[telepathy-gabble/master] Use action_predicate more widely.
Will Thompson
will.thompson at collabora.co.uk
Tue Jun 2 03:13:29 PDT 2009
In some cases, this just makes the test easier to read; in a couple of
cases, it replaces "expect an iq; assert it's this jingle action" with
"expect this jingle action", which is more correct.
---
tests/twisted/jingle/call-state.py | 6 ++----
tests/twisted/jingle/hold-av.py | 3 +--
tests/twisted/jingle/incoming-basics.py | 4 ++--
tests/twisted/jingle/initial-audio-video.py | 4 ++--
tests/twisted/jingle/outgoing-basics.py | 5 ++---
tests/twisted/jingle/outgoing-not-answered.py | 7 +++----
.../twisted/jingle/test-content-adding-removal.py | 16 ++++++----------
tests/twisted/jingle/test-description-info.py | 11 +++++------
tests/twisted/jingle/test-incoming-call-reject.py | 4 ++--
.../twisted/jingle/test-outgoing-call-rejected.py | 3 +--
10 files changed, 26 insertions(+), 37 deletions(-)
diff --git a/tests/twisted/jingle/call-state.py b/tests/twisted/jingle/call-state.py
index d165236..f40ada4 100644
--- a/tests/twisted/jingle/call-state.py
+++ b/tests/twisted/jingle/call-state.py
@@ -53,8 +53,7 @@ def test(jp, q, bus, conn, stream):
stream_handler.Ready(jt.get_audio_codecs_dbus())
stream_handler.StreamState(cs.MEDIA_STREAM_STATE_CONNECTED)
- e = q.expect('stream-iq', predicate=lambda e:
- jp.match_jingle_action(e.query, 'session-initiate'))
+ e = q.expect('stream-iq', predicate=jp.action_predicate('session-initiate'))
stream.send(make_result_iq(stream, e.stanza))
jt.set_sid_from_initiate(e.query)
@@ -220,8 +219,7 @@ def test(jp, q, bus, conn, stream):
stream_handler2.Ready(jt.get_video_codecs_dbus())
stream_handler2.StreamState(cs.MEDIA_STREAM_STATE_CONNECTED)
- e = q.expect('stream-iq', predicate=lambda e:
- jp.match_jingle_action(e.query, 'content-add'))
+ e = q.expect('stream-iq', predicate=jp.action_predicate('content-add'))
stream.send(make_result_iq(stream, e.stanza))
jt.content_accept(e.query, 'video')
diff --git a/tests/twisted/jingle/hold-av.py b/tests/twisted/jingle/hold-av.py
index 1556b4b..4c9e694 100644
--- a/tests/twisted/jingle/hold-av.py
+++ b/tests/twisted/jingle/hold-av.py
@@ -71,8 +71,7 @@ def test(jp, q, bus, conn, stream):
video_stream_handler.Ready(jt.get_video_codecs_dbus())
video_stream_handler.StreamState(cs.MEDIA_STREAM_STATE_CONNECTED)
- e = q.expect('stream-iq', predicate=lambda e:
- jp.match_jingle_action(e.query, 'session-initiate'))
+ e = q.expect('stream-iq', predicate=jp.action_predicate('session-initiate'))
stream.send(make_result_iq(stream, e.stanza))
jt.set_sid_from_initiate(e.query)
diff --git a/tests/twisted/jingle/incoming-basics.py b/tests/twisted/jingle/incoming-basics.py
index a6081b3..cbffbc0 100644
--- a/tests/twisted/jingle/incoming-basics.py
+++ b/tests/twisted/jingle/incoming-basics.py
@@ -150,8 +150,8 @@ def test(jp, q, bus, conn, stream):
EventPattern('dbus-signal', signal='MembersChanged',
args=[u'', [self_handle], [], [], [], self_handle,
cs.GC_REASON_NONE]),
- EventPattern('stream-iq', iq_type='set', predicate=lambda e:
- jp.match_jingle_action(e.query, 'session-accept')),
+ EventPattern('stream-iq',
+ predicate=jp.action_predicate('session-accept')),
EventPattern('dbus-signal', signal='SetStreamSending', args=[True]),
EventPattern('dbus-signal', signal='SetStreamPlaying', args=[True]),
EventPattern('dbus-signal', signal='StreamDirectionChanged',
diff --git a/tests/twisted/jingle/initial-audio-video.py b/tests/twisted/jingle/initial-audio-video.py
index ed038c9..cf971fb 100644
--- a/tests/twisted/jingle/initial-audio-video.py
+++ b/tests/twisted/jingle/initial-audio-video.py
@@ -123,8 +123,8 @@ def check_iav(jt, q, conn, bus, stream, remote_handle, initial_audio,
sh.Ready(jt.get_audio_codecs_dbus())
sh.StreamState(cs.MEDIA_STREAM_STATE_CONNECTED)
- e = q.expect('stream-iq', predicate=lambda e:
- jt.jp.match_jingle_action(e.query, 'session-initiate'))
+ e = q.expect('stream-iq',
+ predicate=jt.jp.action_predicate('session-initiate'))
# TODO: check that the s-i contains the right contents.
chan.Close()
diff --git a/tests/twisted/jingle/outgoing-basics.py b/tests/twisted/jingle/outgoing-basics.py
index 681c6c5..4217fff 100644
--- a/tests/twisted/jingle/outgoing-basics.py
+++ b/tests/twisted/jingle/outgoing-basics.py
@@ -197,9 +197,8 @@ def worker(jp, q, bus, conn, stream, variant):
cs.GC_REASON_INVITED]),
)
else:
- session_initiate = q.expect('stream-iq', iq_type='set',
- predicate=lambda e:
- jp.match_jingle_action(e.query, 'session-initiate'))
+ session_initiate = q.expect('stream-iq',
+ predicate=jp.action_predicate('session-initiate'))
jt2.set_sid_from_initiate(session_initiate.query)
stream.send(jp.xml(jp.ResultIq('test at localhost', session_initiate.stanza,
diff --git a/tests/twisted/jingle/outgoing-not-answered.py b/tests/twisted/jingle/outgoing-not-answered.py
index 568c2d7..8503332 100644
--- a/tests/twisted/jingle/outgoing-not-answered.py
+++ b/tests/twisted/jingle/outgoing-not-answered.py
@@ -35,8 +35,7 @@ def test(jp, q, bus, conn, stream):
stream_handler.Ready(jt.get_audio_codecs_dbus())
stream_handler.StreamState(cs.MEDIA_STREAM_STATE_CONNECTED)
- q.expect('stream-iq', predicate=lambda e:
- jp.match_jingle_action(e.query, 'session-initiate'))
+ q.expect('stream-iq', predicate=jp.action_predicate('session-initiate'))
# Ensure we've got all the MembersChanged signals at the start of the call
# out of the way.
@@ -45,8 +44,8 @@ def test(jp, q, bus, conn, stream):
# daf doesn't answer; we expect the call to end.
mc, t = q.expect_many(
EventPattern('dbus-signal', signal='MembersChanged'),
- EventPattern('stream-iq', predicate=lambda e:
- jp.match_jingle_action(e.query, 'session-terminate')),
+ EventPattern('stream-iq',
+ predicate=jp.action_predicate('session-terminate')),
)
_, added, removed, lp, rp, actor, reason = mc.args
diff --git a/tests/twisted/jingle/test-content-adding-removal.py b/tests/twisted/jingle/test-content-adding-removal.py
index 81a1b5b..9925a7d 100644
--- a/tests/twisted/jingle/test-content-adding-removal.py
+++ b/tests/twisted/jingle/test-content-adding-removal.py
@@ -65,15 +65,13 @@ def test(jp, q, bus, conn, stream, peer_removes_final_content):
# We changed our mind locally, don't want video
chan.StreamedMedia.RemoveStreams([stream_id2])
- e = q.expect('stream-iq', iq_type='set', predicate=lambda x:
- jp.match_jingle_action(x.query, 'session-initiate'))
+ e = q.expect('stream-iq', predicate=jp.action_predicate('session-initiate'))
stream.send(make_result_iq(stream, e.stanza))
jt.set_sid_from_initiate(e.query)
# Gabble sends content-remove for the video stream...
- e2 = q.expect('stream-iq', iq_type='set', predicate=lambda x:
- jp.match_jingle_action(x.query, 'content-remove'))
+ e2 = q.expect('stream-iq', predicate=jp.action_predicate('content-remove'))
# ...but before the peer notices, they accept the call.
jt.accept(with_video=True)
@@ -98,8 +96,7 @@ def test(jp, q, bus, conn, stream, peer_removes_final_content):
stream_handler2.Ready(jt.get_audio_codecs_dbus())
stream_handler2.StreamState(cs.MEDIA_STREAM_STATE_CONNECTED)
- e = q.expect('stream-iq', iq_type='set', predicate=lambda x:
- jp.match_jingle_action(x.query, 'content-add'))
+ e = q.expect('stream-iq', predicate=jp.action_predicate('content-add'))
c = e.query.firstChildElement()
assertEquals('initiator', c['creator'])
stream.send(make_result_iq(stream, e.stanza))
@@ -117,8 +114,7 @@ def test(jp, q, bus, conn, stream, peer_removes_final_content):
# We first remove the original stream
chan.StreamedMedia.RemoveStreams([stream_id])
- e = q.expect('stream-iq', iq_type='set', predicate=lambda x:
- jp.match_jingle_action(x.query, 'content-remove'))
+ e = q.expect('stream-iq', predicate=jp.action_predicate('content-remove'))
content_remove_ack = make_result_iq(stream, e.stanza)
if peer_removes_final_content:
@@ -140,8 +136,8 @@ def test(jp, q, bus, conn, stream, peer_removes_final_content):
chan.StreamedMedia.RemoveStreams([stream2_id])
st, closed = q.expect_many(
- EventPattern('stream-iq', iq_type='set', predicate=lambda x:
- jp.match_jingle_action(x.query, 'session-terminate')),
+ EventPattern('stream-iq',
+ predicate=jp.action_predicate('session-terminate')),
# Gabble shouldn't wait for the peer to ack the terminate before
# considering the call finished.
EventPattern('dbus-signal', signal='Closed',
diff --git a/tests/twisted/jingle/test-description-info.py b/tests/twisted/jingle/test-description-info.py
index 82a817d..3a0703f 100644
--- a/tests/twisted/jingle/test-description-info.py
+++ b/tests/twisted/jingle/test-description-info.py
@@ -4,7 +4,7 @@ Test emition and handling of codec update using description-info
from gabbletest import exec_test, sync_stream
from servicetest import (
- wrap_channel,
+ wrap_channel, assertEquals,
make_channel_proxy, unwrap, tp_path_prefix, EventPattern, call_async)
from jingletest2 import JingleTest2, JingleProtocol031
import constants as cs
@@ -107,11 +107,11 @@ def test(q, bus, conn, stream, send_early_description_info=False):
# First IQ is transport-info; also, we expect to be told what codecs the
# other end wants.
e, src = q.expect_many(
- EventPattern('stream-iq', iq_type='set'),
+ EventPattern('stream-iq',
+ predicate=jp.action_predicate('transport-info')),
EventPattern('dbus-signal', signal='SetRemoteCodecs')
)
- assert jp.match_jingle_action(e.query, 'transport-info')
- assert e.query['initiator'] == 'foo at bar.com/Foo'
+ assertEquals('foo at bar.com/Foo', e.query['initiator'])
assert jt2.audio_codecs == [ (name, id, rate)
for id, name, type, rate, channels, parameters in unwrap(src.args[0]) ], \
@@ -123,8 +123,7 @@ def test(q, bus, conn, stream, send_early_description_info=False):
stream_handler.SupportedCodecs(local_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'))
# farstream is buggy, and tells tp-fs to tell Gabble to change the third
# codec's clockrate. This isn't legal, so Gabble says no.
diff --git a/tests/twisted/jingle/test-incoming-call-reject.py b/tests/twisted/jingle/test-incoming-call-reject.py
index 58b146a..77879f4 100644
--- a/tests/twisted/jingle/test-incoming-call-reject.py
+++ b/tests/twisted/jingle/test-incoming-call-reject.py
@@ -75,8 +75,8 @@ def test(jp, q, bus, conn, stream, busy):
media_chan.RemoveMembers([self_handle], 'rejected')
iq, mc, _ = q.expect_many(
- EventPattern('stream-iq', predicate=lambda e:
- jp.match_jingle_action(e.query, 'session-terminate')),
+ EventPattern('stream-iq',
+ predicate=jp.action_predicate('session-terminate')),
EventPattern('dbus-signal', signal='MembersChanged'),
EventPattern('dbus-signal', signal='Closed'),
)
diff --git a/tests/twisted/jingle/test-outgoing-call-rejected.py b/tests/twisted/jingle/test-outgoing-call-rejected.py
index ee27ed4..2185de1 100644
--- a/tests/twisted/jingle/test-outgoing-call-rejected.py
+++ b/tests/twisted/jingle/test-outgoing-call-rejected.py
@@ -41,8 +41,7 @@ def test(jp, q, bus, conn, stream):
stream_handler.Ready(jt.get_audio_codecs_dbus())
stream_handler.StreamState(cs.MEDIA_STREAM_STATE_CONNECTED)
- e = q.expect('stream-iq', predicate=lambda e:
- jp.match_jingle_action(e.query, 'session-initiate'))
+ e = q.expect('stream-iq', predicate=jp.action_predicate('session-initiate'))
stream.send(make_result_iq(stream, e.stanza))
jt.set_sid_from_initiate(e.query)
--
1.5.6.5
More information about the telepathy-commits
mailing list