[telepathy-gabble/master] run stream tube tests using exec_stream_tube_test

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Wed Apr 29 09:21:27 PDT 2009


Stream tube tests now get the address type, access control and access
control param as parameters.
---
 tests/twisted/tubes/accept-muc-stream-tube.py     |    9 +++--
 tests/twisted/tubes/accept-private-stream-tube.py |   35 +++++++++-----------
 tests/twisted/tubes/offer-muc-stream-tube.py      |   10 +++--
 tests/twisted/tubes/offer-private-stream-tube.py  |   11 ++++--
 tests/twisted/tubes/tubetestutil.py               |    6 ++-
 5 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/tests/twisted/tubes/accept-muc-stream-tube.py b/tests/twisted/tubes/accept-muc-stream-tube.py
index 2e5abdb..000ca33 100644
--- a/tests/twisted/tubes/accept-muc-stream-tube.py
+++ b/tests/twisted/tubes/accept-muc-stream-tube.py
@@ -19,7 +19,8 @@ sample_parameters = dbus.Dictionary({
     'i': dbus.Int32(-123),
     }, signature='sv')
 
-def test(q, bus, conn, stream, bytestream_cls):
+def test(q, bus, conn, stream, bytestream_cls,
+        address_type, access_control, access_control_param):
     if bytestream_cls in [BytestreamS5BRelay, BytestreamS5BRelayBugged]:
         # disable SOCKS5 relay tests because proxy can't be used with muc
         # contacts atm
@@ -181,8 +182,8 @@ def test(q, bus, conn, stream, bytestream_cls):
     assert tube_props['State'] == cs.TUBE_CHANNEL_STATE_LOCAL_PENDING
 
     # Accept the tube
-    call_async(q, tubes_iface, 'AcceptStreamTube', stream_tube_id, 0, 0, '',
-            byte_arrays=True)
+    call_async(q, tubes_iface, 'AcceptStreamTube', stream_tube_id,
+        address_type, access_control, access_control_param, byte_arrays=True)
 
     accept_return_event, _ = q.expect_many(
         EventPattern('dbus-return', method='AcceptStreamTube'),
@@ -236,4 +237,4 @@ def test(q, bus, conn, stream, bytestream_cls):
         EventPattern('dbus-signal', signal='StatusChanged', args=[2, 1]))
 
 if __name__ == '__main__':
-    t.exec_tube_test(test)
+    t.exec_stream_tube_test(test)
diff --git a/tests/twisted/tubes/accept-private-stream-tube.py b/tests/twisted/tubes/accept-private-stream-tube.py
index e9f96a7..afb67e4 100644
--- a/tests/twisted/tubes/accept-private-stream-tube.py
+++ b/tests/twisted/tubes/accept-private-stream-tube.py
@@ -110,7 +110,8 @@ def expect_tube_activity(q, bus, conn, stream, bytestream_cls):
 
     return bytestream
 
-def test(q, bus, conn, stream, bytestream_cls):
+def test(q, bus, conn, stream, bytestream_cls,
+        address_type, access_control, access_control_param):
     conn.Connect()
 
     _, vcard_event, roster_event, disco_event = q.expect_many(
@@ -177,21 +178,19 @@ def test(q, bus, conn, stream, bytestream_cls):
             byte_arrays=True)
     q.expect('dbus-error', method='Accept')
 
-    # Accept the tube with old iface, and use IPv4
-    call_async(q, tubes_iface, 'AcceptStreamTube', stream_tube_id, 2, 0, '',
-            byte_arrays=True)
+    # Accept the tube with old iface
+    call_async(q, tubes_iface, 'AcceptStreamTube', stream_tube_id, address_type,
+        access_control, access_control_param, byte_arrays=True)
 
     accept_return_event, _ = q.expect_many(
         EventPattern('dbus-return', method='AcceptStreamTube'),
         EventPattern('dbus-signal', signal='TubeStateChanged',
             args=[stream_tube_id, 2]))
 
-    ip = accept_return_event.value[0][0]
-    port = accept_return_event.value[0][1]
-    assert port > 0
+    socket_address = accept_return_event.value[0]
 
     factory = EventProtocolClientFactory(q)
-    reactor.connectTCP(ip, port, factory)
+    reactor.connectUNIX(socket_address, factory)
 
     bytestream = expect_tube_activity(q, bus, conn, stream, bytestream_cls)
     tubes_chan.Close()
@@ -202,8 +201,8 @@ def test(q, bus, conn, stream, bytestream_cls):
         receive_tube_offer(q, bus, conn, stream)
 
     # Accept the tube with old iface, and use UNIX sockets
-    call_async(q, tubes_iface, 'AcceptStreamTube', stream_tube_id, 0, 0, '',
-            byte_arrays=True)
+    call_async(q, tubes_iface, 'AcceptStreamTube', stream_tube_id,
+        address_type, access_control, access_control_param, byte_arrays=True)
 
     accept_return_event, _ = q.expect_many(
         EventPattern('dbus-return', method='AcceptStreamTube'),
@@ -224,20 +223,18 @@ def test(q, bus, conn, stream, bytestream_cls):
         receive_tube_offer(q, bus, conn, stream)
 
     # Accept the tube with new iface, and use IPv4
-    call_async(q, new_tube_iface, 'Accept', 2, 0, '',
-            byte_arrays=True)
+    call_async(q, new_tube_iface, 'Accept', address_type,
+        access_control, access_control_param, byte_arrays=True)
 
     accept_return_event, _ = q.expect_many(
         EventPattern('dbus-return', method='Accept'),
         EventPattern('dbus-signal', signal='TubeStateChanged',
             args=[stream_tube_id, 2]))
 
-    ip = accept_return_event.value[0][0]
-    port = accept_return_event.value[0][1]
-    assert port > 0
+    socket_address = accept_return_event.value[0]
 
     factory = EventProtocolClientFactory(q)
-    reactor.connectTCP(ip, port, factory)
+    reactor.connectUNIX(socket_address, factory)
 
     bytestream = expect_tube_activity(q, bus, conn, stream, bytestream_cls)
     tubes_chan.Close()
@@ -248,8 +245,8 @@ def test(q, bus, conn, stream, bytestream_cls):
         receive_tube_offer(q, bus, conn, stream)
 
     # Accept the tube with new iface, and use UNIX sockets
-    call_async(q, new_tube_iface, 'Accept', 0, 0, '',
-            byte_arrays=True)
+    call_async(q, new_tube_iface, 'Accept', address_type, access_control,
+        access_control_param, byte_arrays=True)
 
     accept_return_event, _ = q.expect_many(
         EventPattern('dbus-return', method='Accept'),
@@ -287,4 +284,4 @@ def test(q, bus, conn, stream, bytestream_cls):
     q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
 
 if __name__ == '__main__':
-    t.exec_tube_test(test)
+    t.exec_stream_tube_test(test)
diff --git a/tests/twisted/tubes/offer-muc-stream-tube.py b/tests/twisted/tubes/offer-muc-stream-tube.py
index 84d091f..ab5fe73 100644
--- a/tests/twisted/tubes/offer-muc-stream-tube.py
+++ b/tests/twisted/tubes/offer-muc-stream-tube.py
@@ -67,7 +67,8 @@ def use_tube(q, bytestream, protocol):
     assert binary == data, binary
 
 
-def test(q, bus, conn, stream, bytestream_cls):
+def test(q, bus, conn, stream, bytestream_cls,
+       address_type, access_control, access_control_param):
     if bytestream_cls in [BytestreamS5BRelay, BytestreamS5BRelayBugged]:
         # disable SOCKS5 relay tests because proxy can't be used with muc
         # contacts atm
@@ -97,7 +98,8 @@ def test(q, bus, conn, stream, bytestream_cls):
 
     # offer stream tube (old API) using an Unix socket
     call_async(q, tubes_iface, 'OfferStreamTube',
-        'echo', sample_parameters, 0, dbus.ByteArray(srv_path), 0, "")
+        'echo', sample_parameters, address_type, dbus.ByteArray(srv_path),
+        access_control, access_control_param)
 
     new_tube_event, stream_event, _, new_channels_event = q.expect_many(
         EventPattern('dbus-signal', signal='NewTube'),
@@ -274,7 +276,7 @@ def test(q, bus, conn, stream, bytestream_cls):
 
     # offer the tube
     call_async(q, stream_tube_iface, 'Offer',
-        cs.SOCKET_ADDRESS_TYPE_UNIX, dbus.ByteArray(srv_path), cs.SOCKET_ACCESS_CONTROL_LOCALHOST, "",
+        address_type, dbus.ByteArray(srv_path), access_control, access_control_param,
         {'foo': 'bar'})
 
     new_tube_event, stream_event, _, status_event = q.expect_many(
@@ -354,4 +356,4 @@ def test(q, bus, conn, stream, bytestream_cls):
     q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
 
 if __name__ == '__main__':
-    t.exec_tube_test(test)
+    t.exec_stream_tube_test(test)
diff --git a/tests/twisted/tubes/offer-private-stream-tube.py b/tests/twisted/tubes/offer-private-stream-tube.py
index a091870..b68fb60 100644
--- a/tests/twisted/tubes/offer-private-stream-tube.py
+++ b/tests/twisted/tubes/offer-private-stream-tube.py
@@ -39,7 +39,8 @@ def contact_offer_dbus_tube(bytestream, tube_id):
 
     bytestream.stream.send(iq)
 
-def test(q, bus, conn, stream, bytestream_cls):
+def test(q, bus, conn, stream, bytestream_cls,
+        address_type, access_control, access_control_param):
     echo_path = t.set_up_echo("")
     echo2_path = t.set_up_echo("2")
 
@@ -179,7 +180,8 @@ def test(q, bus, conn, stream, bytestream_cls):
 
     # Create another tube using old API
     call_async(q, tubes_iface, 'OfferStreamTube',
-        'echo', sample_parameters, 0, dbus.ByteArray(echo_path), 0, "")
+        'echo', sample_parameters, address_type, dbus.ByteArray(echo_path),
+        access_control, access_control_param)
 
     event, return_event, new_chan, new_chans = q.expect_many(
         EventPattern('stream-message'),
@@ -259,7 +261,8 @@ def test(q, bus, conn, stream, bytestream_cls):
 
     # Offer the first tube created (new API)
     call_async(q, new_tube_iface, 'Offer',
-        0, dbus.ByteArray(echo2_path), 0, "", new_sample_parameters)
+        address_type, dbus.ByteArray(echo2_path), access_control,
+        access_control_param, new_sample_parameters)
 
     msg_event, new_tube_sig, state_event = q.expect_many(
         EventPattern('stream-message'),
@@ -396,4 +399,4 @@ def test(q, bus, conn, stream, bytestream_cls):
     q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
 
 if __name__ == '__main__':
-    t.exec_tube_test(test)
+    t.exec_stream_tube_test(test)
diff --git a/tests/twisted/tubes/tubetestutil.py b/tests/twisted/tubes/tubetestutil.py
index 3494aef..e8998c1 100644
--- a/tests/twisted/tubes/tubetestutil.py
+++ b/tests/twisted/tubes/tubetestutil.py
@@ -223,7 +223,7 @@ def set_up_echo(name):
     reactor.listenUNIX(full_path, factory)
     return full_path
 
-def exec_tube_test(test):
+def exec_tube_test(test, *args):
     for bytestream_cls in [
             bytestream.BytestreamIBBMsg,
             bytestream.BytestreamIBBIQ,
@@ -233,5 +233,7 @@ def exec_tube_test(test):
             bytestream.BytestreamS5BRelay,
             bytestream.BytestreamS5BRelayBugged]:
         exec_test(lambda q, bus, conn, stream:
-            test(q, bus, conn, stream, bytestream_cls))
+            test(q, bus, conn, stream, bytestream_cls, *args))
 
+def exec_stream_tube_test(test):
+    exec_tube_test(test, cs.SOCKET_ADDRESS_TYPE_UNIX, cs.SOCKET_ACCESS_CONTROL_LOCALHOST, "")
-- 
1.5.6.5




More information about the telepathy-commits mailing list