[Telepathy-commits] [telepathy-mission-control/master] Tests: Add fakeclient, implementing the Telepathy.Client.DRAFT interface
Alban Crequy
alban.crequy at collabora.co.uk
Mon Nov 17 08:53:48 PST 2008
---
test/twisted/Makefile.am | 1 +
test/twisted/fakeclient.py | 57 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 0 deletions(-)
create mode 100644 test/twisted/fakeclient.py
diff --git a/test/twisted/Makefile.am b/test/twisted/Makefile.am
index 90004ce..fd172ef 100644
--- a/test/twisted/Makefile.am
+++ b/test/twisted/Makefile.am
@@ -28,6 +28,7 @@ check-twisted:
EXTRA_DIST = \
$(TWISTED_BASIC_TESTS) \
+ fakeclient.py \
fakecm.py \
mctest.py \
servicetest.py
diff --git a/test/twisted/fakeclient.py b/test/twisted/fakeclient.py
new file mode 100644
index 0000000..8e192e6
--- /dev/null
+++ b/test/twisted/fakeclient.py
@@ -0,0 +1,57 @@
+import dbus
+import dbus.service
+from servicetest import Event
+from servicetest import EventPattern, tp_name_prefix, tp_path_prefix
+
+client_iface = "org.freedesktop.Telepathy.Client.DRAFT"
+client_observer_iface = "org.freedesktop.Telepathy.Client.Observer.DRAFT"
+client_approver_iface = "org.freedesktop.Telepathy.Client.Approver.DRAFT"
+client_handler_iface = "org.freedesktop.Telepathy.Client.Handler.DRAFT"
+
+properties_iface = "org.freedesktop.DBus.Properties"
+
+class FakeClient(dbus.service.Object):
+ def __init__(self, object_path, q, bus, bus_name, nameref):
+ self.object_path = object_path
+ self.q = q
+ self.bus = bus
+ self.bus_name = bus_name
+ # keep a reference on nameref, otherwise, the name will be lost!
+ self.nameref = nameref
+ dbus.service.Object.__init__(self, bus, object_path)
+
+ @dbus.service.method(dbus_interface=properties_iface,
+ in_signature='ss', out_signature='v')
+ def Get(self, interface_name, property_name):
+ self.q.append(Event('dbus-method-call', name="Get",
+ obj=self, interface_name=interface_name,
+ property_name=property_name))
+ if interface_name == client_iface and property_name == "Interfaces":
+ return dbus.Array([
+ client_observer_iface,
+ client_approver_iface,
+ client_handler_iface
+ ])
+ return None
+
+ @dbus.service.method(dbus_interface=properties_iface,
+ in_signature='s', out_signature='a{sv}')
+ def GetAll(self, interface_name):
+ self.q.append(Event('dbus-method-call', name="GetAll",
+ obj=self, interface_name=interface_name))
+ if interface_name == client_iface:
+ return dbus.Dictionary({
+ 'Interfaces': dbus.Array([
+ client_observer_iface,
+ client_approver_iface,
+ client_handler_iface
+ ])
+ }, signature='sv')
+ return None
+
+def start_fake_client(q, bus, bus_name, object_path):
+ nameref = dbus.service.BusName(bus_name, bus=bus)
+ client = FakeClient(object_path, q, bus, bus_name, nameref)
+ return client
+
+
--
1.5.6.5
More information about the Telepathy-commits
mailing list