[telepathy-gabble/master] accept-muc-stream-tube: break a race

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Thu Apr 30 06:29:10 PDT 2009


---
 tests/twisted/tubes/accept-muc-stream-tube.py |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/tests/twisted/tubes/accept-muc-stream-tube.py b/tests/twisted/tubes/accept-muc-stream-tube.py
index 2b61c39..84a7568 100644
--- a/tests/twisted/tubes/accept-muc-stream-tube.py
+++ b/tests/twisted/tubes/accept-muc-stream-tube.py
@@ -192,27 +192,28 @@ def test(q, bus, conn, stream, bytestream_cls,
 
     address = accept_return_event.value[0]
     t.connect_socket(q, address_type, address)
-    event = q.expect('socket-connected')
-    protocol = event.protocol
-    protocol.sendData("hello initiator")
+    socket_event, si_event = q.expect_many(
+        EventPattern('socket-connected'),
+        # expect SI request
+        EventPattern('stream-iq', to='chat at conf.localhost/bob', query_ns=ns.SI,
+            query_name='si'))
+    protocol = socket_event.protocol
 
-    # expect SI request
-    event = q.expect('stream-iq', to='chat at conf.localhost/bob', query_ns=ns.SI,
-        query_name='si')
+    protocol.sendData("hello initiator")
 
-    bytestream, profile = create_from_si_offer(stream, q, bytestream_cls, event.stanza,
+    bytestream, profile = create_from_si_offer(stream, q, bytestream_cls, si_event.stanza,
             'chat at conf.localhost/test')
 
     assert profile == ns.TUBES
 
     muc_stream_node = xpath.queryForNodes('/iq/si/muc-stream[@xmlns="%s"]' %
-        ns.TUBES, event.stanza)[0]
+        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(event.stanza, 'test at localhost/Resource')
+    result, si = bytestream.create_si_reply(si_event.stanza, 'test at localhost/Resource')
     si.addElement((ns.TUBES, 'tube'))
     stream.send(result)
 
-- 
1.5.6.5



More information about the telepathy-commits mailing list