summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2013-09-23 14:18:54 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-09-24 12:12:56 +0100
commitb8d1f3f7c6a42c46df623d64e7967c79da797e20 (patch)
treee1f31fe6c60e338c6d3f811c0bf7b726f107f759
parent091249a731051268016aac6dba8b9533524884ee (diff)
downloadtelepathy-haze-b8d1f3f7c6a42c46df623d64e7967c79da797e20.tar.gz
initial-roster test: convert to ContactList, ContactGroups
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=49389 Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
-rw-r--r--tests/twisted/constants.py3
-rw-r--r--tests/twisted/roster/initial-roster.py130
2 files changed, 52 insertions, 81 deletions
diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py
index 8c60167..e4235f8 100644
--- a/tests/twisted/constants.py
+++ b/tests/twisted/constants.py
@@ -187,6 +187,9 @@ CONN_IFACE_ADDRESSING = CONN + '.Interface.Addressing1'
ATTR_CONTACT_ID = CONN + '/contact-id'
ATTR_CONTACT_CAPABILITIES = CONN_IFACE_CONTACT_CAPS + '/capabilities'
ATTR_PRESENCE = CONN_IFACE_SIMPLE_PRESENCE + '/presence'
+ATTR_SUBSCRIBE = CONN_IFACE_CONTACT_LIST + '/subscribe'
+ATTR_PUBLISH = CONN_IFACE_CONTACT_LIST + '/publish'
+ATTR_GROUPS = CONN_IFACE_CONTACT_GROUPS + '/groups'
STREAM_HANDLER = PREFIX + '.Media.StreamHandler'
diff --git a/tests/twisted/roster/initial-roster.py b/tests/twisted/roster/initial-roster.py
index f68c4cf..18169fc 100644
--- a/tests/twisted/roster/initial-roster.py
+++ b/tests/twisted/roster/initial-roster.py
@@ -6,7 +6,7 @@ import dbus
from hazetest import exec_test, JabberXmlStream
from servicetest import (assertLength, EventPattern, wrap_channel,
- assertEquals, call_async)
+ assertEquals, call_async, assertSameSets)
import constants as cs
import ns
@@ -42,95 +42,63 @@ def test(q, bus, conn, stream):
stream.send(event.stanza)
- q.expect('dbus-signal', signal='StatusChanged',
- args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])
-
- # Amy, Bob and Chris are all stored on our server-side roster
- call_async(q, conn.Requests, 'EnsureChannel',{
- cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_CONTACT_LIST,
- cs.TARGET_HANDLE_TYPE: cs.HT_LIST,
- cs.TARGET_ID: 'stored',
- })
- e = q.expect('dbus-return', method='EnsureChannel')
- stored = wrap_channel(bus.get_object(conn.bus_name, e.value[1]),
- cs.CHANNEL_TYPE_CONTACT_LIST)
- jids = set(conn.inspect_contacts_sync(stored.Group.GetMembers()))
- assertEquals(set(['amy@foo.com', 'bob@foo.com', 'chris@foo.com']), jids)
-
- call_async(q, conn.Requests, 'EnsureChannel',{
- cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_CONTACT_LIST,
- cs.TARGET_HANDLE_TYPE: cs.HT_LIST,
- cs.TARGET_ID: 'subscribe',
- })
- e = q.expect('dbus-return', method='EnsureChannel')
- subscribe = wrap_channel(bus.get_object(conn.bus_name, e.value[1]),
- cs.CHANNEL_TYPE_CONTACT_LIST)
- jids = set(conn.inspect_contacts_sync(subscribe.Group.GetMembers()))
- # everyone on our roster is (falsely!) alleged to be on 'subscribe'
- # (in fact this ought to be just Amy and Chris, but libpurple apparently
- # can't represent this)
- assertEquals(set(['amy@foo.com', 'bob@foo.com', 'chris@foo.com']), jids)
-
- call_async(q, conn.Requests, 'EnsureChannel',{
- cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_CONTACT_LIST,
- cs.TARGET_HANDLE_TYPE: cs.HT_LIST,
- cs.TARGET_ID: 'publish',
- })
- e = q.expect('dbus-return', method='EnsureChannel')
- publish = wrap_channel(bus.get_object(conn.bus_name, e.value[1]),
- cs.CHANNEL_TYPE_CONTACT_LIST)
- jids = set(conn.inspect_contacts_sync(publish.Group.GetMembers()))
- # the publish list is somewhat imaginary because libpurple doesn't have
- # state-recovery
- assertEquals(set(), jids)
-
- call_async(q, conn.Requests, 'EnsureChannel',{
- cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_CONTACT_LIST,
- cs.TARGET_HANDLE_TYPE: cs.HT_GROUP,
- cs.TARGET_ID: '3 letter names',
- })
- e = q.expect('dbus-return', method='EnsureChannel')
- group_chan = wrap_channel(bus.get_object(conn.bus_name, e.value[1]),
- cs.CHANNEL_TYPE_CONTACT_LIST)
- jids = set(conn.inspect_contacts_sync(group_chan.Group.GetMembers()))
- assertEquals(set(['amy@foo.com', 'bob@foo.com']), jids)
+ _, s, _ = q.expect_many(
+ EventPattern('dbus-signal', signal='StatusChanged',
+ args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]),
+ EventPattern('dbus-signal', signal='ContactsChanged',
+ interface=cs.CONN_IFACE_CONTACT_LIST, path=conn.object_path),
+ EventPattern('dbus-signal', signal='ContactListStateChanged',
+ args=[cs.CONTACT_LIST_STATE_SUCCESS]),
+ )
+
+ amy, bob, chris = conn.get_contact_handles_sync(
+ ['amy@foo.com', 'bob@foo.com', 'chris@foo.com'])
+
+ # Amy, Bob and Chris are all stored on our server-side roster.
+ #
+ # Everyone on our roster is (falsely!) alleged to have subscribe=YES
+ # (in fact this ought to be just Amy and Chris, because we're publishing
+ # presence to Bob without being subscribed to his presence, but libpurple
+ # apparently can't represent this).
+ #
+ # The publish value is unknown, because libpurple doesn't have
+ # state-recovery.
+ assertEquals([{
+ amy: (cs.SUBSCRIPTION_STATE_YES, cs.SUBSCRIPTION_STATE_UNKNOWN, ''),
+ bob: (cs.SUBSCRIPTION_STATE_YES, cs.SUBSCRIPTION_STATE_UNKNOWN, ''),
+ chris: (cs.SUBSCRIPTION_STATE_YES, cs.SUBSCRIPTION_STATE_UNKNOWN, ''),
+ }, []], s.args)
# the XMPP prpl puts people into some sort of group, probably called
# Buddies
- channels = conn.Properties.Get(cs.CONN_IFACE_REQUESTS, 'Channels')
+ groups = conn.Properties.Get(cs.CONN_IFACE_CONTACT_GROUPS, 'Groups')
default_group = None
- default_props = None
-
- for path, props in channels:
- if props.get(cs.CHANNEL_TYPE) != cs.CHANNEL_TYPE_CONTACT_LIST:
- continue
-
- if props.get(cs.TARGET_HANDLE_TYPE) != cs.HT_GROUP:
- continue
- if path == group_chan.object_path:
+ for group in groups:
+ if group == '3 letter names':
continue
if default_group is not None:
raise AssertionError('Two unexplained groups: %s, %s' %
- (path, default_group.object_path))
-
- default_group = wrap_channel(bus.get_object(conn.bus_name, path),
- cs.CHANNEL_TYPE_CONTACT_LIST)
- default_props = props
-
- jids = set(conn.inspect_contacts_sync(default_group.Group.GetMembers()))
- assertEquals(set(['chris@foo.com']), jids)
-
- call_async(q, conn.Requests, 'EnsureChannel',{
- cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_CONTACT_LIST,
- cs.TARGET_HANDLE_TYPE: cs.HT_GROUP,
- cs.TARGET_ID: default_props[cs.TARGET_ID],
- })
- e = q.expect('dbus-return', method='EnsureChannel')
- assertEquals(False, e.value[0])
- assertEquals(default_group.object_path, e.value[1])
- assertEquals(default_props, e.value[2])
+ (group, default_group))
+
+ default_group = group
+
+ call_async(q, conn.ContactList, 'GetContactListAttributes',
+ [cs.CONN_IFACE_CONTACT_GROUPS], False)
+ r = q.expect('dbus-return', method='GetContactListAttributes')
+
+ assertEquals(cs.SUBSCRIPTION_STATE_YES, r.value[0][amy][cs.ATTR_SUBSCRIBE])
+ assertEquals(cs.SUBSCRIPTION_STATE_YES, r.value[0][bob][cs.ATTR_SUBSCRIBE])
+ assertEquals(cs.SUBSCRIPTION_STATE_YES, r.value[0][chris][cs.ATTR_SUBSCRIBE])
+
+ assertEquals(cs.SUBSCRIPTION_STATE_UNKNOWN, r.value[0][amy][cs.ATTR_PUBLISH])
+ assertEquals(cs.SUBSCRIPTION_STATE_UNKNOWN, r.value[0][bob][cs.ATTR_PUBLISH])
+ assertEquals(cs.SUBSCRIPTION_STATE_UNKNOWN, r.value[0][chris][cs.ATTR_PUBLISH])
+
+ assertSameSets(['3 letter names'], r.value[0][amy][cs.ATTR_GROUPS])
+ assertSameSets(['3 letter names'], r.value[0][bob][cs.ATTR_GROUPS])
+ assertSameSets([default_group], r.value[0][chris][cs.ATTR_GROUPS])
if __name__ == '__main__':
exec_test(test, protocol=JabberXmlStream, do_connect=False)