[telepathy-gabble/master] Fix some races in Jingle tests
Will Thompson
will.thompson at collabora.co.uk
Wed May 27 08:07:45 PDT 2009
These were occasionally catching IQ acks and things rather than the
events they intended to catch.
---
tests/twisted/jingle/accept-extra-stream.py | 26 ++++++++++++--------------
tests/twisted/jingle/incoming-basics.py | 9 +++++----
tests/twisted/jingle/test-content-complex.py | 10 ++++------
3 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/tests/twisted/jingle/accept-extra-stream.py b/tests/twisted/jingle/accept-extra-stream.py
index 3d75ede..e459c55 100644
--- a/tests/twisted/jingle/accept-extra-stream.py
+++ b/tests/twisted/jingle/accept-extra-stream.py
@@ -2,7 +2,10 @@
Test that we can accept streams added after the call has been accepted.
"""
-from servicetest import make_channel_proxy, EventPattern, sync_dbus, call_async
+from servicetest import (
+ make_channel_proxy, EventPattern, sync_dbus, call_async,
+ assertEquals,
+ )
from gabbletest import exec_test, make_result_iq, sync_stream
import constants as cs
@@ -70,10 +73,8 @@ def test(q, bus, conn, stream):
stream_handler.SupportedCodecs(jt2.get_audio_codecs_dbus())
# peer gets the transport
- e = q.expect('stream-iq')
- assert e.query.name == 'jingle'
- assert e.query['action'] == 'transport-info'
- assert e.query['initiator'] == remote_jid
+ e = q.expect('stream-iq', predicate=jp.action_predicate('transport-info'))
+ assertEquals(remote_jid, e.query['initiator'])
stream.send(make_result_iq(stream, e.stanza))
@@ -137,21 +138,18 @@ def test(q, bus, conn, stream):
video_handler.StreamState(cs.MEDIA_STREAM_STATE_CONNECTED)
video_handler.SupportedCodecs(jt2.get_video_codecs_dbus())
- e, _, _, _ = q.expect_many(
+ ti, _, _, _ = q.expect_many(
# Peer gets the transport
- EventPattern('stream-iq', iq_type='set',
- predicate=lambda e: e.query['action'] =='transport-info'),
+ EventPattern('stream-iq',
+ predicate=jp.action_predicate('transport-info')),
# Gabble tells the peer we accepted
- EventPattern('stream-iq', predicate=lambda e:
- (e.query.name == 'jingle' and
- e.query['action'] == 'content-accept')),
+ EventPattern('stream-iq',
+ predicate=jp.action_predicate('content-accept')),
EventPattern('dbus-signal', signal='SetStreamPlaying', args=[True]),
# It's not entirely clear that this *needs* to fire here...
EventPattern('dbus-signal', signal='SetStreamSending', args=[False]),
)
-
- assert e.query.name == 'jingle'
- assert e.query['initiator'] == remote_jid
+ assertEquals(remote_jid, ti.query['initiator'])
stream.send(make_result_iq(stream, e.stanza))
diff --git a/tests/twisted/jingle/incoming-basics.py b/tests/twisted/jingle/incoming-basics.py
index fe90512..34be73c 100644
--- a/tests/twisted/jingle/incoming-basics.py
+++ b/tests/twisted/jingle/incoming-basics.py
@@ -6,7 +6,9 @@ import dbus
from gabbletest import make_result_iq
from servicetest import (
- make_channel_proxy, unwrap, tp_path_prefix, EventPattern)
+ make_channel_proxy, unwrap, tp_path_prefix, EventPattern,
+ assertEquals,
+ )
from jingletest2 import JingleTest2, test_all_dialects
import constants as cs
@@ -122,9 +124,8 @@ def test(jp, q, bus, conn, stream):
stream_handler.SupportedCodecs(jt.get_audio_codecs_dbus())
# peer gets the transport
- e = q.expect('stream-iq')
- assert jp.match_jingle_action(e.query, 'transport-info')
- assert e.query['initiator'] == 'foo at bar.com/Foo'
+ e = q.expect('stream-iq', predicate=jp.action_predicate('transport-info'))
+ assertEquals('foo at bar.com/Foo', e.query['initiator'])
stream.send(make_result_iq(stream, e.stanza))
diff --git a/tests/twisted/jingle/test-content-complex.py b/tests/twisted/jingle/test-content-complex.py
index e1e8053..9940932 100644
--- a/tests/twisted/jingle/test-content-complex.py
+++ b/tests/twisted/jingle/test-content-complex.py
@@ -3,7 +3,7 @@ Test everything related to contents
"""
from gabbletest import sync_stream
-from servicetest import make_channel_proxy, tp_path_prefix
+from servicetest import make_channel_proxy, tp_path_prefix, assertEquals
import constants as cs
from jingletest2 import (
JingleTest2, JingleProtocol015, JingleProtocol031, test_dialects)
@@ -79,9 +79,8 @@ def worker(jp, q, bus, conn, stream):
stream_handler.StreamState(cs.MEDIA_STREAM_STATE_CONNECTED)
# First one is transport-info
- e = q.expect('stream-iq')
- assert jp.match_jingle_action(e.query, 'transport-info')
- assert e.query['initiator'] == 'foo at bar.com/Foo'
+ e = q.expect('stream-iq', predicate=jp.action_predicate('transport-info'))
+ assertEquals('foo at bar.com/Foo', e.query['initiator'])
# stream.send(gabbletest.make_result_iq(stream, e.stanza))
stream.send(jp.xml(jp.ResultIq('test at localhost', e.stanza, [])))
@@ -90,8 +89,7 @@ def worker(jp, q, bus, conn, stream):
stream_handler.SupportedCodecs(jt2.get_audio_codecs_dbus())
# Second one is session-accept
- e = q.expect('stream-iq')
- assert jp.match_jingle_action(e.query, 'session-accept')
+ e = q.expect('stream-iq', predicate=jp.action_predicate('session-accept'))
# stream.send(gabbletest.make_result_iq(stream, e.stanza))
stream.send(jp.xml(jp.ResultIq('test at localhost', e.stanza, [])))
--
1.5.6.5
More information about the telepathy-commits
mailing list