[Telepathy-commits] [telepathy-gabble/master] Add a simple test for requesting a channel using the requestotron API

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Aug 20 09:38:34 PDT 2008


20080729210627-53eee-ac909c1c314c5917ec2716e922eeda845ca71f96.gz
---
 tests/twisted/Makefile.am                   |    1 +
 tests/twisted/text/initiate-requestotron.py |   74 +++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 0 deletions(-)
 create mode 100644 tests/twisted/text/initiate-requestotron.py

diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index ada6aa8..8e63eeb 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -16,6 +16,7 @@ TWISTED_TESTS = \
 	roster/test-roster.py \
 	roster/test-roster-subscribe.py \
 	text/initiate.py \
+	text/initiate-requestotron.py \
 	text/respawn.py \
 	text/test-text-delayed.py \
 	text/test-text-no-body.py \
diff --git a/tests/twisted/text/initiate-requestotron.py b/tests/twisted/text/initiate-requestotron.py
new file mode 100644
index 0000000..fa6ad13
--- /dev/null
+++ b/tests/twisted/text/initiate-requestotron.py
@@ -0,0 +1,74 @@
+"""
+Test text channel initiated by me, using Requests.
+"""
+
+import dbus
+
+from twisted.words.xish import domish
+
+from gabbletest import exec_test
+from servicetest import call_async, EventPattern
+
+def test(q, bus, conn, stream):
+    conn.Connect()
+    q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+
+    self_handle = conn.GetSelfHandle()
+
+    jid = 'foo at bar.com'
+    call_async(q, conn, 'RequestHandles', 1, [jid])
+
+    event = q.expect('dbus-return', method='RequestHandles')
+    foo_handle = event.value[0][0]
+
+    requestotron = dbus.Interface(conn,
+            'org.freedesktop.Telepathy.Connection.Interface.Requests.DRAFT')
+    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,
+              })
+
+    ret, old_sig, new_sig = q.expect_many(
+        EventPattern('dbus-return', method='CreateChannel'),
+        EventPattern('dbus-signal', signal='NewChannel'),
+        EventPattern('dbus-signal', signal='NewChannels'),
+        )
+
+    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['org.freedesktop.Telepathy.Channel.FUTURE.'
+            'Requested'] == True
+    assert emitted_props['org.freedesktop.Telepathy.Channel.FUTURE.'
+            'TargetID'] == jid
+    assert emitted_props['org.freedesktop.Telepathy.Channel.FUTURE.'
+            'InitiatorHandle'] == self_handle
+    assert emitted_props['org.freedesktop.Telepathy.Channel.FUTURE.'
+            'InitiatorID'] == 'test at localhost'
+
+    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[3] == foo_handle
+    assert old_sig.args[4] == True      # suppress handler
+
+    assert len(new_sig.args) == 1
+    assert len(new_sig.args[0]) == 1        # one channel
+    assert len(new_sig.args[0][0]) == 2     # two struct members
+    assert new_sig.args[0][0][0] == ret.value[0]
+    assert new_sig.args[0][0][1] == ret.value[1]
+
+    conn.Disconnect()
+    q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+
+if __name__ == '__main__':
+    exec_test(test)
+
-- 
1.5.6.3




More information about the Telepathy-commits mailing list