[telepathy-mission-control/master] Refactor tests to use a new function expect_client_setup

Simon McVittie simon.mcvittie at collabora.co.uk
Tue May 12 09:37:35 PDT 2009


As well as code reduction, this function copes with calling GetAll instead
of Get.
---
 test/twisted/account-requests/cancel.py            |   22 +------
 test/twisted/account-requests/create-text.py       |   22 +------
 .../delete-account-during-request.py               |   22 +------
 test/twisted/dispatcher/already-has-channel.py     |   38 +------------
 test/twisted/dispatcher/bypass-approval.py         |   48 +---------------
 test/twisted/dispatcher/cancel.py                  |   22 +------
 test/twisted/dispatcher/capture-bundle.py          |   50 +---------------
 test/twisted/dispatcher/create-text.py             |   22 +------
 test/twisted/dispatcher/dispatch-text.py           |   39 +------------
 test/twisted/dispatcher/exploding-bundles.py       |   39 +------------
 test/twisted/dispatcher/fdo-21034.py               |   22 +------
 test/twisted/dispatcher/lose-text.py               |   39 +------------
 test/twisted/mctest.py                             |   59 ++++++++++++++++++++
 test/twisted/test-connect.py                       |   22 ++------
 14 files changed, 100 insertions(+), 366 deletions(-)

diff --git a/test/twisted/account-requests/cancel.py b/test/twisted/account-requests/cancel.py
index 9adeffd..f06afdc 100644
--- a/test/twisted/account-requests/cancel.py
+++ b/test/twisted/account-requests/cancel.py
@@ -8,7 +8,8 @@ import dbus.service
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
         call_async
 from mctest import exec_test, SimulatedConnection, SimulatedClient, \
-        create_fakecm_account, enable_fakecm_account, SimulatedChannel
+        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
+        expect_client_setup
 import constants as cs
 
 def test(q, bus, mc):
@@ -34,24 +35,7 @@ def test(q, bus, mc):
             interface=cs.APPROVER, method='AddDispatchOperation')
 
     # wait for MC to download the properties
-    q.expect_many(
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=client.object_path),
-            )
+    expect_client_setup(q, [client])
 
     user_action_time = dbus.Int64(1238582606)
 
diff --git a/test/twisted/account-requests/create-text.py b/test/twisted/account-requests/create-text.py
index 1b8bee0..9bcac97 100644
--- a/test/twisted/account-requests/create-text.py
+++ b/test/twisted/account-requests/create-text.py
@@ -8,7 +8,8 @@ import dbus.service
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
         call_async
 from mctest import exec_test, SimulatedConnection, SimulatedClient, \
-        create_fakecm_account, enable_fakecm_account, SimulatedChannel
+        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
+        expect_client_setup
 import constants as cs
 
 def test(q, bus, mc):
@@ -34,24 +35,7 @@ def test(q, bus, mc):
             interface=cs.APPROVER, method='AddDispatchOperation')
 
     # wait for MC to download the properties
-    q.expect_many(
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=client.object_path),
-            )
+    expect_client_setup(q, [client])
 
     test_channel_creation(q, bus, account, client, conn, False)
     test_channel_creation(q, bus, account, client, conn, True)
diff --git a/test/twisted/account-requests/delete-account-during-request.py b/test/twisted/account-requests/delete-account-during-request.py
index acf6b23..21e58f0 100644
--- a/test/twisted/account-requests/delete-account-during-request.py
+++ b/test/twisted/account-requests/delete-account-during-request.py
@@ -8,7 +8,8 @@ import dbus.service
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
         call_async
 from mctest import exec_test, SimulatedConnection, SimulatedClient, \
-        create_fakecm_account, enable_fakecm_account, SimulatedChannel
+        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
+        expect_client_setup
 import constants as cs
 
 def test(q, bus, mc):
@@ -27,24 +28,7 @@ def test(q, bus, mc):
             handle=[text_fixed_properties], bypass_approval=False)
 
     # wait for MC to download the properties
-    q.expect_many(
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=client.object_path),
-            )
+    expect_client_setup(q, [client])
 
     user_action_time = dbus.Int64(1238582606)
 
diff --git a/test/twisted/dispatcher/already-has-channel.py b/test/twisted/dispatcher/already-has-channel.py
index d991a75..0983de8 100644
--- a/test/twisted/dispatcher/already-has-channel.py
+++ b/test/twisted/dispatcher/already-has-channel.py
@@ -8,7 +8,7 @@ import dbus.service
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
         call_async
 from mctest import exec_test, SimulatedConnection, SimulatedClient, \
-        create_fakecm_account, SimulatedChannel
+        create_fakecm_account, SimulatedChannel, expect_client_setup
 import constants as cs
 
 def test(q, bus, mc):
@@ -30,41 +30,7 @@ def test(q, bus, mc):
             handle=[text_fixed_properties], bypass_approval=False)
 
     # wait for MC to download the properties
-    q.expect_many(
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=empathy.object_path),
-
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=kopete.object_path),
-            )
+    expect_client_setup(q, [empathy, kopete])
 
     # Enable the account
     account.Set(cs.ACCOUNT, 'Enabled', True,
diff --git a/test/twisted/dispatcher/bypass-approval.py b/test/twisted/dispatcher/bypass-approval.py
index 23abdd7..784fbf9 100644
--- a/test/twisted/dispatcher/bypass-approval.py
+++ b/test/twisted/dispatcher/bypass-approval.py
@@ -8,7 +8,8 @@ import dbus.service
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
         call_async
 from mctest import exec_test, SimulatedConnection, SimulatedClient, \
-        create_fakecm_account, enable_fakecm_account, SimulatedChannel
+        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
+        expect_client_setup
 import constants as cs
 
 def test(q, bus, mc):
@@ -45,50 +46,7 @@ def test(q, bus, mc):
             handle=[urgent_fixed_properties], bypass_approval=True)
 
     # wait for MC to download the properties
-    q.expect_many(
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=empathy.object_path),
-
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=kopete.object_path),
-
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=bypass.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=bypass.object_path),
-            )
+    expect_client_setup(q, [empathy, kopete, bypass])
 
     # subscribe to the OperationList interface (MC assumes that until this
     # property has been retrieved once, nobody cares)
diff --git a/test/twisted/dispatcher/cancel.py b/test/twisted/dispatcher/cancel.py
index 9cc885d..aef13d9 100644
--- a/test/twisted/dispatcher/cancel.py
+++ b/test/twisted/dispatcher/cancel.py
@@ -8,7 +8,8 @@ import dbus.service
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
         call_async
 from mctest import exec_test, SimulatedConnection, SimulatedClient, \
-        create_fakecm_account, enable_fakecm_account, SimulatedChannel
+        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
+        expect_client_setup
 import constants as cs
 
 def test(q, bus, mc):
@@ -34,24 +35,7 @@ def test(q, bus, mc):
             interface=cs.APPROVER, method='AddDispatchOperation')
 
     # wait for MC to download the properties
-    q.expect_many(
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=client.object_path),
-            )
+    expect_client_setup(q, [client])
 
     test_channel_creation(q, bus, account, client, conn, False)
     test_channel_creation(q, bus, account, client, conn, True)
diff --git a/test/twisted/dispatcher/capture-bundle.py b/test/twisted/dispatcher/capture-bundle.py
index 261f51d..7f5dd62 100644
--- a/test/twisted/dispatcher/capture-bundle.py
+++ b/test/twisted/dispatcher/capture-bundle.py
@@ -8,7 +8,8 @@ import dbus.service
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
         call_async
 from mctest import exec_test, SimulatedConnection, SimulatedClient, \
-        create_fakecm_account, enable_fakecm_account, SimulatedChannel
+        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
+        expect_client_setup
 import constants as cs
 
 def test(q, bus, mc):
@@ -39,41 +40,7 @@ def test(q, bus, mc):
             bypass_approval=False)
 
     # wait for MC to download the properties
-    q.expect_many(
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=empathy.object_path),
-
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=kopete.object_path),
-            )
+    expect_client_setup(q, [empathy, kopete])
 
     # subscribe to the OperationList interface (MC assumes that until this
     # property has been retrieved once, nobody cares)
@@ -216,16 +183,7 @@ def test(q, bus, mc):
             bypass_approval=True)
 
     # wait for MC to download the properties
-    q.expect_many(
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=bypass.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=bypass.object_path),
-            )
+    expect_client_setup(q, [bypass])
 
     # From now on, this test must fail if we're asked to approve anything
     approval = [
diff --git a/test/twisted/dispatcher/create-text.py b/test/twisted/dispatcher/create-text.py
index 855dfd5..d108d2e 100644
--- a/test/twisted/dispatcher/create-text.py
+++ b/test/twisted/dispatcher/create-text.py
@@ -8,7 +8,8 @@ import dbus.service
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
         call_async
 from mctest import exec_test, SimulatedConnection, SimulatedClient, \
-        create_fakecm_account, enable_fakecm_account, SimulatedChannel
+        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
+        expect_client_setup
 import constants as cs
 
 def test(q, bus, mc):
@@ -34,24 +35,7 @@ def test(q, bus, mc):
             interface=cs.APPROVER, method='AddDispatchOperation')
 
     # wait for MC to download the properties
-    q.expect_many(
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=client.object_path),
-            )
+    expect_client_setup(q, [client])
 
     test_channel_creation(q, bus, account, client, conn, False)
     test_channel_creation(q, bus, account, client, conn, True)
diff --git a/test/twisted/dispatcher/dispatch-text.py b/test/twisted/dispatcher/dispatch-text.py
index fc580e9..1313a5f 100644
--- a/test/twisted/dispatcher/dispatch-text.py
+++ b/test/twisted/dispatcher/dispatch-text.py
@@ -7,7 +7,8 @@ import dbus.service
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
         call_async
 from mctest import exec_test, SimulatedConnection, SimulatedClient, \
-        create_fakecm_account, enable_fakecm_account, SimulatedChannel
+        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
+        expect_client_setup
 import constants as cs
 
 def test(q, bus, mc):
@@ -30,41 +31,7 @@ def test(q, bus, mc):
             handle=[text_fixed_properties], bypass_approval=False)
 
     # wait for MC to download the properties
-    q.expect_many(
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=empathy.object_path),
-
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=kopete.object_path),
-            )
+    expect_client_setup(q, [empathy, kopete])
 
     # subscribe to the OperationList interface (MC assumes that until this
     # property has been retrieved once, nobody cares)
diff --git a/test/twisted/dispatcher/exploding-bundles.py b/test/twisted/dispatcher/exploding-bundles.py
index e6ea956..2e0f44b 100644
--- a/test/twisted/dispatcher/exploding-bundles.py
+++ b/test/twisted/dispatcher/exploding-bundles.py
@@ -7,7 +7,8 @@ import dbus.service
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
         call_async
 from mctest import exec_test, SimulatedConnection, SimulatedClient, \
-        create_fakecm_account, enable_fakecm_account, SimulatedChannel
+        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
+        expect_client_setup
 import constants as cs
 
 def test(q, bus, mc):
@@ -44,41 +45,7 @@ def test(q, bus, mc):
             handle=[text_fixed_properties], bypass_approval=False)
 
     # wait for MC to download the properties
-    q.expect_many(
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=empathy.object_path),
-
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=kopete.object_path),
-            )
+    expect_client_setup(q, [empathy, kopete])
 
     # subscribe to the OperationList interface (MC assumes that until this
     # property has been retrieved once, nobody cares)
diff --git a/test/twisted/dispatcher/fdo-21034.py b/test/twisted/dispatcher/fdo-21034.py
index 25fe7ee..00e2a96 100644
--- a/test/twisted/dispatcher/fdo-21034.py
+++ b/test/twisted/dispatcher/fdo-21034.py
@@ -7,7 +7,8 @@ import dbus.service
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
         call_async
 from mctest import exec_test, SimulatedConnection, SimulatedClient, \
-        create_fakecm_account, enable_fakecm_account, SimulatedChannel
+        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
+        expect_client_setup
 import constants as cs
 
 def test(q, bus, mc):
@@ -26,24 +27,7 @@ def test(q, bus, mc):
             handle=[text_fixed_properties], bypass_approval=False)
 
     # wait for MC to download the properties
-    q.expect_many(
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=client.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=client.object_path),
-            )
+    expect_client_setup(q, [client])
 
     cd = bus.get_object(cs.CD, cs.CD_PATH)
     cd_props = dbus.Interface(cd, cs.PROPERTIES_IFACE)
diff --git a/test/twisted/dispatcher/lose-text.py b/test/twisted/dispatcher/lose-text.py
index 1097311..fbe7162 100644
--- a/test/twisted/dispatcher/lose-text.py
+++ b/test/twisted/dispatcher/lose-text.py
@@ -8,7 +8,8 @@ import dbus.service
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix, \
         call_async
 from mctest import exec_test, SimulatedConnection, SimulatedClient, \
-        create_fakecm_account, enable_fakecm_account, SimulatedChannel
+        create_fakecm_account, enable_fakecm_account, SimulatedChannel, \
+        expect_client_setup
 import constants as cs
 
 def test(q, bus, mc):
@@ -31,41 +32,7 @@ def test(q, bus, mc):
             handle=[text_fixed_properties], bypass_approval=False)
 
     # wait for MC to download the properties
-    q.expect_many(
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=empathy.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=empathy.object_path),
-
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.CLIENT, 'Interfaces'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.APPROVER, 'ApproverChannelFilter'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.HANDLER, 'HandlerChannelFilter'],
-                path=kopete.object_path),
-            EventPattern('dbus-method-call',
-                interface=cs.PROPERTIES_IFACE, method='Get',
-                args=[cs.OBSERVER, 'ObserverChannelFilter'],
-                path=kopete.object_path),
-            )
+    expect_client_setup(q, [empathy, kopete])
 
     # subscribe to the OperationList interface (MC assumes that until this
     # property has been retrieved once, nobody cares)
diff --git a/test/twisted/mctest.py b/test/twisted/mctest.py
index 471a876..d7e2b5f 100644
--- a/test/twisted/mctest.py
+++ b/test/twisted/mctest.py
@@ -514,3 +514,62 @@ def enable_fakecm_account(q, bus, mc, account, expected_params):
             )
 
     return conn
+
+def expect_client_setup(q, clients):
+    patterns = []
+
+    def is_client_setup(e):
+        if e.method == 'Get' and e.args == [cs.CLIENT, 'Interfaces']:
+            return True
+        if e.method == 'GetAll' and e.args == [cs.CLIENT]:
+            return True
+        return False
+
+    def is_approver_setup(e):
+        if e.method == 'Get' and \
+                e.args == [cs.APPROVER, 'ApproverChannelFilter']:
+            return True
+        if e.method == 'GetAll' and e.args == [cs.APPROVER]:
+            return True
+        return False
+
+    def is_observer_setup(e):
+        if e.method == 'Get' and \
+                e.args == [cs.OBSERVER, 'ObserverChannelFilter']:
+            return True
+        if e.method == 'GetAll' and e.args == [cs.OBSERVER]:
+            return True
+        return False
+
+    def is_handler_setup(e):
+        if e.method == 'Get' and \
+                e.args == [cs.HANDLER, 'HandlerChannelFilter']:
+            return True
+        if e.method == 'GetAll' and e.args == [cs.HANDLER]:
+            return True
+        return False
+
+    for client in clients:
+        patterns.append(servicetest.EventPattern('dbus-method-call',
+            interface=cs.PROPERTIES_IFACE,
+            path=client.object_path, handled=True,
+            predicate=is_client_setup))
+
+        if client.observe:
+            patterns.append(servicetest.EventPattern('dbus-method-call',
+                interface=cs.PROPERTIES_IFACE,
+                path=client.object_path, handled=True,
+                predicate=is_observer_setup))
+
+        if client.approve:
+            patterns.append(servicetest.EventPattern('dbus-method-call',
+                interface=cs.PROPERTIES_IFACE,
+                path=client.object_path, handled=True,
+                predicate=is_approver_setup))
+
+        if client.handle:
+            patterns.append(servicetest.EventPattern('dbus-method-call',
+                interface=cs.PROPERTIES_IFACE,
+                path=client.object_path, predicate=is_handler_setup))
+
+    q.expect_many(*patterns)
diff --git a/test/twisted/test-connect.py b/test/twisted/test-connect.py
index 7fddf88..21e6b16 100644
--- a/test/twisted/test-connect.py
+++ b/test/twisted/test-connect.py
@@ -3,7 +3,7 @@ import dbus.service
 
 from servicetest import EventPattern, tp_name_prefix, tp_path_prefix
 from mctest import exec_test, SimulatedConnection, create_fakecm_account,\
-        SimulatedChannel
+        SimulatedChannel, SimulatedClient, expect_client_setup
 import constants as cs
 
 def test(q, bus, mc):
@@ -19,22 +19,10 @@ def test(q, bus, mc):
     caps = dbus.Array([http_fixed_properties], signature='a{sv}')
 
     # Be a Client
-    client_name_ref = dbus.service.BusName(
-            tp_name_prefix + '.Client.downloader', bus=bus)
-
-    e = q.expect('dbus-method-call',
-            interface=cs.PROPERTIES_IFACE, method='Get',
-            args=[cs.CLIENT, 'Interfaces'],
-            handled=False)
-    q.dbus_return(e.message, dbus.Array([cs.HANDLER], signature='s',
-        variant_level=1), signature='v')
-
-    e = q.expect('dbus-method-call',
-            interface=cs.PROPERTIES_IFACE, method='Get',
-            args=[cs.HANDLER, 'HandlerChannelFilter'],
-            handled=False)
-    q.dbus_return(e.message, dbus.Array([http_fixed_properties],
-        signature='a{sv}', variant_level=1), signature='v')
+    client = SimulatedClient(q, bus, 'downloader',
+            observe=[], approve=[], handle=[http_fixed_properties],
+            bypass_approval=False)
+    expect_client_setup(q, [client])
 
     # Create an account
     params = dbus.Dictionary({"account": "someguy at example.com",
-- 
1.5.6.5




More information about the telepathy-commits mailing list