telepathy-haze: sync servicetest.py from Gabble

Simon McVittie smcv at kemper.freedesktop.org
Tue Sep 24 04:14:09 PDT 2013


Module: telepathy-haze
Branch: master
Commit: c4fb4468d51bfe46e6ecd9b850bcb93cb528399f
URL:    http://cgit.freedesktop.org/telepathy/telepathy-haze/commit/?id=c4fb4468d51bfe46e6ecd9b850bcb93cb528399f

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Mon Sep 23 12:56:53 2013 +0100

sync servicetest.py from Gabble

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=49389
Reviewed-by: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>

---

 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',



More information about the telepathy-commits mailing list