[telepathy-idle/master] Use constants.py in requests-create.py

Will Thompson will.thompson at collabora.co.uk
Fri Aug 28 18:27:12 PDT 2009


---
 tests/twisted/channels/requests-create.py |   58 +++++++++++++----------------
 1 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/tests/twisted/channels/requests-create.py b/tests/twisted/channels/requests-create.py
index 2dd97d8..2372756 100644
--- a/tests/twisted/channels/requests-create.py
+++ b/tests/twisted/channels/requests-create.py
@@ -7,38 +7,33 @@ Most of this test was borrowed from a gabble test and modified to fit idle
 from idletest import exec_test
 from servicetest import EventPattern, call_async, tp_name_prefix
 import dbus
+import constants as cs
 
 def test(q, bus, conn, stream):
     conn.Connect()
     q.expect('dbus-signal', signal='StatusChanged', args=[0,1])
 
     nick = 'foo'
-    call_async(q, conn, 'RequestHandles', 1, [nick])
+    call_async(q, conn, 'RequestHandles', cs.HT_CONTACT, [nick])
     event = q.expect('dbus-return', method='RequestHandles')
     foo_handle = event.value[0][0]
 
-    properties = conn.GetAll(
-            'org.freedesktop.Telepathy.Connection.Interface.Requests',
-            dbus_interface='org.freedesktop.DBus.Properties')
+    properties = conn.GetAll(cs.CONN_IFACE_REQUESTS,
+            dbus_interface=cs.PROPERTIES_IFACE)
     assert properties.get('Channels') == [], properties['Channels']
-    assert ({'org.freedesktop.Telepathy.Channel.ChannelType':
-                'org.freedesktop.Telepathy.Channel.Type.Text',
-             'org.freedesktop.Telepathy.Channel.TargetHandleType': 1,
-             },
-             ['org.freedesktop.Telepathy.Channel.TargetHandle',
-              'org.freedesktop.Telepathy.Channel.TargetID'
-             ],
-             ) in properties.get('RequestableChannelClasses'),\
+    assert ({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT,
+             cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+            },
+            [cs.TARGET_HANDLE, cs.TARGET_ID],
+           ) in properties.get('RequestableChannelClasses'),\
                      properties['RequestableChannelClasses']
 
-    requestotron = dbus.Interface(conn,
-            'org.freedesktop.Telepathy.Connection.Interface.Requests')
-    call_async(q, requestotron, 'CreateChannel',
-            { 'org.freedesktop.Telepathy.Channel.ChannelType':
-                'org.freedesktop.Telepathy.Channel.Type.Text',
-              'org.freedesktop.Telepathy.Channel.TargetHandleType': 1,
-              'org.freedesktop.Telepathy.Channel.TargetHandle': foo_handle,
-              })
+    requestotron = dbus.Interface(conn, cs.CONN_IFACE_REQUESTS)
+    request = { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT,
+                cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+                cs.TARGET_ID: nick,
+              }
+    call_async(q, requestotron, 'CreateChannel', request)
 
     ret, old_sig, new_sig = q.expect_many(
         EventPattern('dbus-return', method='CreateChannel'),
@@ -48,17 +43,17 @@ def test(q, bus, conn, stream):
 
     assert len(ret.value) == 2
     emitted_props = ret.value[1]
-    assert emitted_props['org.freedesktop.Telepathy.Channel.ChannelType'] ==\
-            'org.freedesktop.Telepathy.Channel.Type.Text'
-    assert emitted_props['org.freedesktop.Telepathy.Channel.'
-            'TargetHandleType'] == 1
-    assert emitted_props['org.freedesktop.Telepathy.Channel.TargetHandle'] ==\
-            foo_handle
+    assert emitted_props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT
+    assert emitted_props[cs.TARGET_HANDLE_TYPE] == cs.HT_CONTACT
+    assert emitted_props[cs.TARGET_HANDLE] == foo_handle
+    assert emitted_props[cs.TARGET_ID] == nick
+    assert emitted_props[cs.REQUESTED]
+    assert emitted_props[cs.INITIATOR_HANDLE] == conn.GetSelfHandle()
+    assert emitted_props[cs.INITIATOR_ID] == stream.nick
 
     assert old_sig.args[0] == ret.value[0]
-    assert old_sig.args[1] == u'org.freedesktop.Telepathy.Channel.Type.Text'
-    # check that handle type == contact handle
-    assert old_sig.args[2] == 1
+    assert old_sig.args[1] == cs.CHANNEL_TYPE_TEXT
+    assert old_sig.args[2] == cs.HT_CONTACT
     assert old_sig.args[3] == foo_handle
     assert old_sig.args[4] == True      # suppress handler
 
@@ -68,9 +63,8 @@ def test(q, bus, conn, stream):
     assert new_sig.args[0][0][0] == ret.value[0]
     assert new_sig.args[0][0][1] == ret.value[1]
 
-    properties = conn.GetAll(
-            'org.freedesktop.Telepathy.Connection.Interface.Requests',
-            dbus_interface='org.freedesktop.DBus.Properties')
+    properties = conn.GetAll(cs.CONN_IFACE_REQUESTS,
+            dbus_interface=cs.PROPERTIES_IFACE)
 
     assert new_sig.args[0][0] in properties['Channels'], \
             (new_sig.args[0][0], properties['Channels'])
-- 
1.5.6.5




More information about the telepathy-commits mailing list