[telepathy-gabble/master] test ConnectionClosed signal with Cancelled

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Wed May 20 10:02:26 PDT 2009


---
 tests/twisted/tubes/accept-muc-stream-tube.py |   47 +++++++++++++++++-------
 1 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/tests/twisted/tubes/accept-muc-stream-tube.py b/tests/twisted/tubes/accept-muc-stream-tube.py
index e0adf5a..68d3a6b 100644
--- a/tests/twisted/tubes/accept-muc-stream-tube.py
+++ b/tests/twisted/tubes/accept-muc-stream-tube.py
@@ -198,23 +198,27 @@ def test(q, bus, conn, stream, bytestream_cls,
     protocol = socket_event.protocol
     protocol.sendData("hello initiator")
 
-    bytestream, profile = create_from_si_offer(stream, q, bytestream_cls, si_event.stanza,
-            'chat at conf.localhost/test')
+    def accept_tube_si_connection():
+        bytestream, profile = create_from_si_offer(stream, q, bytestream_cls, si_event.stanza,
+                'chat at conf.localhost/test')
 
-    assert profile == ns.TUBES
+        assert profile == ns.TUBES
 
-    muc_stream_node = xpath.queryForNodes('/iq/si/muc-stream[@xmlns="%s"]' %
-        ns.TUBES, si_event.stanza)[0]
-    assert muc_stream_node is not None
-    assert muc_stream_node['tube'] == str(stream_tube_id)
+        muc_stream_node = xpath.queryForNodes('/iq/si/muc-stream[@xmlns="%s"]' %
+            ns.TUBES, si_event.stanza)[0]
+        assert muc_stream_node is not None
+        assert muc_stream_node['tube'] == str(stream_tube_id)
 
-    # set the real jid of the target as 'to' because the XMPP server changes
-    # it when delivering the IQ
-    result, si = bytestream.create_si_reply(si_event.stanza, 'test at localhost/Resource')
-    si.addElement((ns.TUBES, 'tube'))
-    stream.send(result)
+        # set the real jid of the target as 'to' because the XMPP server changes
+        # it when delivering the IQ
+        result, si = bytestream.create_si_reply(si_event.stanza, 'test at localhost/Resource')
+        si.addElement((ns.TUBES, 'tube'))
+        stream.send(result)
+
+        bytestream.wait_bytestream_open()
+        return bytestream
 
-    bytestream.wait_bytestream_open()
+    bytestream = accept_tube_si_connection()
 
     binary = bytestream.get_data()
     assert binary == 'hello initiator'
@@ -234,7 +238,22 @@ def test(q, bus, conn, stream, bytestream_cls,
 
     # bytestream is refused
     send_error_reply(stream, si_event.stanza)
-    e = q.expect('dbus-signal', signal='ConnectionClosed', args=[conn_id, cs.CONNECTION_REFUSED])
+    q.expect_many(
+        EventPattern('dbus-signal', signal='ConnectionClosed', args=[conn_id, cs.CONNECTION_REFUSED]),
+        EventPattern('socket-disconnected'))
+
+    # establish another tube connection
+    socket_event, si_event, conn_id = t.connect_to_cm_socket(q, 'chat at conf.localhost/bob',
+        address_type, address, access_control, access_control_param)
+
+    protocol = socket_event.protocol
+    bytestream = accept_tube_si_connection()
+
+    # disconnect local socket
+    protocol.transport.loseConnection()
+    q.expect_many(
+        EventPattern('dbus-signal', signal='ConnectionClosed', args=[conn_id, cs.CANCELLED]),
+        EventPattern('socket-disconnected'))
 
     # OK, we're done
     conn.Disconnect()
-- 
1.5.6.5




More information about the telepathy-commits mailing list