[telepathy-gabble/master] offer-muc-stream-tube.py: use create_server

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Wed Apr 29 10:44:11 PDT 2009


---
 tests/twisted/tubes/offer-muc-stream-tube.py |   22 ++++++----------------
 1 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/tests/twisted/tubes/offer-muc-stream-tube.py b/tests/twisted/tubes/offer-muc-stream-tube.py
index ab5fe73..3e84fd6 100644
--- a/tests/twisted/tubes/offer-muc-stream-tube.py
+++ b/tests/twisted/tubes/offer-muc-stream-tube.py
@@ -5,7 +5,7 @@ import os
 
 import dbus
 
-from servicetest import call_async, EventPattern, EventProtocolFactory, unwrap,\
+from servicetest import call_async, EventPattern, unwrap,\
     assertContains
 from gabbletest import acknowledge_iq, make_muc_presence
 import constants as cs
@@ -24,17 +24,6 @@ sample_parameters = dbus.Dictionary({
     'i': dbus.Int32(-123),
     }, signature='sv')
 
-def set_up_listener_socket(q, path):
-    factory = EventProtocolFactory(q)
-    full_path = os.getcwd() + path
-    try:
-        os.remove(full_path)
-    except OSError, e:
-        if e.errno != errno.ENOENT:
-            raise
-    reactor.listenUNIX(full_path, factory)
-    return full_path
-
 def connect_to_tube(stream, q, bytestream_cls, muc, stream_tube_id):
     # The CM is the server, so fake a client wanting to talk to it
     bytestream = bytestream_cls(stream, q, 'alpha', '%s/bob' % muc,
@@ -74,7 +63,6 @@ def test(q, bus, conn, stream, bytestream_cls,
         # contacts atm
         return
 
-    srv_path = set_up_listener_socket(q, '/stream')
     conn.Connect()
 
     _, iq_event = q.expect_many(
@@ -96,9 +84,11 @@ def test(q, bus, conn, stream, bytestream_cls,
 
     bob_handle = conn.RequestHandles(cs.HT_CONTACT, ['chat at conf.localhost/bob'])[0]
 
+    address = t.create_server(q, address_type)
+
     # offer stream tube (old API) using an Unix socket
     call_async(q, tubes_iface, 'OfferStreamTube',
-        'echo', sample_parameters, address_type, dbus.ByteArray(srv_path),
+        'echo', sample_parameters, address_type, address,
         access_control, access_control_param)
 
     new_tube_event, stream_event, _, new_channels_event = q.expect_many(
@@ -205,7 +195,7 @@ def test(q, bus, conn, stream, bytestream_cls,
     use_tube(q, bytestream, protocol)
 
     # offer a stream tube to another room (new API)
-    srv_path = set_up_listener_socket(q, '/stream2')
+    address = t.create_server(q, address_type)
 
     call_async(q, conn.Requests, 'CreateChannel',
             {cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
@@ -276,7 +266,7 @@ def test(q, bus, conn, stream, bytestream_cls,
 
     # offer the tube
     call_async(q, stream_tube_iface, 'Offer',
-        address_type, dbus.ByteArray(srv_path), access_control, access_control_param,
+        address_type, address, access_control, access_control_param,
         {'foo': 'bar'})
 
     new_tube_event, stream_event, _, status_event = q.expect_many(
-- 
1.5.6.5




More information about the telepathy-commits mailing list