telepathy-gabble: tubes test: use more the channel wrapper

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Thu Oct 3 05:11:32 PDT 2013


Module: telepathy-gabble
Branch: master
Commit: a5602d10fe382935011c08121cca2031e7b54c2a
URL:    http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=a5602d10fe382935011c08121cca2031e7b54c2a

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Thu Oct  3 12:30:33 2013 +0200

tubes test: use more the channel wrapper

---

 tests/twisted/tubes/accept-muc-dbus-tube.py  |    6 ++----
 tests/twisted/tubes/offer-muc-dbus-tube.py   |   11 ++++-------
 tests/twisted/tubes/offer-muc-stream-tube.py |    6 ++----
 3 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/tests/twisted/tubes/accept-muc-dbus-tube.py b/tests/twisted/tubes/accept-muc-dbus-tube.py
index 3af5505..b1a3dfb 100644
--- a/tests/twisted/tubes/accept-muc-dbus-tube.py
+++ b/tests/twisted/tubes/accept-muc-dbus-tube.py
@@ -64,14 +64,12 @@ def test(q, bus, conn, stream, access_control):
         props[cs.DBUS_TUBE_SUPPORTED_ACCESS_CONTROLS])
 
     tube_chan = wrap_channel(bus.get_object(conn.bus_name, path), 'DBusTube')
-    dbus_tube_iface = dbus.Interface(tube_chan, cs.CHANNEL_TYPE_DBUS_TUBE)
-    tube_chan_iface = dbus.Interface(tube_chan, cs.CHANNEL)
 
     # only Bob is in DBusNames
     dbus_names = tube_chan.Get(cs.CHANNEL_TYPE_DBUS_TUBE, 'DBusNames', dbus_interface=cs.PROPERTIES_IFACE)
     assertEquals({bob_handle: bob_bus_name}, dbus_names)
 
-    call_async(q, dbus_tube_iface, 'Accept', access_control)
+    call_async(q, tube_chan.DBusTube, 'Accept', access_control)
 
     return_event, names_changed1, names_changed2, presence_event = q.expect_many(
         EventPattern('dbus-return', method='Accept'),
@@ -106,7 +104,7 @@ def test(q, bus, conn, stream, access_control):
     assertEquals({tubes_self_handle: self_bus_name}, added)
     assertEquals([], removed)
 
-    tube_chan_iface.Close()
+    tube_chan.Channel.Close()
     q.expect_many(
         EventPattern('dbus-signal', signal='Closed'),
         EventPattern('dbus-signal', signal='ChannelClosed'))
diff --git a/tests/twisted/tubes/offer-muc-dbus-tube.py b/tests/twisted/tubes/offer-muc-dbus-tube.py
index 61d8879..563e001 100644
--- a/tests/twisted/tubes/offer-muc-dbus-tube.py
+++ b/tests/twisted/tubes/offer-muc-dbus-tube.py
@@ -147,23 +147,20 @@ def test(q, bus, conn, stream, access_control):
     assertContains((path, prop), all_channels)
 
     tube_chan = wrap_channel(bus.get_object(conn.bus_name, path), 'DBusTube')
-    dbus_tube_iface = dbus.Interface(tube_chan, cs.CHANNEL_TYPE_DBUS_TUBE)
-    chan_iface = dbus.Interface(tube_chan, cs.CHANNEL)
-    tube_props = tube_chan.GetAll(cs.CHANNEL_IFACE_TUBE, dbus_interface=cs.PROPERTIES_IFACE,
-        byte_arrays=True)
+    tube_props = tube_chan.Properties.GetAll(cs.CHANNEL_IFACE_TUBE, byte_arrays=True)
 
     assert tube_props['State'] == cs.TUBE_CHANNEL_STATE_NOT_OFFERED
 
     # try to offer using a wrong access control
     try:
-        dbus_tube_iface.Offer(sample_parameters, cs.SOCKET_ACCESS_CONTROL_PORT)
+        tube_chan.DBusTube.Offer(sample_parameters, cs.SOCKET_ACCESS_CONTROL_PORT)
     except dbus.DBusException, e:
         assertEquals(e.get_dbus_name(), cs.INVALID_ARGUMENT)
     else:
         assert False
 
     # offer the tube
-    call_async(q, dbus_tube_iface, 'Offer', sample_parameters, access_control)
+    call_async(q, tube_chan.DBusTube, 'Offer', sample_parameters, access_control)
 
     presence_event, return_event, status_event, dbus_changed_event = q.expect_many(
         EventPattern('stream-presence', to='chat2 at conf.localhost/test'),
@@ -242,7 +239,7 @@ def test(q, bus, conn, stream, access_control):
     names = tube_chan.Get(cs.CHANNEL_TYPE_DBUS_TUBE, 'DBusNames', dbus_interface=cs.PROPERTIES_IFACE)
     assert names == {tube_self_handle: my_bus_name}
 
-    chan_iface.Close()
+    tube_chan.Channel.Close()
     _, _, event = q.expect_many(
         EventPattern('dbus-signal', signal='Closed'),
         EventPattern('dbus-signal', signal='ChannelClosed'),
diff --git a/tests/twisted/tubes/offer-muc-stream-tube.py b/tests/twisted/tubes/offer-muc-stream-tube.py
index 02d04ea..ce7f338 100644
--- a/tests/twisted/tubes/offer-muc-stream-tube.py
+++ b/tests/twisted/tubes/offer-muc-stream-tube.py
@@ -121,14 +121,12 @@ def test(q, bus, conn, stream, bytestream_cls,
     assertContains((path, prop), all_channels)
 
     tube_chan = wrap_channel(bus.get_object(conn.bus_name, path), 'StreamTube')
-    stream_tube_iface = dbus.Interface(tube_chan, cs.CHANNEL_TYPE_STREAM_TUBE)
-    chan_iface = dbus.Interface(tube_chan, cs.CHANNEL)
     tube_props = tube_chan.GetAll(cs.CHANNEL_IFACE_TUBE, dbus_interface=cs.PROPERTIES_IFACE)
 
     assert tube_props['State'] == cs.TUBE_CHANNEL_STATE_NOT_OFFERED
 
     # offer the tube
-    call_async(q, stream_tube_iface, 'Offer', address_type, address, access_control, {'foo': 'bar'})
+    call_async(q, tube_chan.StreamTube, 'Offer', address_type, address, access_control, {'foo': 'bar'})
 
     stream_event, _, status_event = q.expect_many(
         EventPattern('stream-presence', to='chat at conf.localhost/test'),
@@ -190,7 +188,7 @@ def test(q, bus, conn, stream, bytestream_cls,
 
     use_tube(q, bytestream, protocol, conn_id)
 
-    chan_iface.Close()
+    tube_chan.Channel.Close()
     q.expect_many(
         EventPattern('dbus-signal', signal='Closed'),
         EventPattern('dbus-signal', signal='ChannelClosed'))



More information about the telepathy-commits mailing list