telepathy-gabble: factor out get_contacts_presences_sync()
Guillaume Desmottes
gdesmott at kemper.freedesktop.org
Fri Oct 11 14:58:34 PDT 2013
Module: telepathy-gabble
Branch: master
Commit: 3cb8765b37e612b247eefafa3dafaea56dba0edb
URL: http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=3cb8765b37e612b247eefafa3dafaea56dba0edb
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date: Wed Oct 9 15:21:32 2013 -0400
factor out get_contacts_presences_sync()
---
tests/twisted/Makefile.am | 1 +
tests/twisted/presence/initial-contact-presence.py | 6 ++++--
tests/twisted/presence/shared-status.py | 5 +++--
tests/twisted/presence_helper.py | 2 ++
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 670727e..5865b14 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -238,6 +238,7 @@ TWISTED_OTHER_FILES = \
mucutil.py \
ns.py \
olpc/util.py \
+ presence_helper.py \
presence/__init__.py \
presence/invisible_helper.py \
rostertest.py \
diff --git a/tests/twisted/presence/initial-contact-presence.py b/tests/twisted/presence/initial-contact-presence.py
index c4cf28e..c76309f 100644
--- a/tests/twisted/presence/initial-contact-presence.py
+++ b/tests/twisted/presence/initial-contact-presence.py
@@ -10,6 +10,7 @@ This serves as a regression test for
from gabbletest import exec_test, make_presence, sync_stream, elem
from servicetest import assertEquals, EventPattern, sync_dbus
+from presence_helper import get_contacts_presences_sync
import constants as cs
import ns
@@ -32,13 +33,14 @@ def test(q, bus, conn, stream):
amy, bob, che, dre, eve = conn.get_contact_handles_sync(
['amy at foo.com', 'bob at foo.com', 'che at foo.com', 'dre at foo.com',
'eve at foo.com'])
+
assertEquals({amy: UNKNOWN,
bob: UNKNOWN,
che: UNKNOWN,
dre: UNKNOWN,
eve: UNKNOWN,
},
- conn.SimplePresence.GetPresences([amy, bob, che, dre, eve]))
+ get_contacts_presences_sync(conn, [amy, bob, che, dre, eve]))
# Before the server sends Gabble the roster, it relays an 'unavailable'
# presence for one of the contacts we're subscribed to. This seems to
@@ -94,7 +96,7 @@ def test(q, bus, conn, stream):
dre: OFFLINE,
eve: AVAILABLE,
},
- conn.SimplePresence.GetPresences([amy, bob, che, dre, eve]))
+ get_contacts_presences_sync(conn, [amy, bob, che, dre, eve]))
if __name__ == '__main__':
exec_test(test)
diff --git a/tests/twisted/presence/shared-status.py b/tests/twisted/presence/shared-status.py
index 53dab68..b2e02b8 100644
--- a/tests/twisted/presence/shared-status.py
+++ b/tests/twisted/presence/shared-status.py
@@ -17,6 +17,7 @@ import constants as cs
import dbus
from twisted.words.xish import xpath, domish
from invisible_helper import SharedStatusStream
+from presence_helper import get_contacts_presences_sync
presence_types = {'available' : cs.PRESENCE_AVAILABLE,
'away' : cs.PRESENCE_AWAY,
@@ -38,7 +39,7 @@ def _show_to_shared_status_show(show):
def _test_remote_status(q, bus, conn, stream, msg, show, list_attrs):
self = conn.Properties.Get(cs.CONN, "SelfHandle")
- presence = conn.SimplePresence.GetPresences([self])[self]
+ presence = get_contacts_presences_sync(conn, [self])[self]
is_away = presence[0] in (cs.PRESENCE_AWAY, cs.PRESENCE_EXTENDED_AWAY)
if is_away:
@@ -79,7 +80,7 @@ def _test_local_status(q, conn, stream, msg, show, expected_show=None):
away = expected_show in ('away', 'xa')
self = conn.Properties.Get(cs.CONN, "SelfHandle")
- prev_presence = conn.SimplePresence.GetPresences([self])[self]
+ prev_presence = get_contacts_presences_sync(conn, [self])[self]
was_away = prev_presence[0] in (cs.PRESENCE_AWAY,
cs.PRESENCE_EXTENDED_AWAY)
was_invisible = (prev_presence[0] == cs.PRESENCE_HIDDEN)
diff --git a/tests/twisted/presence_helper.py b/tests/twisted/presence_helper.py
new file mode 100644
index 0000000..5d89a75
--- /dev/null
+++ b/tests/twisted/presence_helper.py
@@ -0,0 +1,2 @@
+def get_contacts_presences_sync(conn, contacts):
+ return conn.SimplePresence.GetPresences(contacts)
More information about the telepathy-commits
mailing list