telepathy-gabble: tests: use partial in a few places for neatness
Will Thompson
wjt at kemper.freedesktop.org
Thu Dec 6 04:29:02 PST 2012
Module: telepathy-gabble
Branch: master
Commit: 98add3fb1749366229fc0c211f0fa939d3dfc267
URL: http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=98add3fb1749366229fc0c211f0fa939d3dfc267
Author: Will Thompson <will.thompson at collabora.co.uk>
Date: Thu Nov 22 16:17:51 2012 +0000
tests: use partial in a few places for neatness
---
tests/twisted/caps/advertise-contact-caps.py | 23 +++++++++++++-------
tests/twisted/jingle/outgoing-ensure.py | 7 ++---
tests/twisted/jingle/stun-server.py | 21 +++++++++--------
.../jingle/test-wait-for-caps-incomplete.py | 9 ++++---
tests/twisted/jingle/test-wait-for-caps.py | 9 ++++---
5 files changed, 39 insertions(+), 30 deletions(-)
diff --git a/tests/twisted/caps/advertise-contact-caps.py b/tests/twisted/caps/advertise-contact-caps.py
index 9200e16..ab40277 100644
--- a/tests/twisted/caps/advertise-contact-caps.py
+++ b/tests/twisted/caps/advertise-contact-caps.py
@@ -2,6 +2,7 @@
Test UpdateCapabilities.
"""
+from functools import partial
import dbus
from twisted.words.xish import xpath, domish
@@ -247,14 +248,20 @@ def run_mixed_test (q, bus, conn, stream):
check_caps(namespaces, JINGLE_CAPS)
if __name__ == '__main__':
- exec_test(lambda q, b, c, s:
- run_test (q, b, c, s,
- cs.CHANNEL_TYPE_STREAMED_MEDIA, cs.CHANNEL_IFACE_MEDIA_SIGNALLING,
- cs.INITIAL_AUDIO, cs.INITIAL_VIDEO), do_connect=False)
+ exec_test(
+ partial(run_test,
+ media_channel_type=cs.CHANNEL_TYPE_STREAMED_MEDIA,
+ media_interface=cs.CHANNEL_IFACE_MEDIA_SIGNALLING,
+ initial_audio=cs.INITIAL_AUDIO,
+ initial_video=cs.INITIAL_VIDEO),
+ do_connect=False)
- exec_test(lambda q, b, c, s:
- run_test (q, b, c, s,
- cs.CHANNEL_TYPE_CALL, cs.CHANNEL_TYPE_CALL,
- cs.CALL_INITIAL_AUDIO, cs.CALL_INITIAL_VIDEO), do_connect=False)
+ exec_test(
+ partial(run_test,
+ media_channel_type=cs.CHANNEL_TYPE_CALL,
+ media_interface=cs.CHANNEL_TYPE_CALL,
+ initial_audio=cs.CALL_INITIAL_AUDIO,
+ initial_video=cs.CALL_INITIAL_VIDEO),
+ do_connect=False)
exec_test(run_mixed_test, do_connect=False)
diff --git a/tests/twisted/jingle/outgoing-ensure.py b/tests/twisted/jingle/outgoing-ensure.py
index f2f1d55..a5bab23 100644
--- a/tests/twisted/jingle/outgoing-ensure.py
+++ b/tests/twisted/jingle/outgoing-ensure.py
@@ -6,6 +6,7 @@ This also exercises calls to a contact on a SIP gateway, who has no resource,
only a bare JID.
"""
+from functools import partial
from gabbletest import exec_test
from servicetest import (
wrap_channel,
@@ -212,7 +213,5 @@ def test(q, bus, conn, stream, channel_type):
chan.Close()
if __name__ == '__main__':
- exec_test(lambda q, bus, conn, stream:
- test(q, bus, conn, stream, cs.CHANNEL_TYPE_STREAMED_MEDIA))
- exec_test(lambda q, bus, conn, stream:
- test(q, bus, conn, stream, cs.CHANNEL_TYPE_CALL))
+ exec_test(partial(test, channel_type=cs.CHANNEL_TYPE_STREAMED_MEDIA))
+ exec_test(partial(test, channel_type=cs.CHANNEL_TYPE_CALL))
diff --git a/tests/twisted/jingle/stun-server.py b/tests/twisted/jingle/stun-server.py
index 2294c71..d4e7ca8 100644
--- a/tests/twisted/jingle/stun-server.py
+++ b/tests/twisted/jingle/stun-server.py
@@ -2,6 +2,7 @@
Test getting STUN server from Google jingleinfo
"""
+from functools import partial
import dbus
import socket
@@ -268,23 +269,23 @@ def test_call(q, bus, conn, stream,
if __name__ == '__main__':
# StreamedMedia tests
- exec_test(lambda q, b, c, s: test_streamed_media(q, b, c, s,
+ exec_test(partial(test_streamed_media,
google=False), do_connect=False)
- exec_test(lambda q, b, c, s: test_streamed_media(q, b, c, s,
+ exec_test(partial(test_streamed_media,
google=False, expected_stun_server='5.4.3.2', expected_stun_port=54321),
params={'fallback-stun-server': 'resolves-to-5.4.3.2',
'fallback-stun-port': dbus.UInt16(54321)}, do_connect=False)
if GOOGLE_RELAY_ENABLED:
- exec_test(lambda q, b, c, s: test_streamed_media(q, b, c, s,
+ exec_test(partial(test_streamed_media,
google=True, expected_stun_server='1.2.3.4', expected_stun_port=12345),
protocol=GoogleXmlStream, do_connect=False)
- exec_test(lambda q, b, c, s: test_streamed_media(q, b, c, s,
+ exec_test(partial(test_streamed_media,
google=True, expected_stun_server='5.4.3.2', expected_stun_port=54321),
protocol=GoogleXmlStream,
params={'stun-server': 'resolves-to-5.4.3.2',
'stun-port': dbus.UInt16(54321)}, do_connect=False)
- exec_test(lambda q, b, c, s: test_streamed_media(q, b, c, s,
+ exec_test(partial(test_streamed_media,
google=True, expected_stun_server='1.2.3.4', expected_stun_port=12345),
protocol=GoogleXmlStream,
params={'fallback-stun-server': 'resolves-to-5.4.3.2',
@@ -294,9 +295,9 @@ if __name__ == '__main__':
# Call tests
if CHANNEL_TYPE_CALL_ENABLED:
- exec_test(lambda q, b, c, s: test_call(q, b, c, s,
+ exec_test(partial(test_call,
google=False), do_connect=False)
- exec_test(lambda q, b, c, s: test_call(q, b, c, s,
+ exec_test(partial(test_call,
google=False, expected_stun_server='5.4.3.2',
expected_stun_port=54321),
params={'fallback-stun-server': 'resolves-to-5.4.3.2',
@@ -305,17 +306,17 @@ if __name__ == '__main__':
print "NOTE: built with --disable-channel-type-call; omitting Call tests"
if CHANNEL_TYPE_CALL_ENABLED and GOOGLE_RELAY_ENABLED:
- exec_test(lambda q, b, c, s: test_call(q, b, c, s,
+ exec_test(partial(test_call,
google=True, expected_stun_server='1.2.3.4',
expected_stun_port=12345),
protocol=GoogleXmlStream, do_connect=False)
- exec_test(lambda q, b, c, s: test_call(q, b, c, s,
+ exec_test(partial(test_call,
google=True, expected_stun_server='5.4.3.2',
expected_stun_port=54321),
protocol=GoogleXmlStream,
params={'stun-server': 'resolves-to-5.4.3.2',
'stun-port': dbus.UInt16(54321)}, do_connect=False)
- exec_test(lambda q, b, c, s: test_call(q, b, c, s,
+ exec_test(partial(test_call,
google=True, expected_stun_server='1.2.3.4',
expected_stun_port=12345),
protocol=GoogleXmlStream,
diff --git a/tests/twisted/jingle/test-wait-for-caps-incomplete.py b/tests/twisted/jingle/test-wait-for-caps-incomplete.py
index 353c334..ba9876c 100644
--- a/tests/twisted/jingle/test-wait-for-caps-incomplete.py
+++ b/tests/twisted/jingle/test-wait-for-caps-incomplete.py
@@ -4,6 +4,7 @@ and returns an error when Disconnect is called and there are
incomplete requests.
"""
+from functools import partial
from gabbletest import exec_test, disconnect_conn
from servicetest import make_channel_proxy, call_async, sync_dbus, EventPattern
import jingletest
@@ -66,10 +67,10 @@ def test(q, bus, conn, stream, channel_type):
before_events[0].error
if __name__ == '__main__':
- exec_test(lambda q, bus, conn, stream:
- test(q, bus, conn, stream, cs.CHANNEL_TYPE_STREAMED_MEDIA), timeout=10)
+ exec_test(partial(test, channel_type=cs.CHANNEL_TYPE_STREAMED_MEDIA),
+ timeout=10)
print "FIXME: leaks connection, everyone dies"
raise SystemExit(77)
- exec_test(lambda q, bus, conn, stream:
- test(q, bus, conn, stream, cs.CHANNEL_TYPE_CALL), timeout=10)
+ exec_test(partial(test, channel_type=cs.CHANNEL_TYPE_CALL),
+ timeout=10)
diff --git a/tests/twisted/jingle/test-wait-for-caps.py b/tests/twisted/jingle/test-wait-for-caps.py
index f7eaa96..47afe7d 100644
--- a/tests/twisted/jingle/test-wait-for-caps.py
+++ b/tests/twisted/jingle/test-wait-for-caps.py
@@ -4,6 +4,7 @@ attempts to call a contact. Gabble should delay the RequestStreams
call until caps have arrived.
"""
+from functools import partial
from gabbletest import exec_test
from servicetest import make_channel_proxy, call_async, sync_dbus
import jingletest
@@ -93,8 +94,8 @@ def run_test(q, bus, conn, stream, jt, request_before_presence, channel_type):
q.expect('dbus-return', method='CreateChannel')
if __name__ == '__main__':
- exec_test(lambda q, bus, conn, stream:
- test(q, bus, conn, stream, cs.CHANNEL_TYPE_STREAMED_MEDIA), timeout=10)
- exec_test(lambda q, bus, conn, stream:
- test(q, bus, conn, stream, cs.CHANNEL_TYPE_CALL), timeout=10)
+ exec_test(partial(test, channel_type=cs.CHANNEL_TYPE_STREAMED_MEDIA),
+ timeout=10)
+ exec_test(partial(test, channel_type=cs.CHANNEL_TYPE_CALL),
+ timeout=10)
More information about the telepathy-commits
mailing list