diff options
42 files changed, 160 insertions, 265 deletions
diff --git a/tests/twisted/console.py b/tests/twisted/console.py index f92e57aa8..d4bf44c9e 100644 --- a/tests/twisted/console.py +++ b/tests/twisted/console.py @@ -27,7 +27,7 @@ def send_unrecognised_get(q, stream): return q.expect('stream-iq', iq_type='error') def test(q, bus, conn, stream): - rccs = conn.Properties.Get(cs.CONN_IFACE_REQUESTS, + rccs = conn.Properties.Get(cs.CONN, 'RequestableChannelClasses') fixed = { diff --git a/tests/twisted/file-transfer/file_transfer_helper.py b/tests/twisted/file-transfer/file_transfer_helper.py index 4fa915b5d..3cea0eb84 100644 --- a/tests/twisted/file-transfer/file_transfer_helper.py +++ b/tests/twisted/file-transfer/file_transfer_helper.py @@ -199,21 +199,14 @@ class ReceiveFileTest(FileTransferTest): def check_new_channel(self): def is_ft_channel_event(event): - channels, = event.args - - if len(channels) > 1: - return False - - path, props = channels[0] + path, props = event.args return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_FILE_TRANSFER - e = self.q.expect('dbus-signal', signal='NewChannels', + e = self.q.expect('dbus-signal', signal='NewChannel', path=self.conn.object.object_path, predicate=is_ft_channel_event) - channels = e.args[0] - assert len(channels) == 1 - path, props = channels[0] + path, props = e.args # check channel properties # Channel D-Bus properties @@ -365,7 +358,7 @@ class SendFileTest(FileTransferTest): self.close_channel, self.done] def check_ft_available(self): - properties = self.conn.GetAll(cs.CONN_IFACE_REQUESTS, + properties = self.conn.GetAll(cs.CONN, dbus_interface=cs.PROPERTIES_IFACE) # general FT class diff --git a/tests/twisted/jingle-share/file_transfer_helper.py b/tests/twisted/jingle-share/file_transfer_helper.py index 96eccd9dc..b49cef1c2 100644 --- a/tests/twisted/jingle-share/file_transfer_helper.py +++ b/tests/twisted/jingle-share/file_transfer_helper.py @@ -250,20 +250,14 @@ class ReceiveFileTest(FileTransferTest): def check_new_channel(self): def is_ft_channel_event(event): - channels, = event.args - - if len(channels) > 1: - return False - - path, props = channels[0] + path, props = event.args return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_FILE_TRANSFER - e = self.q.expect('dbus-signal', signal='NewChannels', + e = self.q.expect('dbus-signal', signal='NewChannel', path=self.conn.object.object_path, predicate=is_ft_channel_event) - channels, = e.args - path, props = channels[0] + path, props = e.args # check channel properties # Channel D-Bus properties @@ -383,7 +377,7 @@ class SendFileTest(FileTransferTest): self.close_channel, self.done] def check_ft_available(self): - properties = self.conn.GetAll(cs.CONN_IFACE_REQUESTS, + properties = self.conn.GetAll(cs.CONN, dbus_interface=cs.PROPERTIES_IFACE) # general FT class diff --git a/tests/twisted/jingle-share/test-multift.py b/tests/twisted/jingle-share/test-multift.py index 889e6aeca..e1e4570ba 100644 --- a/tests/twisted/jingle-share/test-multift.py +++ b/tests/twisted/jingle-share/test-multift.py @@ -69,7 +69,7 @@ def test(q, bus, conn, stream): # /!\ This predicate has side-effects: it writes to 'found' def predicate(e): - path, props = e.args[0][0] + path, props = e.args if props[cs.CHANNEL_TYPE] != cs.CHANNEL_TYPE_FILE_TRANSFER: return False @@ -86,7 +86,7 @@ def test(q, bus, conn, stream): return False patterns.append(EventPattern('dbus-signal', - signal='NewChannels', + signal='NewChannel', predicate=get_predicate(name, found, i))) # Make sure every file transfer has a channel associated with it diff --git a/tests/twisted/jingle/call-codecoffer.py b/tests/twisted/jingle/call-codecoffer.py index 987ebf3b4..9dfd5cf66 100644 --- a/tests/twisted/jingle/call-codecoffer.py +++ b/tests/twisted/jingle/call-codecoffer.py @@ -110,12 +110,12 @@ def test_incoming(jp, q, bus, conn, stream): jt2.incoming_call() - ret = q.expect_many(EventPattern('dbus-signal', signal='NewChannels', + ret = q.expect_many(EventPattern('dbus-signal', signal='NewChannel', predicate=lambda e: - cs.CHANNEL_TYPE_CALL in e.args[0][0][1].values()), + cs.CHANNEL_TYPE_CALL in e.args[1].values()), EventPattern('dbus-signal', signal='NewMediaDescriptionOffer')) - chan = bus.get_object(conn.bus_name, ret[0].args[0][0][0]) + chan = bus.get_object(conn.bus_name, ret[0].args[0]) properties = chan.GetAll(cs.CHANNEL_TYPE_CALL, dbus_interface=dbus.PROPERTIES_IFACE) @@ -172,14 +172,14 @@ def test_outgoing(jp, q, bus, conn, stream): cs.CALL_INITIAL_VIDEO: False }, dbus_interface=cs.CONN_IFACE_REQUESTS) - ret = q.expect_many(EventPattern('dbus-signal', signal='NewChannels', + ret = q.expect_many(EventPattern('dbus-signal', signal='NewChannel', predicate=lambda e: - cs.CHANNEL_TYPE_CALL in e.args[0][0][1].values()), + cs.CHANNEL_TYPE_CALL in e.args[1].values()), # a codec offer appears already! EventPattern('dbus-signal', signal='NewMediaDescriptionOffer')) # all the basic stuff is already tested in call-basics.py - chan = bus.get_object(conn.bus_name, ret[0].args[0][0][0]) + chan = bus.get_object(conn.bus_name, ret[0].args[0]) # there is no remote codec information, so this should be empty assertEquals(ret[1].args[1][cs.CALL_CONTENT_MEDIA_DESCRIPTION + ".Codecs"], []) diff --git a/tests/twisted/jingle/call-muc.py b/tests/twisted/jingle/call-muc.py index f82c07eee..2d38ceb88 100644 --- a/tests/twisted/jingle/call-muc.py +++ b/tests/twisted/jingle/call-muc.py @@ -50,9 +50,9 @@ def run_incoming_test(q, bus, conn, stream, bob_leaves_room = False): stream.send(presence) e = q.expect ('dbus-signal', - signal='NewChannels', + signal='NewChannel', predicate=lambda e: \ - e.args[0][0][1][cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_CALL ) + e.args[1][cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_CALL ) (path, props) = e.args[0][0] diff --git a/tests/twisted/jingle/call_helper.py b/tests/twisted/jingle/call_helper.py index 5c65706e4..f1f9f1e99 100644 --- a/tests/twisted/jingle/call_helper.py +++ b/tests/twisted/jingle/call_helper.py @@ -286,12 +286,9 @@ class CallTest(object): cs.CALL_INITIAL_VIDEO: self.initial_video, }) - signal = self.q.expect('dbus-signal', signal='NewChannels') + signal = self.q.expect('dbus-signal', signal='NewChannel') - assertLength(1, signal.args) - assertLength(1, signal.args[0]) # one channel - assertLength(2, signal.args[0][0]) # two struct members - emitted_props = signal.args[0][0][1] + emitted_props = signal.args[1] assertEquals( cs.CHANNEL_TYPE_CALL, emitted_props[cs.CHANNEL_TYPE]) @@ -312,7 +309,7 @@ class CallTest(object): assertEquals(self.initial_audio, emitted_props[cs.CALL_INITIAL_AUDIO]) assertEquals(self.initial_video, emitted_props[cs.CALL_INITIAL_VIDEO]) - chan_path = signal.args[0][0][0] + chan_path = signal.args[0] self.chan = wrap_channel( self.bus.get_object(self.conn.bus_name, chan_path), 'Call') @@ -322,7 +319,7 @@ class CallTest(object): # Check if all the properties are there assertEquals(sorted([ "Contents", "CallMembers", "CallState", "CallFlags", "CallStateReason", "CallStateDetails", - "HardwareStreaming", "InitialAudio", "InitialAudioName", + "HardwareStreaming", "InitialAudio", "InitialAudioName", "InitialTones", "InitialVideo", "InitialVideoName", "MutableContents", "InitialTransport", "MemberIdentifiers" ]), sorted(properties.keys())) diff --git a/tests/twisted/jingle/session-id-collision.py b/tests/twisted/jingle/session-id-collision.py index b9815407b..8fe28d452 100644 --- a/tests/twisted/jingle/session-id-collision.py +++ b/tests/twisted/jingle/session-id-collision.py @@ -27,14 +27,14 @@ def test(jp, q, bus, conn, stream): jt2.sid = '1' jt1.incoming_call() - q.expect('dbus-signal', signal='NewChannels', - predicate=lambda e: cs.CHANNEL_TYPE_CALL in e.args[0][0][1][cs.CHANNEL_TYPE]) + q.expect('dbus-signal', signal='NewChannel', + predicate=lambda e: cs.CHANNEL_TYPE_CALL in e.args[1][cs.CHANNEL_TYPE]) # If Gabble confuses the two sessions, it'll NAK the IQ rather than # realising this is a new call. jt2.incoming_call() - q.expect('dbus-signal', signal='NewChannels', - predicate=lambda e: cs.CHANNEL_TYPE_CALL in e.args[0][0][1][cs.CHANNEL_TYPE]) + q.expect('dbus-signal', signal='NewChannel', + predicate=lambda e: cs.CHANNEL_TYPE_CALL in e.args[1][cs.CHANNEL_TYPE]) # On the other hand, if the same person calls twice with the same sid, # Gabble _should_ NAK the second s-i. diff --git a/tests/twisted/jingle/stun-server.py b/tests/twisted/jingle/stun-server.py index 6fb471174..f140f25d0 100644 --- a/tests/twisted/jingle/stun-server.py +++ b/tests/twisted/jingle/stun-server.py @@ -108,10 +108,9 @@ def test_call(jp, q, bus, conn, stream, assertLength(0, e.args) assertEquals(e.interface, cs.CALL_STREAM_IFACE_MEDIA) - e = q.expect('dbus-signal', signal='NewChannels') - assert e.args[0][0][0] + e = q.expect('dbus-signal', signal='NewChannel') - call_chan = make_channel_proxy(conn, e.args[0][0][0], 'Channel') + call_chan = make_channel_proxy(conn, e.args[0], 'Channel') # Exercise channel properties channel_props = call_chan.GetAll( diff --git a/tests/twisted/muc/only-text-when-needed.py b/tests/twisted/muc/only-text-when-needed.py index 744e47ef0..2e840d9b7 100644 --- a/tests/twisted/muc/only-text-when-needed.py +++ b/tests/twisted/muc/only-text-when-needed.py @@ -24,7 +24,7 @@ def stream_tube(q, bus, conn, stream, method, jid, presence=True): if presence: send_muc_presence(q, stream, jid) e, _ = q.expect_many(EventPattern('dbus-return', method=method), - EventPattern('dbus-signal', signal='NewChannels')) + EventPattern('dbus-signal', signal='NewChannel')) # sigh if method == 'EnsureChannel': @@ -48,7 +48,7 @@ def text_channel(q, bus, conn, stream, method, jid, presence=True): if presence: send_muc_presence(q, stream, jid) e, _ = q.expect_many(EventPattern('dbus-return', method=method), - EventPattern('dbus-signal', signal='NewChannels')) + EventPattern('dbus-signal', signal='NewChannel')) # sigh if method == 'EnsureChannel': @@ -110,16 +110,14 @@ def tube_no_text(q, bus, conn, stream): ret, new_sig = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), - EventPattern('dbus-signal', signal='NewChannels')) + EventPattern('dbus-signal', signal='NewChannel')) - q.forbid_events([EventPattern('dbus-signal', signal='NewChannels')]) + q.forbid_events([EventPattern('dbus-signal', signal='NewChannel')]) tube_path, tube_props = ret.value assertEquals(cs.CHANNEL_TYPE_STREAM_TUBE, tube_props[cs.CHANNEL_TYPE]) - channels = new_sig.args[0] - assertEquals(1, len(channels)) - path, props = channels[0] + path, props = new_sig.args assertEquals(tube_path, path) assertEquals(tube_props, props) @@ -144,11 +142,9 @@ def tube_then_text(q, bus, conn, stream): assertEquals(True, yours) assertEquals(cs.CHANNEL_TYPE_TEXT, text_props[cs.CHANNEL_TYPE]) - new_sig = q.expect('dbus-signal', signal='NewChannels') + new_sig = q.expect('dbus-signal', signal='NewChannel') - channels = new_sig.args[0] - assertEquals(1, len(channels)) - path, props = channels[0] + path, props = new_sig.args assertEquals(text_path, path) assertEquals(text_props, props) @@ -248,13 +244,10 @@ def recreate_text(q, bus, conn, stream): path, props = ret.value assertEquals(cs.CHANNEL_TYPE_TEXT, props[cs.CHANNEL_TYPE]) - new_sig = q.expect('dbus-signal', signal='NewChannels') + new_sig = q.expect('dbus-signal', signal='NewChannel') - channels = new_sig.args[0] - assertEquals(1, len(channels)) - - assertEquals(path, channels[0][0]) - assertEquals(props, channels[0][1]) + assertEquals(path, new_sig.args[0]) + assertEquals(props, new_sig.args[1]) # the channel should be identical given it's the same MucChannel assertEquals(text_path, path) @@ -304,10 +297,8 @@ def test_message(q, bus, conn, stream): ) # the text channel appears! - e = q.expect('dbus-signal', signal='NewChannels') - channels = e.args[0] - assertEquals(1, len(channels)) - path, props = channels[0] + e = q.expect('dbus-signal', signal='NewChannel') + path, props = e.args assertEquals(cs.CHANNEL_TYPE_TEXT, props[cs.CHANNEL_TYPE]) # make sure we didn't request it assertEquals(False, props[cs.REQUESTED]) @@ -356,10 +347,8 @@ def test_requested_message(q, bus, conn, stream): ) ) - e = q.expect('dbus-signal', signal='NewChannels') - channels = e.args[0] - assertEquals(1, len(channels)) - path, props = channels[0] + e = q.expect('dbus-signal', signal='NewChannel') + path, props = e.args assertEquals(cs.CHANNEL_TYPE_TEXT, props[cs.CHANNEL_TYPE]) # now make sure we didn't request it assertEquals(False, props[cs.REQUESTED]) diff --git a/tests/twisted/muc/password.py b/tests/twisted/muc/password.py index ee1ec3300..62cecf2c3 100644 --- a/tests/twisted/muc/password.py +++ b/tests/twisted/muc/password.py @@ -34,7 +34,7 @@ def test(q, bus, conn, stream): cc, _, _ = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), - EventPattern('dbus-signal', signal='NewChannels'), + EventPattern('dbus-signal', signal='NewChannel'), EventPattern('dbus-signal', signal='PasswordFlagsChanged', args=[cs.PASSWORD_FLAG_PROVIDE, 0])) diff --git a/tests/twisted/muc/roomlist.py b/tests/twisted/muc/roomlist.py index d16fc8987..00f5ddb06 100644 --- a/tests/twisted/muc/roomlist.py +++ b/tests/twisted/muc/roomlist.py @@ -34,6 +34,8 @@ def test(q, bus, conn, stream): properties = conn.Properties.GetAll(cs.CONN_IFACE_REQUESTS) assert properties.get('Channels') == [], properties['Channels'] + + properties = conn.Properties.GetAll(cs.CONN) assert ({ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_ROOM_LIST, cs.TARGET_HANDLE_TYPE: cs.HT_NONE, }, @@ -52,7 +54,7 @@ def test(q, bus, conn, stream): ret, sig = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), - EventPattern('dbus-signal', signal='NewChannels'), + EventPattern('dbus-signal', signal='NewChannel'), ) path2 = ret.value[0] chan = bus.get_object(conn.bus_name, path2) @@ -67,8 +69,8 @@ def test(q, bus, conn, stream): assertEquals('test@localhost', props[cs.INITIATOR_ID]) assertEquals('conference.example.net', props[cs.CHANNEL_TYPE_ROOM_LIST+ '.Server']) - assert sig.args[0][0][0] == path2 - assert sig.args[0][0][1] == props + assert sig.args[0] == path2 + assert sig.args[1] == props assert chan.Get(cs.CHANNEL_TYPE_ROOM_LIST, 'Server', dbus_interface=dbus.PROPERTIES_IFACE) == \ diff --git a/tests/twisted/muc/test-muc-invitation.py b/tests/twisted/muc/test-muc-invitation.py index ea3965a71..15b4abadc 100644 --- a/tests/twisted/muc/test-muc-invitation.py +++ b/tests/twisted/muc/test-muc-invitation.py @@ -21,8 +21,8 @@ def test(q, bus, conn, stream): stream.send(message) - event = q.expect('dbus-signal', signal='NewChannels') - path, props = event.args[0][0] + event = q.expect('dbus-signal', signal='NewChannel') + path, props = event.args assertEquals(cs.CHANNEL_TYPE_TEXT, props[cs.CHANNEL_TYPE]) assertEquals(cs.HT_ROOM, props[cs.TARGET_HANDLE_TYPE]) assertEquals(1, props[cs.TARGET_HANDLE]) diff --git a/tests/twisted/mucutil.py b/tests/twisted/mucutil.py index 8bb830b9e..36b6571ba 100644 --- a/tests/twisted/mucutil.py +++ b/tests/twisted/mucutil.py @@ -80,13 +80,13 @@ def join_muc(q, bus, conn, stream, muc, request=None, def join_muc_and_check(q, bus, conn, stream, muc, request=None): """ - Like join_muc(), but also checks the NewChannels and NewChannel signals and + Like join_muc(), but also checks the NewChannel signals and the Members property, and returns both members' handles. """ chan, path, props = \ join_muc(q, bus, conn, stream, muc, request=request) - q.expect('dbus-signal', signal='NewChannels', args=[[(path, props)]]) + q.expect('dbus-signal', signal='NewChannel', args=[path, props]) test_handle, bob_handle = conn.get_contact_handles_sync( ['%s/test' % muc, '%s/bob' % muc]) diff --git a/tests/twisted/plugin-channel-managers.py b/tests/twisted/plugin-channel-managers.py index 03668d733..7ae4a1d58 100644 --- a/tests/twisted/plugin-channel-managers.py +++ b/tests/twisted/plugin-channel-managers.py @@ -14,7 +14,7 @@ if not PLUGINS_ENABLED: raise SystemExit(77) # which makes the test show up as skipped def test(q, bus, conn, stream): - rccs = conn.Properties.Get(cs.CONN_IFACE_REQUESTS, + rccs = conn.Properties.Get(cs.CONN, 'RequestableChannelClasses') # These values are from plugins/test.c diff --git a/tests/twisted/power-save.py b/tests/twisted/power-save.py index 28861d5d5..b127849e5 100644 --- a/tests/twisted/power-save.py +++ b/tests/twisted/power-save.py @@ -117,7 +117,7 @@ def test_local_queueing(q, bus, conn, stream): event = q.expect('dbus-signal', signal='AliasesChanged') # .. and finally the message that flushed the stanza queue - q.expect('dbus-signal', signal='NewChannels') + q.expect('dbus-signal', signal='NewChannel') sync_stream(q, stream) diff --git a/tests/twisted/sasl/saslutil.py b/tests/twisted/sasl/saslutil.py index fcbd8f9e5..35a1d6f0e 100644 --- a/tests/twisted/sasl/saslutil.py +++ b/tests/twisted/sasl/saslutil.py @@ -89,14 +89,13 @@ def connect_and_get_sasl_channel(q, bus, conn): return expect_sasl_channel(q, bus, conn) def expect_sasl_channel(q, bus, conn): - new_signal = q.expect('dbus-signal', signal='NewChannels', - predicate=lambda e: e.args[0][0][1].get(cs.CHANNEL_TYPE) == + new_signal = q.expect('dbus-signal', signal='NewChannel', + predicate=lambda e: e.args[1].get(cs.CHANNEL_TYPE) == cs.CHANNEL_TYPE_SERVER_AUTHENTICATION) - path, props = new_signal.args[0][0] + path, props = new_signal.args chan = SaslChannelWrapper(bus.get_object(conn.bus_name, path)) - assertLength(1, new_signal.args[0]) assertEquals(cs.CHANNEL_IFACE_SASL_AUTH, props.get(cs.AUTH_METHOD)) return chan, props diff --git a/tests/twisted/search/search_helper.py b/tests/twisted/search/search_helper.py index d492d3980..3f9b201ef 100644 --- a/tests/twisted/search/search_helper.py +++ b/tests/twisted/search/search_helper.py @@ -32,7 +32,7 @@ def _send_server_reply(q, stream, result): stream.send(result) ret = q.expect('dbus-return', method='CreateChannel') - nc_sig = q.expect('dbus-signal', signal='NewChannels') + nc_sig = q.expect('dbus-signal', signal='NewChannel') return (ret, nc_sig) diff --git a/tests/twisted/test-debug.py b/tests/twisted/test-debug.py index 6c079a32c..7ea1bb082 100644 --- a/tests/twisted/test-debug.py +++ b/tests/twisted/test-debug.py @@ -50,7 +50,7 @@ def test(q, bus, conn, stream): cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT, cs.TARGET_HANDLE: conn.Properties.Get(cs.CONN, "SelfHandle") }) - q.expect('dbus-signal', signal='NewChannels') + q.expect('dbus-signal', signal='NewChannel') assertEquals (snapshot, messages) diff --git a/tests/twisted/test-fallback-socks5-proxy.py b/tests/twisted/test-fallback-socks5-proxy.py index 275352d43..e40ae1b17 100644 --- a/tests/twisted/test-fallback-socks5-proxy.py +++ b/tests/twisted/test-fallback-socks5-proxy.py @@ -127,20 +127,20 @@ def accept_stream_tube(q, bus, conn, stream): elem(ns.TUBES, 'tube', type='stream', service='http', id='10')) stream.send(message) - # we are interested in the 'NewChannels' announcing the tube channel + # we are interested in the 'NewChannel' announcing the tube channel 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 # Proxy queries are send when receiving an incoming stream tube new_chan, e1, e2 = q.expect_many( - EventPattern('dbus-signal', signal='NewChannels', predicate=new_chan_predicate), + EventPattern('dbus-signal', signal='NewChannel', predicate=new_chan_predicate), proxy_query_events[0], proxy_query_events[1]) send_socks5_reply(stream, e1.stanza) send_socks5_reply(stream, e2.stanza) - path, props = new_chan.args[0][0] + path, props = new_chan.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/text/destroy.py b/tests/twisted/text/destroy.py index b05037a56..64cca39d1 100644 --- a/tests/twisted/text/destroy.py +++ b/tests/twisted/text/destroy.py @@ -24,18 +24,15 @@ def test(q, bus, conn, stream): ret, new_sig = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), - EventPattern('dbus-signal', signal='NewChannels'), + EventPattern('dbus-signal', signal='NewChannel'), ) text_chan = wrap_channel(bus.get_object(conn.bus_name, ret.value[0]), 'Text') chan_iface = dbus.Interface(text_chan, cs.CHANNEL) destroyable_iface = dbus.Interface(text_chan, cs.CHANNEL_IFACE_DESTROYABLE) - assert len(new_sig.args) == 1 - assert len(new_sig.args[0]) == 1 # one channel - assert len(new_sig.args[0][0]) == 2 # two struct members - assert new_sig.args[0][0][0] == ret.value[0] - emitted_props = new_sig.args[0][0][1] + assert new_sig.args[0] == ret.value[0] + emitted_props = new_sig.args[1] assert emitted_props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT assert emitted_props[cs.TARGET_HANDLE_TYPE] == cs.HT_CONTACT assert emitted_props[cs.TARGET_HANDLE] == foo_handle diff --git a/tests/twisted/text/ensure.py b/tests/twisted/text/ensure.py index fcef90a69..7149940b8 100644 --- a/tests/twisted/text/ensure.py +++ b/tests/twisted/text/ensure.py @@ -5,7 +5,7 @@ Test text channel initiated by me, using Requests.EnsureChannel import dbus from gabbletest import exec_test -from servicetest import call_async, EventPattern +from servicetest import call_async, EventPattern, assertContains import constants as cs def test(q, bus, conn, stream): @@ -17,6 +17,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_TEXT, cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT, }, @@ -38,7 +41,7 @@ def test_ensure_ensure(q, conn, self_handle, jid, handle): ret, new_sig = q.expect_many( EventPattern('dbus-return', method='EnsureChannel'), - EventPattern('dbus-signal', signal='NewChannels'), + EventPattern('dbus-signal', signal='NewChannel'), ) assert len(ret.value) == 3 @@ -50,18 +53,13 @@ def test_ensure_ensure(q, conn, self_handle, jid, handle): check_props(emitted_props, self_handle, handle, jid) - assert len(new_sig.args) == 1 - assert len(new_sig.args[0]) == 1 # one channel - assert len(new_sig.args[0][0]) == 2 # two struct members - assert new_sig.args[0][0][0] == path - assert new_sig.args[0][0][1] == emitted_props + assert new_sig.args[0] == path + assert new_sig.args[1] == emitted_props properties = conn.GetAll( cs.CONN_IFACE_REQUESTS, dbus_interface=dbus.PROPERTIES_IFACE) - assert new_sig.args[0][0] in properties['Channels'], \ - (new_sig.args[0][0], properties['Channels']) - + assertContains((new_sig.args[0], new_sig.args[1]), properties['Channels']) # Now try Ensuring a channel which already exists call_async(q, conn.Requests, 'EnsureChannel', request_props(handle)) @@ -87,7 +85,7 @@ def test_request_ensure(q, conn, self_handle, jid, handle): ret, new_sig = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), - EventPattern('dbus-signal', signal='NewChannels'), + EventPattern('dbus-signal', signal='NewChannel'), ) assert len(ret.value) == 2 @@ -95,18 +93,13 @@ def test_request_ensure(q, conn, self_handle, jid, handle): check_props(emitted_props, self_handle, handle, jid) - assert len(new_sig.args) == 1 - assert len(new_sig.args[0]) == 1 # one channel - assert len(new_sig.args[0][0]) == 2 # two struct members - assert new_sig.args[0][0][0] == path - assert new_sig.args[0][0][1] == emitted_props + assert new_sig.args[0] == path + assert new_sig.args[1] == emitted_props properties = conn.GetAll( cs.CONN_IFACE_REQUESTS, dbus_interface=dbus.PROPERTIES_IFACE) - assert new_sig.args[0][0] in properties['Channels'], \ - (new_sig.args[0][0], properties['Channels']) - + assertContains((new_sig.args[0], new_sig.args[1]), properties['Channels']) # Now try Ensuring that same channel. call_async(q, conn.Requests, 'EnsureChannel', request_props(handle)) diff --git a/tests/twisted/text/initiate-requestotron.py b/tests/twisted/text/initiate-requestotron.py index c969eaac1..729486b47 100644 --- a/tests/twisted/text/initiate-requestotron.py +++ b/tests/twisted/text/initiate-requestotron.py @@ -18,6 +18,9 @@ def test(q, bus, conn, stream): properties = conn.GetAll( cs.CONN_IFACE_REQUESTS, dbus_interface=dbus.PROPERTIES_IFACE) assert properties.get('Channels') == [], properties['Channels'] + + properties = conn.GetAll( + cs.CONN, dbus_interface=dbus.PROPERTIES_IFACE) assert ({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT, }, @@ -33,7 +36,7 @@ def test(q, bus, conn, stream): ret, new_sig = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), - EventPattern('dbus-signal', signal='NewChannels'), + EventPattern('dbus-signal', signal='NewChannel'), ) assert len(ret.value) == 2 @@ -50,17 +53,13 @@ def test(q, bus, conn, stream): assertEquals(cs.DELIVERY_REPORTING_SUPPORT_FLAGS_RECEIVE_FAILURES, emitted_props[cs.DELIVERY_REPORTING_SUPPORT]) - assert len(new_sig.args) == 1 - assert len(new_sig.args[0]) == 1 # one channel - assert len(new_sig.args[0][0]) == 2 # two struct members - assert new_sig.args[0][0][0] == ret.value[0] - assert new_sig.args[0][0][1] == ret.value[1] + assert new_sig.args[0] == ret.value[0] + assert new_sig.args[1] == ret.value[1] properties = conn.GetAll( cs.CONN_IFACE_REQUESTS, dbus_interface=dbus.PROPERTIES_IFACE) - assert new_sig.args[0][0] in properties['Channels'], \ - (new_sig.args[0][0], properties['Channels']) + assertContains((new_sig.args[0], new_sig.args[1]), properties['Channels']) if __name__ == '__main__': exec_test(test) diff --git a/tests/twisted/text/initiate.py b/tests/twisted/text/initiate.py index 778dd6a58..92594c6de 100644 --- a/tests/twisted/text/initiate.py +++ b/tests/twisted/text/initiate.py @@ -23,12 +23,12 @@ def test(q, bus, conn, stream): ret, sig = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), - EventPattern('dbus-signal', signal='NewChannels'), + EventPattern('dbus-signal', signal='NewChannel'), ) text_chan = wrap_channel(bus.get_object(conn.bus_name, ret.value[0]), 'Text') - path, props = sig.args[0][0] + path, props = sig.args assertEquals(ret.value[0], path) assertEquals(cs.CHANNEL_TYPE_TEXT, props[cs.CHANNEL_TYPE]) # check that handle type == contact handle diff --git a/tests/twisted/text/respawn.py b/tests/twisted/text/respawn.py index 6998b2b7c..8ca081699 100644 --- a/tests/twisted/text/respawn.py +++ b/tests/twisted/text/respawn.py @@ -23,17 +23,14 @@ def test(q, bus, conn, stream): ret, new_sig = q.expect_many( EventPattern('dbus-return', method='CreateChannel'), - EventPattern('dbus-signal', signal='NewChannels'), + EventPattern('dbus-signal', signal='NewChannel'), ) text_chan = wrap_channel(bus.get_object(conn.bus_name, ret.value[0]), 'Text') chan_iface = dbus.Interface(text_chan, cs.CHANNEL) - assert len(new_sig.args) == 1 - assert len(new_sig.args[0]) == 1 # one channel - assert len(new_sig.args[0][0]) == 2 # two struct members - assert new_sig.args[0][0][0] == ret.value[0] - emitted_props = new_sig.args[0][0][1] + assert new_sig.args[0] == ret.value[0] + emitted_props = new_sig.args[1] assert emitted_props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT assert emitted_props[cs.TARGET_HANDLE_TYPE] == cs.HT_CONTACT assert emitted_props[cs.TARGET_HANDLE] == foo_handle @@ -92,8 +89,8 @@ def test(q, bus, conn, stream): assert new.args[0] == text_chan.object_path,\ (new.args[0], text_chan.object_path) - event = q.expect('dbus-signal', signal='NewChannels') - path, props = event.args[0][0] + event = q.expect('dbus-signal', signal='NewChannel') + path, props = event.args assertEquals(text_chan.object_path, path) assertEquals(cs.CHANNEL_TYPE_TEXT, props[cs.CHANNEL_TYPE]) assertEquals(cs.HT_CONTACT, props[cs.TARGET_HANDLE_TYPE]) diff --git a/tests/twisted/text/test-text-delayed.py b/tests/twisted/text/test-text-delayed.py index 605b2c148..480d40271 100644 --- a/tests/twisted/text/test-text-delayed.py +++ b/tests/twisted/text/test-text-delayed.py @@ -23,8 +23,8 @@ def test(q, bus, conn, stream): stream.send(m) - event = q.expect('dbus-signal', signal='NewChannels') - path, props = event.args[0][0] + event = q.expect('dbus-signal', signal='NewChannel') + path, props = event.args assertEquals(cs.CHANNEL_TYPE_TEXT, props[cs.CHANNEL_TYPE]) assertEquals(cs.HT_CONTACT, props[cs.TARGET_HANDLE_TYPE]) jid = conn.inspect_contact_sync(props[cs.TARGET_HANDLE]) diff --git a/tests/twisted/text/test-text-no-body.py b/tests/twisted/text/test-text-no-body.py index 34e54b7bb..ec70b77b4 100644 --- a/tests/twisted/text/test-text-no-body.py +++ b/tests/twisted/text/test-text-no-body.py @@ -28,8 +28,8 @@ def test(q, bus, conn, stream): stream.send(m) # first message should be from Bob, not Alice - event = q.expect('dbus-signal', signal='NewChannels') - path, props = event.args[0][0] + event = q.expect('dbus-signal', signal='NewChannel') + path, props = event.args assertEquals(cs.CHANNEL_TYPE_TEXT, props[cs.CHANNEL_TYPE]) jid = conn.inspect_contact_sync(props[cs.TARGET_HANDLE]) assertEquals('bob@foo.com', jid) diff --git a/tests/twisted/text/test-text.py b/tests/twisted/text/test-text.py index ff7bb1678..fc3c42b80 100644 --- a/tests/twisted/text/test-text.py +++ b/tests/twisted/text/test-text.py @@ -23,8 +23,8 @@ def test(q, bus, conn, stream): m.addElement('body', content='hello') stream.send(m) - event = q.expect('dbus-signal', signal='NewChannels') - path, props = event.args[0][0] + event = q.expect('dbus-signal', signal='NewChannel') + path, props = event.args text_chan = wrap_channel(bus.get_object(conn.bus_name, path), 'Text') assertEquals(cs.CHANNEL_TYPE_TEXT, props[cs.CHANNEL_TYPE]) assertEquals(cs.HT_CONTACT, props[cs.TARGET_HANDLE_TYPE]) diff --git a/tests/twisted/tls/server-tls-channel.py b/tests/twisted/tls/server-tls-channel.py index 6528e696d..fb2d2d85d 100644 --- a/tests/twisted/tls/server-tls-channel.py +++ b/tests/twisted/tls/server-tls-channel.py @@ -101,12 +101,7 @@ def test_disconnect_inbetween(q, bus, conn, stream): args=[cs.CONN_STATUS_DISCONNECTED, cs.CSR_REQUESTED]) def is_server_tls_chan_event(event): - channels = event.args[0]; - - if len(channels) > 1: - return False - - path, props = channels[0] + path, props = event.args return props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_SERVER_TLS_CONNECTION def connect_and_get_tls_objects(q, bus, conn, expect_example_jid=True): @@ -116,11 +111,10 @@ def connect_and_get_tls_objects(q, bus, conn, expect_example_jid=True): args=[cs.CONN_STATUS_CONNECTING, cs.CSR_REQUESTED]) ev, = q.expect_many( - EventPattern('dbus-signal', signal='NewChannels', + EventPattern('dbus-signal', signal='NewChannel', predicate=is_server_tls_chan_event)) - channels = ev.args[0] - path, props = channels[0] + path, props = ev.args chan = ServerTlsChanWrapper(bus.get_object(conn.bus_name, path)) hostname = props[cs.TLS_HOSTNAME] 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) |