[Telepathy-commits] [telepathy-gabble/master] Add fd.o #12791 regression test back as a separate file

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Aug 19 10:51:52 PDT 2008


20080428163705-53eee-961c527cac0f951f14e682682bd2cac67604449c.gz
---
 tests/twisted/Makefile.am            |    1 +
 tests/twisted/roster/groups-12791.py |   89 ++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 0 deletions(-)
 create mode 100644 tests/twisted/roster/groups-12791.py

diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 8e130f7..a356468 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -8,6 +8,7 @@ TWISTED_TESTS = \
 	olpc/test-olpc-bundle.py \
 	olpc/test-olpc-set-props-preload.py \
 	roster/groups.py \
+	roster/groups-12791.py \
 	roster/test-google-roster.py \
 	roster/test-roster.py \
 	roster/test-roster-subscribe.py \
diff --git a/tests/twisted/roster/groups-12791.py b/tests/twisted/roster/groups-12791.py
new file mode 100644
index 0000000..83b249c
--- /dev/null
+++ b/tests/twisted/roster/groups-12791.py
@@ -0,0 +1,89 @@
+
+"""
+Test basic roster functionality.
+"""
+
+import dbus
+
+from gabbletest import exec_test
+
+
+HT_CONTACT_LIST = 3
+HT_GROUP = 4
+
+
+def _expect_contact_list_channel(q, bus, conn, name, contacts):
+    event = q.expect('dbus-signal', signal='NewChannel')
+    path, type, handle_type, handle, suppress_handler = event.args
+    assert type == u'org.freedesktop.Telepathy.Channel.Type.ContactList', type
+    assert handle_type == HT_CONTACT_LIST, handle_type
+    inspected = conn.InspectHandles(handle_type, [handle])[0]
+    assert inspected == name, (inspected, name)
+    chan = bus.get_object(conn._named_service, path)
+    group_iface = dbus.Interface(chan,
+        u'org.freedesktop.Telepathy.Channel.Interface.Group')
+    inspected = conn.InspectHandles(1, group_iface.GetMembers())
+    assert inspected == contacts, (inspected, contacts)
+
+def _expect_group_channel(q, bus, conn, name, contacts):
+    event = q.expect('dbus-signal', signal='NewChannel')
+    path, type, handle_type, handle, suppress_handler = event.args
+    assert type == u'org.freedesktop.Telepathy.Channel.Type.ContactList', type
+    assert handle_type == HT_GROUP, handle_type
+    inspected = conn.InspectHandles(handle_type, [handle])[0]
+    assert inspected == name, (inspected, name)
+    chan = bus.get_object(conn._named_service, path)
+    group_iface = dbus.Interface(chan,
+        u'org.freedesktop.Telepathy.Channel.Interface.Group')
+    inspected = conn.InspectHandles(1, group_iface.GetMembers())
+    assert inspected == contacts, (inspected, contacts)
+
+def test(q, bus, conn, stream):
+    conn.Connect()
+    q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+
+    event = q.expect('stream-iq', query_ns='jabber:iq:roster')
+    event.stanza['type'] = 'result'
+
+    item = event.query.addElement('item')
+    item['jid'] = 'amy at foo.com'
+    item['subscription'] = 'both'
+    group = item.addElement('group', content='women')
+    group = item.addElement('group', content='affected-by-fdo-12791')
+
+    item = event.query.addElement('item')
+    item['jid'] = 'bob at foo.com'
+    item['subscription'] = 'from'
+    group = item.addElement('group', content='men')
+
+    item = event.query.addElement('item')
+    item['jid'] = 'che at foo.com'
+    item['subscription'] = 'to'
+    group = item.addElement('group', content='men')
+
+    item = event.query.addElement('item')
+    item['jid'] = 'amy at foo.com'
+    item['subscription'] = 'both'
+    group = item.addElement('group', content='women')
+
+    stream.send(event.stanza)
+
+    # FIXME: this is somewhat fragile - it's asserting the exact order that
+    # things currently happen in roster.c. In reality the order is not
+    # significant
+    _expect_contact_list_channel(q, bus, conn, 'publish',
+        ['amy at foo.com', 'bob at foo.com'])
+    _expect_contact_list_channel(q, bus, conn, 'subscribe',
+        ['amy at foo.com', 'che at foo.com'])
+    _expect_contact_list_channel(q, bus, conn, 'known',
+        ['amy at foo.com', 'bob at foo.com', 'che at foo.com'])
+    _expect_group_channel(q, bus, conn, 'women', ['amy at foo.com'])
+    _expect_group_channel(q, bus, conn, 'affected-by-fdo-12791', [])
+    _expect_group_channel(q, bus, conn, 'men', ['bob at foo.com', 'che at foo.com'])
+
+    conn.Disconnect()
+    q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+
+if __name__ == '__main__':
+    exec_test(test)
+
-- 
1.5.6.3




More information about the Telepathy-commits mailing list