[telepathy-gabble/master] Move LocalCandidatesAdded and session-initiate into an expect_many.

Mike Ruprecht mike.ruprecht at collabora.co.uk
Tue Dec 29 05:35:29 PST 2009


Because one is a dbus-signal and the other is an xmpp stream-iq, the order
wasn't guaranteed. The two signals were sometimes, although rarely, out of
order, which caused the test to incorrectly fail.
---
 tests/twisted/jingle/call-basics.py |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/tests/twisted/jingle/call-basics.py b/tests/twisted/jingle/call-basics.py
index 4df806e..a500334 100644
--- a/tests/twisted/jingle/call-basics.py
+++ b/tests/twisted/jingle/call-basics.py
@@ -204,8 +204,17 @@ def run_test(jp, q, bus, conn, stream, incoming):
     cstream.AddCandidates (candidates,
         dbus_interface=cs.CALL_STREAM_IFACE_MEDIA)
 
-    signal = q.expect ('dbus-signal', signal='LocalCandidatesAdded')
-    assertEquals (candidates, signal.args[0])
+    expected = [ EventPattern('dbus-signal', signal='LocalCandidatesAdded') ]
+
+    if not incoming:
+        expected.append (EventPattern('stream-iq',
+            predicate=jp.action_predicate('session-initiate')))
+
+    ret = q.expect_many (*expected)
+    assertEquals (candidates, ret[0].args[0])
+
+    if not incoming:
+        jt2.parse_session_initiate(ret[1].query)
 
     cstream.CandidatesPrepared (dbus_interface=cs.CALL_STREAM_IFACE_MEDIA)
 
@@ -256,11 +265,6 @@ def run_test(jp, q, bus, conn, stream, incoming):
         chan.Accept (dbus_interface=cs.CHANNEL_TYPE_CALL)
         q.expect('stream-iq', predicate=jp.action_predicate('session-accept'))
     else:
-        session_initiate = q.expect('stream-iq',
-            predicate=jp.action_predicate('session-initiate'))
-
-        jt2.parse_session_initiate(session_initiate.query)
-
         if jp.is_modern_jingle():
             # The other person's client starts ringing, and tells us so!
             node = jp.SetIq(jt2.peer, jt2.jid, [
-- 
1.5.6.5




More information about the telepathy-commits mailing list