telepathy-gabble: test-roster: stop using old roster API

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Tue Oct 8 12:53:34 PDT 2013


Module: telepathy-gabble
Branch: master
Commit: 0753746ad8e5ed29e0ee75fae09861ce04ab2939
URL:    http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=0753746ad8e5ed29e0ee75fae09861ce04ab2939

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Tue Oct  8 14:54:30 2013 -0400

test-roster: stop using old roster API

Also, use contacts_changed_predicate.

---

 tests/twisted/roster/test-roster.py |   33 +++++++++++----------------------
 1 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/tests/twisted/roster/test-roster.py b/tests/twisted/roster/test-roster.py
index 28d46b3..407eb2b 100644
--- a/tests/twisted/roster/test-roster.py
+++ b/tests/twisted/roster/test-roster.py
@@ -3,8 +3,8 @@ Test basic roster functionality.
 """
 
 from gabbletest import exec_test
-from rostertest import expect_contact_list_signals, check_contact_list_signals
-from servicetest import (assertEquals, assertLength, call_async)
+from rostertest import check_contact_roster, contacts_changed_predicate
+from servicetest import (assertEquals, call_async)
 import constants as cs
 import ns
 
@@ -37,23 +37,21 @@ def test(q, bus, conn, stream):
     # roster query twice. This used to crash Gabble.
     stream.send(event.stanza)
 
+    contacts = [
+        ('amy at foo.com', cs.SUBSCRIPTION_STATE_YES, cs.SUBSCRIPTION_STATE_YES, ''),
+        ('bob at foo.com', cs.SUBSCRIPTION_STATE_NO, cs.SUBSCRIPTION_STATE_YES, ''),
+        ('che at foo.com', cs.SUBSCRIPTION_STATE_YES, cs.SUBSCRIPTION_STATE_NO, ''),
+        ]
+
     # slight implementation detail: TpBaseContactList emits ContactsChanged
     # before it announces its channels
-    s = q.expect('dbus-signal', signal='ContactsChanged',
-            interface=cs.CONN_IFACE_CONTACT_LIST, path=conn.object_path)
+    q.expect('dbus-signal', signal='ContactsChangedWithID',
+            interface=cs.CONN_IFACE_CONTACT_LIST, path=conn.object_path,
+            predicate=lambda e: contacts_changed_predicate(e, conn, contacts))
 
     amy, bob, che = conn.get_contact_handles_sync(
             ['amy at foo.com', 'bob at foo.com', 'che at foo.com'])
 
-    assertEquals([{
-        amy: (cs.SUBSCRIPTION_STATE_YES, cs.SUBSCRIPTION_STATE_YES, ''),
-        bob: (cs.SUBSCRIPTION_STATE_NO, cs.SUBSCRIPTION_STATE_YES, ''),
-        che: (cs.SUBSCRIPTION_STATE_YES, cs.SUBSCRIPTION_STATE_NO, ''),
-        }, []], s.args)
-
-    pairs = expect_contact_list_signals(q, bus, conn,
-            ['publish', 'subscribe', 'stored'])
-
     # this is emitted last, so clients can tell when the initial state dump
     # has finished
     q.expect('dbus-signal', signal='ContactListStateChanged',
@@ -82,14 +80,5 @@ def test(q, bus, conn, stream):
             },
         },), r.value)
 
-    check_contact_list_signals(q, bus, conn, pairs.pop(0), cs.HT_LIST,
-            'publish', ['amy at foo.com', 'bob at foo.com'])
-    check_contact_list_signals(q, bus, conn, pairs.pop(0), cs.HT_LIST,
-            'subscribe', ['amy at foo.com', 'che at foo.com'])
-    check_contact_list_signals(q, bus, conn, pairs.pop(0), cs.HT_LIST,
-            'stored', ['amy at foo.com', 'bob at foo.com', 'che at foo.com'])
-
-    assertLength(0, pairs)      # i.e. we've checked all of them
-
 if __name__ == '__main__':
     exec_test(test)



More information about the telepathy-commits mailing list