summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2010-12-21 13:20:41 (GMT)
committerJonny Lamb <jonny.lamb@collabora.co.uk>2010-12-21 13:20:41 (GMT)
commit95e56df4a2a0acc89c86fd85eb25ae0e7cdb603d (patch)
tree29c7a54f46d09addb75d26f3cf261dcf123ee128
parente3e955d792db4328ff026a7c1c48c13dc8028826 (diff)
downloadtelepathy-mission-control-95e56df4a2a0acc89c86fd85eb25ae0e7cdb603d.tar.gz
telepathy-mission-control-95e56df4a2a0acc89c86fd85eb25ae0e7cdb603d.tar.xz
mctest: implement GetContactAttributes and GetAll on Contacts
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--test/twisted/mctest.py45
1 files changed, 39 insertions, 6 deletions
diff --git a/test/twisted/mctest.py b/test/twisted/mctest.py
index 41e7eaf..e67b8cd 100644
--- a/test/twisted/mctest.py
+++ b/test/twisted/mctest.py
@@ -244,6 +244,14 @@ class SimulatedConnection(object):
interface=cs.PROPERTIES_IFACE, method='GetAll',
args=[cs.CONN_IFACE_REQUESTS])
+ q.add_dbus_method_impl(self.GetContactAttributes,
+ path=self.object_path,
+ interface=cs.CONN_IFACE_CONTACTS, method='GetContactAttributes')
+ q.add_dbus_method_impl(self.GetAll_Contacts,
+ path=self.object_path,
+ interface=cs.PROPERTIES_IFACE, method='GetAll',
+ args=[cs.CONN_IFACE_CONTACTS])
+
if not has_requests:
q.add_dbus_method_impl(self.ListChannels,
path=self.object_path, interface=cs.CONN,
@@ -410,18 +418,25 @@ class SimulatedConnection(object):
for c in self.channels:
c.close()
- def InspectHandles(self, e):
- htype, hs = e.args
+ def inspect_handles(self, handles, htype=cs.HT_CONTACT):
ret = []
- for h in hs:
+ for h in handles:
if (htype, h) in self._identifiers:
ret.append(self._identifiers[(htype, h)])
else:
- self.q.dbus_raise(e.message, INVALID_HANDLE, str(h))
- return
+ raise Exception(h)
+
+ return ret
- self.q.dbus_return(e.message, ret, signature='as')
+ def InspectHandles(self, e):
+ htype, hs = e.args
+
+ try:
+ ret = self.inspect_handles(hs, htype)
+ self.q.dbus_return(e.message, ret, signature='as')
+ except e:
+ self.q.dbus_raise(e.message, INVALID_HANDLE, str(e.args[0]))
def GetStatus(self, e):
self.q.dbus_return(e.message, self.status, signature='u')
@@ -499,6 +514,24 @@ class SimulatedConnection(object):
for channel in channels],
signature='a(oa{sv})')
+ def GetContactAttributes(self, e):
+ ret = {}
+
+ try:
+ for h in e.args[0]:
+ id = self.inspect_handles(h)[0]
+ ret[dbus.UInt32(h)] = dbus.Dictionary({telepathy.CONN_IFACE + '/contact-id': id},
+ signature='sv')
+
+ q.dbus_return(e.message, ret, signature='a{ua{sv}}')
+ except e:
+ self.q.dbus_raise(e.message, INVALID_HANDLE, str(e.args[0]))
+
+ def GetAll_Contacts(self, e):
+ self.q.dbus_return(e.message, {
+ 'ContactAttributeInterfaces': []
+ }, signature='a{sv}')
+
class SimulatedChannel(object):
def __init__(self, conn, immutable, mutable={},
destroyable=False, group=False):