summaryrefslogtreecommitdiff
path: root/tests/twisted/tubes
diff options
context:
space:
mode:
Diffstat (limited to 'tests/twisted/tubes')
-rw-r--r--tests/twisted/tubes/accept-muc-dbus-tube.py7
-rw-r--r--tests/twisted/tubes/accept-muc-stream-tube.py14
-rw-r--r--tests/twisted/tubes/accept-private-dbus-tube.py8
-rw-r--r--tests/twisted/tubes/accept-private-stream-tube.py9
-rw-r--r--tests/twisted/tubes/check-create-tube-return.py4
-rw-r--r--tests/twisted/tubes/close-muc-with-closed-tube.py6
-rw-r--r--tests/twisted/tubes/ensure-si-tube.py16
-rw-r--r--tests/twisted/tubes/offer-muc-dbus-tube.py19
-rw-r--r--tests/twisted/tubes/offer-muc-stream-tube.py11
-rw-r--r--tests/twisted/tubes/offer-private-dbus-tube.py15
-rw-r--r--tests/twisted/tubes/offer-private-stream-tube.py14
-rw-r--r--tests/twisted/tubes/test-socks5-muc.py8
-rw-r--r--tests/twisted/tubes/tubetestutil.py43
13 files changed, 58 insertions, 116 deletions
diff --git a/tests/twisted/tubes/accept-muc-dbus-tube.py b/tests/twisted/tubes/accept-muc-dbus-tube.py
index 83b1b5982..4cf657ef6 100644
--- a/tests/twisted/tubes/accept-muc-dbus-tube.py
+++ b/tests/twisted/tubes/accept-muc-dbus-tube.py
@@ -43,13 +43,12 @@ def test(q, bus, conn, stream, access_control):
# tube channel is created
def new_chan_predicate(e):
- path, props = e.args[0][0]
+ path, props = e.args
return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
- event = q.expect('dbus-signal', signal='NewChannels',
+ event = q.expect('dbus-signal', signal='NewChannel',
predicate=new_chan_predicate)
- channels = event.args[0]
- path, props = channels[0]
+ path, props = event.args
assertEquals(cs.CHANNEL_TYPE_DBUS_TUBE, props[cs.CHANNEL_TYPE])
assertEquals('chat@conf.localhost/bob', props[cs.INITIATOR_ID])
diff --git a/tests/twisted/tubes/accept-muc-stream-tube.py b/tests/twisted/tubes/accept-muc-stream-tube.py
index 16f2d6254..670aa7fdf 100644
--- a/tests/twisted/tubes/accept-muc-stream-tube.py
+++ b/tests/twisted/tubes/accept-muc-stream-tube.py
@@ -110,24 +110,20 @@ def test(q, bus, conn, stream, bytestream_cls,
stream.send(presence)
# text channel
- new_event = q.expect('dbus-signal', signal='NewChannels')
+ new_event = q.expect('dbus-signal', signal='NewChannel')
- channels = new_event.args[0]
- assert len(channels) == 1
- path, props = channels[0]
+ path, props = new_event.args
assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT
def new_chan_predicate(e):
- path, props = e.args[0][0]
+ path, props = e.args
return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
# tube channel is announced
- new_event = q.expect('dbus-signal', signal='NewChannels',
+ new_event = q.expect('dbus-signal', signal='NewChannel',
predicate=new_chan_predicate)
- channels = new_event.args[0]
- assert len(channels) == 1
- path, props = channels[0]
+ path, props = new_event.args
assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
assert props[cs.INITIATOR_HANDLE] == bob_handle
assert props[cs.INITIATOR_ID] == 'chat@conf.localhost/bob'
diff --git a/tests/twisted/tubes/accept-private-dbus-tube.py b/tests/twisted/tubes/accept-private-dbus-tube.py
index fb81cb63e..7f3efab71 100644
--- a/tests/twisted/tubes/accept-private-dbus-tube.py
+++ b/tests/twisted/tubes/accept-private-dbus-tube.py
@@ -91,14 +91,12 @@ def test(q, bus, conn, stream, bytestream_cls, access_control):
contact_offer_dbus_tube(bytestream, last_tube_id)
def new_chan_predicate(e):
- path, props = e.args[0][0]
+ path, props = e.args
return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
- e = q.expect('dbus-signal', signal='NewChannels',
+ e = q.expect('dbus-signal', signal='NewChannel',
predicate=new_chan_predicate)
- channels = e.args[0]
- assert len(channels) == 1
- path, props = channels[0]
+ path, props = e.args
assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
assert props[cs.INITIATOR_HANDLE] == bob_handle
diff --git a/tests/twisted/tubes/accept-private-stream-tube.py b/tests/twisted/tubes/accept-private-stream-tube.py
index 37ed1693d..386e51b5c 100644
--- a/tests/twisted/tubes/accept-private-stream-tube.py
+++ b/tests/twisted/tubes/accept-private-stream-tube.py
@@ -36,16 +36,13 @@ def receive_tube_offer(q, bus, conn, stream):
stream.send(message)
def new_chan_predicate(e):
- path, props = e.args[0][0]
+ path, props = e.args
return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
- new_sig = q.expect('dbus-signal', signal='NewChannels',
+ new_sig = q.expect('dbus-signal', signal='NewChannel',
predicate=new_chan_predicate)
- assert len(new_sig.args) == 1
- assert len(new_sig.args[0]) == 1
-
- path, props = new_sig.args[0][0]
+ path, props = new_sig.args
assertEquals(cs.CHANNEL_TYPE_STREAM_TUBE, props[cs.CHANNEL_TYPE])
assertEquals(cs.HT_CONTACT, props[cs.TARGET_HANDLE_TYPE])
assertEquals(False, props[cs.REQUESTED])
diff --git a/tests/twisted/tubes/check-create-tube-return.py b/tests/twisted/tubes/check-create-tube-return.py
index 2f1e34aa9..a2af73f9f 100644
--- a/tests/twisted/tubes/check-create-tube-return.py
+++ b/tests/twisted/tubes/check-create-tube-return.py
@@ -41,7 +41,7 @@ def test(q, bus, conn, stream):
ret, _ = q.expect_many(
EventPattern('dbus-return', method='CreateChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
+ EventPattern('dbus-signal', signal='NewChannel'),
)
_, props = ret.value
@@ -63,7 +63,7 @@ def test(q, bus, conn, stream):
ret, _ = q.expect_many(
EventPattern('dbus-return', method='CreateChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
+ EventPattern('dbus-signal', signal='NewChannel'),
)
_, props = ret.value
diff --git a/tests/twisted/tubes/close-muc-with-closed-tube.py b/tests/twisted/tubes/close-muc-with-closed-tube.py
index 3f28d2aae..3cf23fdef 100644
--- a/tests/twisted/tubes/close-muc-with-closed-tube.py
+++ b/tests/twisted/tubes/close-muc-with-closed-tube.py
@@ -96,14 +96,14 @@ def test(q, bus, conn, stream):
stream.send(presence)
def new_chan_predicate(e):
- path, props = e.args[0][0]
+ path, props = e.args
return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
# tube channel is automatically created
- event = q.expect('dbus-signal', signal='NewChannels',
+ event = q.expect('dbus-signal', signal='NewChannel',
predicate=new_chan_predicate)
- path, props = event.args[0][0]
+ path, props = event.args
assertEquals(cs.CHANNEL_TYPE_DBUS_TUBE, props[cs.CHANNEL_TYPE])
assertEquals(cs.HT_ROOM, props[cs.TARGET_HANDLE_TYPE])
diff --git a/tests/twisted/tubes/ensure-si-tube.py b/tests/twisted/tubes/ensure-si-tube.py
index 259c464a7..868ec63d0 100644
--- a/tests/twisted/tubes/ensure-si-tube.py
+++ b/tests/twisted/tubes/ensure-si-tube.py
@@ -27,6 +27,9 @@ def test(q, bus, conn, stream):
properties = conn.GetAll(
cs.CONN_IFACE_REQUESTS, dbus_interface=cs.PROPERTIES_IFACE)
assert properties.get('Channels') == [], properties['Channels']
+
+ properties = conn.GetAll(
+ cs.CONN, dbus_interface=cs.PROPERTIES_IFACE)
assert ({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
},
@@ -73,11 +76,8 @@ def test(q, bus, conn, stream):
bob_handle = conn.get_contact_handle_sync('bob@localhost')
def new_chan_predicate(e):
- types = []
- for _, props in e.args[0]:
- types.append(props[cs.CHANNEL_TYPE])
-
- return cs.CHANNEL_TYPE_STREAM_TUBE in types
+ _, props = e.args
+ return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
call_async(q, conn.Requests, 'CreateChannel',
{ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
@@ -88,7 +88,7 @@ def test(q, bus, conn, stream):
ret, _ = q.expect_many(
EventPattern('dbus-return', method='CreateChannel'),
- EventPattern('dbus-signal', signal='NewChannels',
+ EventPattern('dbus-signal', signal='NewChannel',
predicate=new_chan_predicate),
)
@@ -122,14 +122,14 @@ def test(q, bus, conn, stream):
ret, new_sig = q.expect_many(
EventPattern('dbus-return', method='EnsureChannel'),
- EventPattern('dbus-signal', signal='NewChannels',
+ EventPattern('dbus-signal', signal='NewChannel',
predicate=new_chan_predicate),
)
yours, path, props = ret.value
assert yours
- emitted_props = new_sig.args[0][0][1]
+ emitted_props = new_sig.args[1]
assert props == emitted_props, (props, emitted_props)
chan = bus.get_object(conn.bus_name, path)
diff --git a/tests/twisted/tubes/offer-muc-dbus-tube.py b/tests/twisted/tubes/offer-muc-dbus-tube.py
index 06b4705ec..0e138a22a 100644
--- a/tests/twisted/tubes/offer-muc-dbus-tube.py
+++ b/tests/twisted/tubes/offer-muc-dbus-tube.py
@@ -127,11 +127,9 @@ def test(q, bus, conn, stream, access_control):
}
join_muc(q, bus, conn, stream, muc, request=request)
- e = q.expect('dbus-signal', signal='NewChannels')
+ e = q.expect('dbus-signal', signal='NewChannel')
- channels = e.args[0]
- assert len(channels) == 1
- path, prop = channels[0]
+ path, prop = e.args
assert prop[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
assert prop[cs.INITIATOR_ID] == 'chat2@conf.localhost/test'
assert prop[cs.REQUESTED] == True
@@ -267,28 +265,27 @@ def test(q, bus, conn, stream, access_control):
stream.send(make_muc_presence('none', 'participant', muc, 'test'))
def new_tube(e):
- path, props = e.args[0][0]
+ path, props = e.args
return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
def new_text(e):
- path, props = e.args[0][0]
+ path, props = e.args
return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT
# tube and text is created
- text_event, tube_event = q.expect_many(EventPattern('dbus-signal', signal='NewChannels',
+ text_event, tube_event = q.expect_many(EventPattern('dbus-signal', signal='NewChannel',
predicate=new_text),
- EventPattern('dbus-signal', signal='NewChannels',
+ EventPattern('dbus-signal', signal='NewChannel',
predicate=new_tube))
- channels = e.args[0]
- tube_path, props = tube_event.args[0][0]
+ tube_path, props = tube_event.args
assertEquals(cs.CHANNEL_TYPE_DBUS_TUBE, props[cs.CHANNEL_TYPE])
assertEquals('chat2@conf.localhost/test', props[cs.INITIATOR_ID])
assertEquals(False, props[cs.REQUESTED])
assertEquals(cs.HT_ROOM, props[cs.TARGET_HANDLE_TYPE])
assertEquals('com.example.TestCase', props[cs.DBUS_TUBE_SERVICE_NAME])
- _, props = text_event.args[0][0]
+ _, props = text_event.args
assertEquals(cs.CHANNEL_TYPE_TEXT, props[cs.CHANNEL_TYPE])
assertEquals(True, props[cs.REQUESTED])
diff --git a/tests/twisted/tubes/offer-muc-stream-tube.py b/tests/twisted/tubes/offer-muc-stream-tube.py
index bc6f0efd5..ab0603710 100644
--- a/tests/twisted/tubes/offer-muc-stream-tube.py
+++ b/tests/twisted/tubes/offer-muc-stream-tube.py
@@ -79,11 +79,8 @@ def test(q, bus, conn, stream, bytestream_cls,
address = t.create_server(q, address_type)
def new_chan_predicate(e):
- types = []
- for _, props in e.args[0]:
- types.append(props[cs.CHANNEL_TYPE])
-
- return cs.CHANNEL_TYPE_STREAM_TUBE in types
+ _, props = e.args
+ return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
def find_stream_tube(channels):
for path, props in channels:
@@ -104,10 +101,10 @@ def test(q, bus, conn, stream, bytestream_cls,
_, new_tube_path, new_tube_props = \
join_muc(q, bus, conn, stream, 'chat@conf.localhost', request)
- e = q.expect('dbus-signal', signal='NewChannels',
+ e = q.expect('dbus-signal', signal='NewChannel',
predicate=new_chan_predicate)
- path, prop = find_stream_tube(e.args[0])
+ path, prop = e.args
assert prop[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
assert prop[cs.INITIATOR_ID] == 'chat@conf.localhost/test'
assert prop[cs.REQUESTED] == True
diff --git a/tests/twisted/tubes/offer-private-dbus-tube.py b/tests/twisted/tubes/offer-private-dbus-tube.py
index ee4e190a7..a7b2de54a 100644
--- a/tests/twisted/tubes/offer-private-dbus-tube.py
+++ b/tests/twisted/tubes/offer-private-dbus-tube.py
@@ -104,11 +104,8 @@ def offer_new_dbus_tube(q, bus, conn, stream, self_handle, alice_handle,
# Offer a tube to Alice (new API)
def new_chan_predicate(e):
- types = []
- for _, props in e.args[0]:
- types.append(props[cs.CHANNEL_TYPE])
-
- return cs.CHANNEL_TYPE_DBUS_TUBE in types
+ _, props = e.args
+ return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
def find_dbus_tube(channels):
for path, props in channels:
@@ -125,11 +122,11 @@ def offer_new_dbus_tube(q, bus, conn, stream, self_handle, alice_handle,
}, byte_arrays=True)
cc_ret, nc = q.expect_many(
EventPattern('dbus-return', method='CreateChannel'),
- EventPattern('dbus-signal', signal='NewChannels',
+ EventPattern('dbus-signal', signal='NewChannel',
predicate=new_chan_predicate),
)
tube_path, tube_props = cc_ret.value
- _, new_channel_props = find_dbus_tube(nc.args[0])
+ _, new_channel_props = nc.args
# check tube channel properties
assert tube_props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_DBUS_TUBE
@@ -151,8 +148,8 @@ def offer_new_dbus_tube(q, bus, conn, stream, self_handle, alice_handle,
all_channels = conn.Get(cs.CONN_IFACE_REQUESTS, 'Channels',
dbus_interface=cs.PROPERTIES_IFACE, byte_arrays=True)
- for path, props in nc.args[0]:
- assertContains((path, props), all_channels)
+ path, props = nc.args
+ assertContains((path, props), all_channels)
assertEquals(tube_props, new_channel_props)
diff --git a/tests/twisted/tubes/offer-private-stream-tube.py b/tests/twisted/tubes/offer-private-stream-tube.py
index e43901bf8..b6a488323 100644
--- a/tests/twisted/tubes/offer-private-stream-tube.py
+++ b/tests/twisted/tubes/offer-private-stream-tube.py
@@ -107,20 +107,20 @@ def test(q, bus, conn, stream, bytestream_cls,
cs.STREAM_TUBE_SERVICE: "newecho",
})
- def find_stream_tube(channels):
- for path, props in channels:
- if props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE:
- return path, props
+ def find_stream_tube(e):
+ path, props = e.args
+ if props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE:
+ return path, props
return None, None
def new_chan_predicate(e):
- path, _ = find_stream_tube(e.args[0])
+ path, _ = find_stream_tube(e)
return path is not None
ret, new_sig = q.expect_many(
EventPattern('dbus-return', method='CreateChannel'),
- EventPattern('dbus-signal', signal='NewChannels',
+ EventPattern('dbus-signal', signal='NewChannel',
predicate=new_chan_predicate),
)
@@ -142,7 +142,7 @@ def test(q, bus, conn, stream, bytestream_cls,
# the tube created using the new API is in the "not offered" state
assert new_tube_props['State'] == cs.TUBE_CHANNEL_STATE_NOT_OFFERED
- _, stream_tube_channel_properties = find_stream_tube(new_sig.args[0])
+ _, stream_tube_channel_properties = find_stream_tube(new_sig)
assert cs.TUBE_STATE not in stream_tube_channel_properties
assert cs.TUBE_PARAMETERS not in stream_tube_channel_properties
diff --git a/tests/twisted/tubes/test-socks5-muc.py b/tests/twisted/tubes/test-socks5-muc.py
index 54947ec55..1c9236dfa 100644
--- a/tests/twisted/tubes/test-socks5-muc.py
+++ b/tests/twisted/tubes/test-socks5-muc.py
@@ -42,14 +42,12 @@ def test(q, bus, conn, stream):
stream.send(presence)
def new_chan_predicate(e):
- path, props = e.args[0][0]
+ path, props = e.args
return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
- e = q.expect('dbus-signal', signal='NewChannels',
+ e = q.expect('dbus-signal', signal='NewChannel',
predicate=new_chan_predicate)
- channels = e.args[0]
- assert len(channels) == 1
- path, props = channels[0]
+ path, props = e.args
assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_STREAM_TUBE
tube_chan = bus.get_object(conn.bus_name, path)
diff --git a/tests/twisted/tubes/tubetestutil.py b/tests/twisted/tubes/tubetestutil.py
index 3c53d1533..092220df1 100644
--- a/tests/twisted/tubes/tubetestutil.py
+++ b/tests/twisted/tubes/tubetestutil.py
@@ -82,6 +82,9 @@ def check_conn_properties(q, conn, channel_list=None):
assert i in properties['Channels'], \
(i, properties['Channels'])
+ properties = conn.GetAll(
+ cs.CONN, dbus_interface=cs.PROPERTIES_IFACE)
+
# 1-1 StreamTube channel
assert ({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT
@@ -112,46 +115,6 @@ def check_conn_properties(q, conn, channel_list=None):
) in properties.get('RequestableChannelClasses'),\
properties['RequestableChannelClasses']
-
-def check_NewChannel_signal(args, channel_type, chan_path, contact_handle,
- suppress_handler):
- """
- Checks the first argument, a tuple of arguments from NewChannel, matches
- the other arguments.
- """
- if chan_path is not None:
- assert args[0] == chan_path, (args, chan_path)
- assert args[1] == channel_type, (args, channel_type)
- assert args[2] == cs.HT_CONTACT, (args, cs.HT_CONTACT)
- assert args[3] == contact_handle, (args, contact_handle)
- assert args[4] == suppress_handler, (args, suppress_handler)
-
-def check_NewChannels_signal(conn, args, channel_type, chan_path, contact_handle,
- contact_id, initiator_handle):
- """
- Checks the first argument, a one-tuple of arguments from NewChannels,
- matches the other arguments.
- """
- assert len(args) == 1, args
- assert len(args[0]) == 1 # one channel
- path, props = args[0][0]
-
- assert path == chan_path, (emitted_path, chan_path)
-
- assert props[cs.CHANNEL_TYPE] == channel_type, (props, channel_type)
- assert props[cs.TARGET_HANDLE_TYPE] == cs.HT_CONTACT, props
- assert props[cs.TARGET_HANDLE] == contact_handle, (props, contact_handle)
- assert props[cs.TARGET_ID] == contact_id, (props, contact_id)
- assert props[cs.REQUESTED] == True, props
- assert props[cs.INITIATOR_HANDLE] == initiator_handle, \
- (props, initiator_handle)
- assert props[cs.INITIATOR_ID] == 'test@localhost', props
-
- # check that the newly announced channel is in the channels list
- all_channels = conn.Get(cs.CONN_IFACE_REQUESTS, 'Channels',
- dbus_interface=cs.PROPERTIES_IFACE, byte_arrays=True)
- assertContains((path, props), all_channels)
-
def check_platform_socket_types(sock_types):
assertContains(cs.SOCKET_ADDRESS_TYPE_IPV4, sock_types)
assertContains(cs.SOCKET_ADDRESS_TYPE_IPV6, sock_types)