[telepathy-mission-control/master] dispatcher/create-text.py etc.: check that AddRequest is called on the right handler

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Oct 20 13:58:21 PDT 2009


---
 test/twisted/dispatcher/create-text.py             |   44 ++++++++------------
 .../dispatcher/dispatch-delayed-by-plugin.py       |    4 +-
 test/twisted/dispatcher/ensure-is-approval.py      |   10 +----
 3 files changed, 22 insertions(+), 36 deletions(-)

diff --git a/test/twisted/dispatcher/create-text.py b/test/twisted/dispatcher/create-text.py
index cf93b7c..d706512 100644
--- a/test/twisted/dispatcher/create-text.py
+++ b/test/twisted/dispatcher/create-text.py
@@ -115,34 +115,26 @@ def test_channel_creation(q, bus, account, client, conn,
     # call, be in a defined order? Probably not though, since CMs and Clients
     # aren't meant to be the same process!
 
-    if channel_type == cs.CHANNEL_TYPE_TEXT:
-        cm_request_call, add_request_call = q.expect_many(
-                EventPattern('dbus-method-call',
-                    interface=cs.CONN_IFACE_REQUESTS,
-                    method=(ensure and 'EnsureChannel' or 'CreateChannel'),
-                    path=conn.object_path, args=[request], handled=False),
-                # FIXME: we should get AddRequest in the other case, too
-                EventPattern('dbus-method-call', handled=False,
-                    interface=cs.CLIENT_IFACE_REQUESTS,
-                    method='AddRequest'),
-                )
-
-        assert add_request_call.args[0] == request_path
-        # FIXME: untrue:
-        # assert add_request_call.path == prefer.object_path
-        request_props = add_request_call.args[1]
-        assert request_props[cs.CR + '.Account'] == account.object_path
-        assert request_props[cs.CR + '.Requests'] == [request]
-        assert request_props[cs.CR + '.UserActionTime'] == user_action_time
-        assert request_props[cs.CR + '.PreferredHandler'] == prefer.bus_name
-        assert request_props[cs.CR + '.Interfaces'] == []
-
-        q.dbus_return(add_request_call.message, signature='')
-    else:
-        cm_request_call = q.expect('dbus-method-call',
+    cm_request_call, add_request_call = q.expect_many(
+            EventPattern('dbus-method-call',
                 interface=cs.CONN_IFACE_REQUESTS,
                 method=(ensure and 'EnsureChannel' or 'CreateChannel'),
-                path=conn.object_path, args=[request], handled=False)
+                path=conn.object_path, args=[request], handled=False),
+            EventPattern('dbus-method-call', handled=False,
+                interface=cs.CLIENT_IFACE_REQUESTS,
+                method='AddRequest'),
+            )
+
+    assert add_request_call.args[0] == request_path
+    assert add_request_call.path == prefer.object_path
+    request_props = add_request_call.args[1]
+    assert request_props[cs.CR + '.Account'] == account.object_path
+    assert request_props[cs.CR + '.Requests'] == [request]
+    assert request_props[cs.CR + '.UserActionTime'] == user_action_time
+    assert request_props[cs.CR + '.PreferredHandler'] == prefer.bus_name
+    assert request_props[cs.CR + '.Interfaces'] == []
+
+    q.dbus_return(add_request_call.message, signature='')
 
     # Time passes. A channel is returned.
 
diff --git a/test/twisted/dispatcher/dispatch-delayed-by-plugin.py b/test/twisted/dispatcher/dispatch-delayed-by-plugin.py
index 0279feb..52c99aa 100644
--- a/test/twisted/dispatcher/dispatch-delayed-by-plugin.py
+++ b/test/twisted/dispatcher/dispatch-delayed-by-plugin.py
@@ -205,7 +205,7 @@ def test(q, bus, mc):
             EventPattern('dbus-return', method='EnsureChannel'),
             EventPattern('dbus-method-call', handled=False,
                 interface=cs.CLIENT_IFACE_REQUESTS,
-                method='AddRequest'), # FIXME: path=kopete.object_path),
+                method='AddRequest', path=kopete.object_path),
             )
     request_path = ret.value[0]
 
@@ -243,7 +243,7 @@ def test(q, bus, mc):
     q.dbus_return(e.message, signature='')
 
     e = q.expect('dbus-method-call',
-            # FIXME: untrue: path=kopete.object_path,
+            path=kopete.object_path,
             interface=cs.HANDLER, method='HandleChannels',
             handled=False)
     assert e.args[0] == account.object_path, e.args
diff --git a/test/twisted/dispatcher/ensure-is-approval.py b/test/twisted/dispatcher/ensure-is-approval.py
index 4cb0755..131875a 100644
--- a/test/twisted/dispatcher/ensure-is-approval.py
+++ b/test/twisted/dispatcher/ensure-is-approval.py
@@ -189,7 +189,7 @@ def test(q, bus, mc):
             EventPattern('dbus-return', method='EnsureChannel'),
             EventPattern('dbus-method-call', handled=False,
                 interface=cs.CLIENT_IFACE_REQUESTS,
-                method='AddRequest'), # FIXME: path=kopete.object_path),
+                method='AddRequest', path=kopete.object_path),
             )
     request_path = ret.value[0]
 
@@ -218,13 +218,7 @@ def test(q, bus, mc):
             method='EnsureChannel',
             path=conn.object_path, args=[request], handled=False)
 
-    # FIXME: we should be able to assert that this goes to Kopete, above
-    if add_request_call.path == kopete.object_path:
-        q.dbus_return(add_request_call.message, bus=kopete_bus, signature='')
-    elif add_request_call.path == empathy.object_path:
-        q.dbus_return(add_request_call.message, bus=empathy_bus, signature='')
-    else:
-        assert False, "%s is neither Empathy nor Kopete" % add_request_call.path
+    q.dbus_return(add_request_call.message, bus=kopete_bus, signature='')
 
     # Time passes. The CM returns the existing channel
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list