diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-09-23 12:56:53 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-09-24 12:12:44 +0100 |
commit | c4fb4468d51bfe46e6ecd9b850bcb93cb528399f (patch) | |
tree | d2ac18d082126645d0ba0e6aa65c1200d9eef80b | |
parent | 309d2316079783841deff16ad37e3bb434dc7197 (diff) | |
download | telepathy-haze-c4fb4468d51bfe46e6ecd9b850bcb93cb528399f.tar.gz |
sync servicetest.py from Gabble
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=49389
Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
-rw-r--r-- | tests/twisted/servicetest.py | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py index 31c00f4..fcba708 100644 --- a/tests/twisted/servicetest.py +++ b/tests/twisted/servicetest.py @@ -13,14 +13,16 @@ import os import pprint import unittest -import dbus.glib +import dbus +from dbus.mainloop.glib import DBusGMainLoop +DBusGMainLoop(set_as_default=True) from twisted.internet import reactor import constants as cs -tp_name_prefix = 'org.freedesktop.Telepathy' -tp_path_prefix = '/org/freedesktop/Telepathy' +tp_name_prefix = cs.PREFIX +tp_path_prefix = '/' + cs.PREFIX.replace('.', '/') class DictionarySupersetOf (object): """Utility class for expecting "a dictionary with at least these keys".""" @@ -433,7 +435,7 @@ def sync_dbus(bus, q, conn): assert conn.object.bus_name.startswith(':') root_object = bus.get_object(conn.object.bus_name, '/', introspect=False) call_async(q, - dbus.Interface(root_object, 'org.freedesktop.Telepathy.Tests'), + dbus.Interface(root_object, cs.PREFIX + '.Tests'), 'DummySyncDBus') q.expect('dbus-error', method='DummySyncDBus') @@ -457,8 +459,25 @@ class ProxyWrapper: return getattr(self.default_interface, name) +class ConnWrapper(ProxyWrapper): + def inspect_contact_sync(self, handle): + return self.inspect_contacts_sync([handle])[0] + + def inspect_contacts_sync(self, handles): + h2asv = self.Contacts.GetContactAttributes(handles, [], True) + ret = [] + for h in handles: + ret.append(h2asv[h][cs.ATTR_CONTACT_ID]) + return ret + + def get_contact_handle_sync(self, identifier): + return self.Contacts.GetContactByID(identifier, [])[0] + + def get_contact_handles_sync(self, ids): + return [self.get_contact_handle_sync(i) for i in ids] + def wrap_connection(conn): - return ProxyWrapper(conn, tp_name_prefix + '.Connection', + return ConnWrapper(conn, tp_name_prefix + '.Connection', dict([ (name, tp_name_prefix + '.Connection.Interface.' + name) for name in ['Aliasing', 'Avatars', 'Capabilities', 'Contacts', |