[Telepathy-commits] [telepathy-gabble/master] Move duplicated NewChannel checking to tubetestutil
Will Thompson
will.thompson at collabora.co.uk
Wed Feb 18 08:09:20 PST 2009
---
.../offer-accept-private-dbus-stream-tube-ibb.py | 14 +++-----------
...offer-accept-private-dbus-stream-tube-socks5.py | 14 ++++----------
tests/twisted/tubes/tubetestutil.py | 14 ++++++++++++++
3 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-ibb.py b/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-ibb.py
index 366ec93..58d8dbd 100644
--- a/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-ibb.py
+++ b/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-ibb.py
@@ -75,14 +75,6 @@ def check_channel_properties(q, bus, conn, stream, channel, channel_type,
# there is some support.
assert len(supported_socket_types) == 3
-def check_NewChannel_signal(old_sig, channel_type, chan_path, contact_handle, suppress_handler):
- if chan_path is not None:
- assert old_sig[0] == chan_path
- assert old_sig[1] == channel_type
- assert old_sig[2] == HT_CONTACT
- assert old_sig[3] == contact_handle
- assert old_sig[4] == suppress_handler # suppress handler
-
def check_NewChannels_signal(new_sig, channel_type, chan_path, contact_handle,
contact_id, initiator_handle):
assert len(new_sig) == 1
@@ -238,7 +230,7 @@ def test(q, bus, conn, stream):
assert len(ret.value) == 1
chan_path = ret.value[0]
- check_NewChannel_signal(old_sig.args, CHANNEL_TYPE_TUBES, chan_path, bob_handle, True)
+ t.check_NewChannel_signal(old_sig.args, CHANNEL_TYPE_TUBES, chan_path, bob_handle, True)
check_NewChannels_signal(new_sig.args, CHANNEL_TYPE_TUBES, chan_path,
bob_handle, 'bob at localhost', conn.GetSelfHandle())
old_tubes_channel_properties = new_sig.args[0][0]
@@ -284,7 +276,7 @@ def test(q, bus, conn, stream):
# the tube created using the old API is in the "not offered" state
assert new_tube_props['State'] == TUBE_CHANNEL_STATE_NOT_OFFERED
- check_NewChannel_signal(old_sig.args, CHANNEL_TYPE_STREAM_TUBE,
+ t.check_NewChannel_signal(old_sig.args, CHANNEL_TYPE_STREAM_TUBE,
new_chan_path, bob_handle, True)
check_NewChannels_signal(new_sig.args, CHANNEL_TYPE_STREAM_TUBE, new_chan_path, \
bob_handle, 'bob at localhost', conn.GetSelfHandle())
@@ -338,7 +330,7 @@ def test(q, bus, conn, stream):
# the tube channel (new API) is announced
- check_NewChannel_signal(new_chan.args, CHANNEL_TYPE_STREAM_TUBE,
+ t.check_NewChannel_signal(new_chan.args, CHANNEL_TYPE_STREAM_TUBE,
None, bob_handle, False)
check_NewChannels_signal(new_chans.args, CHANNEL_TYPE_STREAM_TUBE, new_chan.args[0],
bob_handle, "bob at localhost", self_handle)
diff --git a/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-socks5.py b/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-socks5.py
index 308fcc0..cdd85cc 100644
--- a/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-socks5.py
+++ b/tests/twisted/tubes/offer-accept-private-dbus-stream-tube-socks5.py
@@ -110,13 +110,6 @@ def check_channel_properties(q, bus, conn, stream, channel, channel_type,
# there is some support.
assert len(supported_socket_types) == 3
-def check_NewChannel_signal(old_sig, channel_type, chan_path, contact_handle):
- assert old_sig[0] == chan_path
- assert old_sig[1] == tp_name_prefix + '.Channel.Type.' + channel_type
- assert old_sig[2] == 1 # contact handle
- assert old_sig[3] == contact_handle
- assert old_sig[4] == True # suppress handler
-
def check_NewChannels_signal(new_sig, channel_type, chan_path, contact_handle,
contact_id, initiator_handle):
assert len(new_sig) == 1
@@ -252,7 +245,8 @@ def test(q, bus, conn, stream):
assert len(ret.value) == 1
chan_path = ret.value[0]
- check_NewChannel_signal(old_sig.args, "Tubes", chan_path, bob_handle)
+ t.check_NewChannel_signal(old_sig.args, CHANNEL_TYPE_TUBES, chan_path,
+ bob_handle, True)
check_NewChannels_signal(new_sig.args, "Tubes", chan_path,
bob_handle, 'bob at localhost', conn.GetSelfHandle())
old_tubes_channel_properties = new_sig.args[0][0]
@@ -285,8 +279,8 @@ def test(q, bus, conn, stream):
# of the Channel.Type.StreamTube object !
assert chan_path != new_chan_path
- check_NewChannel_signal(old_sig.args, "StreamTube.DRAFT", \
- new_chan_path, bob_handle)
+ t.check_NewChannel_signal(old_sig.args, CHANNEL_TYPE_STREAM_TUBE,
+ new_chan_path, bob_handle, True)
check_NewChannels_signal(new_sig.args, "StreamTube.DRAFT", new_chan_path, \
bob_handle, 'bob at localhost', conn.GetSelfHandle())
stream_tube_channel_properties = new_sig.args[0][0]
diff --git a/tests/twisted/tubes/tubetestutil.py b/tests/twisted/tubes/tubetestutil.py
index a5e27c2..93f6887 100644
--- a/tests/twisted/tubes/tubetestutil.py
+++ b/tests/twisted/tubes/tubetestutil.py
@@ -110,6 +110,20 @@ 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] == HT_CONTACT, (args, HT_CONTACT)
+ assert args[3] == contact_handle, (args, contact_handle)
+ assert args[4] == suppress_handler, (args, suppress_handler)
+
class Echo(Protocol):
"""
A trivial protocol that just echoes back whatever you send it, in lowercase.
--
1.5.6.5
More information about the telepathy-commits
mailing list