[Telepathy-commits] [telepathy-mission-control/master] Test SetSelfCapabilities: add a fake client with a tube capability, and check MC calls SetSelfCapabilities correctly
Alban Crequy
alban.crequy at collabora.co.uk
Tue Nov 18 07:55:30 PST 2008
---
test/twisted/fakeclient.py | 23 +++++++++++++++++++----
test/twisted/test-connect.py | 19 ++++++++++++++++++-
2 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/test/twisted/fakeclient.py b/test/twisted/fakeclient.py
index 8e192e6..fee1258 100644
--- a/test/twisted/fakeclient.py
+++ b/test/twisted/fakeclient.py
@@ -10,14 +10,18 @@ client_handler_iface = "org.freedesktop.Telepathy.Client.Handler.DRAFT"
properties_iface = "org.freedesktop.DBus.Properties"
+empty_caps = dbus.Array([], signature='a{sv}')
+
class FakeClient(dbus.service.Object):
- def __init__(self, object_path, q, bus, bus_name, nameref):
+ def __init__(self, object_path, q, bus, bus_name, nameref,
+ caps = empty_caps):
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
+ self.caps = caps
dbus.service.Object.__init__(self, bus, object_path)
@dbus.service.method(dbus_interface=properties_iface,
@@ -31,7 +35,18 @@ class FakeClient(dbus.service.Object):
client_observer_iface,
client_approver_iface,
client_handler_iface
- ])
+ ], signature='s')
+ if interface_name == client_observer_iface and \
+ property_name == "ObserverChannelFilter":
+ return empty_caps
+ if interface_name == client_approver_iface and \
+ property_name == "ApproverChannelFilter":
+ return empty_caps
+ if interface_name == client_handler_iface and \
+ property_name == "HandlerChannelFilter":
+ return self.caps
+ print "Error: interface_name=%s property_name=%s" % \
+ (interface_name, property_name)
return None
@dbus.service.method(dbus_interface=properties_iface,
@@ -49,9 +64,9 @@ class FakeClient(dbus.service.Object):
}, signature='sv')
return None
-def start_fake_client(q, bus, bus_name, object_path):
+def start_fake_client(q, bus, bus_name, object_path, caps):
nameref = dbus.service.BusName(bus_name, bus=bus)
- client = FakeClient(object_path, q, bus, bus_name, nameref)
+ client = FakeClient(object_path, q, bus, bus_name, nameref, caps)
return client
diff --git a/test/twisted/test-connect.py b/test/twisted/test-connect.py
index b3b1384..d2e8a8c 100644
--- a/test/twisted/test-connect.py
+++ b/test/twisted/test-connect.py
@@ -2,17 +2,34 @@ import dbus
from servicetest import EventPattern, tp_name_prefix, tp_path_prefix
from fakecm import start_fake_connection_manager
+from fakeclient import start_fake_client
from mctest import exec_test
FakeCM_bus_name = "org.freedesktop.Telepathy.ConnectionManager.fakecm"
ConnectionManager_object_path = \
"/org/freedesktop/Telepathy/ConnectionManager/fakecm"
+FakeClient_bus_name = "org.freedesktop.Telepathy.Client.fakeclient"
+Client_object_path = \
+ "/org/freedesktop/Telepathy/Client/fakeclient"
+
def test(q, bus, mc):
start_fake_connection_manager(q, bus, FakeCM_bus_name,
ConnectionManager_object_path)
+ http_fixed_properties = dbus.Dictionary({
+ 'org.freedesktop.Telepathy.Channel.TargetHandleType': 1L,
+ 'org.freedesktop.Telepathy.Channel.ChannelType':
+ 'org.freedesktop.Telepathy.Channel.Type.StreamTube.DRAFT',
+ 'org.freedesktop.Telepathy.Channel.Type.StreamTube.DRAFT.Service':
+ 'http'
+ }, signature='sv')
+ caps = dbus.Array([http_fixed_properties], signature='a{sv}')
+
+ start_fake_client(q, bus, FakeClient_bus_name,
+ Client_object_path, caps)
+
# Get the AccountManager interface
account_manager = bus.get_object(
tp_name_prefix + '.AccountManager',
@@ -77,7 +94,7 @@ def test(q, bus, mc):
e = q.expect('dbus-method-call', name='SetSelfCapabilities',
path=conn_object_path)
- assert e.caps == dbus.Array([]), e.caps
+ assert e.caps == caps, e.caps
# Check the requested presence is online
properties = account.GetAll(
--
1.5.6.5
More information about the Telepathy-commits
mailing list