[Telepathy-commits] [telepathy-gabble/master] Extract check_conn_properties to tubetestutils

Will Thompson will.thompson at collabora.co.uk
Tue Feb 3 03:36:54 PST 2009


---
 .../offer-accept-private-dbus-stream-tube-ibb.py   |   26 ---------------
 tests/twisted/tubes/tubetestutil.py                |   34 ++++++++++++++++++++
 2 files changed, 34 insertions(+), 26 deletions(-)

diff --git a/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-ibb.py b/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-ibb.py
index 910e635..e6beeea 100644
--- a/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-ibb.py
+++ b/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-ibb.py
@@ -55,32 +55,6 @@ def set_up_echo(name):
             raise
     reactor.listenUNIX(os.getcwd() + '/stream' + name, factory)
 
-def check_conn_properties(q, bus, conn, stream, channel_list=None):
-    properties = conn.GetAll(
-            CONN_IFACE_REQUESTS,
-            dbus_interface=PROPERTIES_IFACE)
-
-    if channel_list == None:
-        assert properties.get('Channels') == [], properties['Channels']
-    else:
-        for i in channel_list:
-            assert i in properties['Channels'], \
-                (i, properties['Channels'])
-
-    assert ({CHANNEL_TYPE: CHANNEL_TYPE_TUBES,
-             TARGET_HANDLE_TYPE: HT_CONTACT,
-             },
-             [TARGET_HANDLE, TARGET_ID
-             ]
-            ) in properties.get('RequestableChannelClasses'),\
-                     properties['RequestableChannelClasses']
-    assert ({CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE,
-             TARGET_HANDLE_TYPE: HT_CONTACT
-             },
-             [TARGET_HANDLE, TARGET_ID, TUBE_PARAMETERS, STREAM_TUBE_SERVICE]
-            ) in properties.get('RequestableChannelClasses'),\
-                     properties['RequestableChannelClasses']
-
 def check_channel_properties(q, bus, conn, stream, channel, channel_type,
         contact_handle, contact_id, state=None):
     # Exercise basic Channel Properties from spec 0.17.7
diff --git a/tests/twisted/tubes/tubetestutil.py b/tests/twisted/tubes/tubetestutil.py
index fff393c..d3365d4 100644
--- a/tests/twisted/tubes/tubetestutil.py
+++ b/tests/twisted/tubes/tubetestutil.py
@@ -2,7 +2,10 @@
 Helper functions for writing tubes tests
 """
 
+from dbus import PROPERTIES_IFACE
+
 from servicetest import unwrap
+from constants import *
 
 def check_tube_in_tubes(tube, tubes):
     """
@@ -27,3 +30,34 @@ def check_tube_in_tubes(tube, tubes):
 
     assert False, "tube %s not in %s" % (unwrap (tube), unwrap (tubes))
 
+
+def check_conn_properties(q, bus, conn, stream, channel_list=None):
+    """
+    Check that Connection.Interface.Requests.Channels matches channel_list, and
+    that RequestableChannelClasses contains the expected tube types.
+    """
+
+    properties = conn.GetAll(
+            CONN_IFACE_REQUESTS,
+            dbus_interface=PROPERTIES_IFACE)
+
+    if channel_list == None:
+        assert properties.get('Channels') == [], properties['Channels']
+    else:
+        for i in channel_list:
+            assert i in properties['Channels'], \
+                (i, properties['Channels'])
+
+    assert ({CHANNEL_TYPE: CHANNEL_TYPE_TUBES,
+             TARGET_HANDLE_TYPE: HT_CONTACT,
+             },
+             [TARGET_HANDLE, TARGET_ID
+             ]
+            ) in properties.get('RequestableChannelClasses'),\
+                     properties['RequestableChannelClasses']
+    assert ({CHANNEL_TYPE: CHANNEL_TYPE_STREAM_TUBE,
+             TARGET_HANDLE_TYPE: HT_CONTACT
+             },
+             [TARGET_HANDLE, TARGET_ID, TUBE_PARAMETERS, STREAM_TUBE_SERVICE]
+            ) in properties.get('RequestableChannelClasses'),\
+                     properties['RequestableChannelClasses']
-- 
1.5.6.5




More information about the telepathy-commits mailing list