From 8504b03c98619deaea6042e2c2dfcd34a7390ffe Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 3 Oct 2013 15:11:05 +0200 Subject: [PATCH 6/8] join_muc: stop returning the muc handle --- tests/twisted/gabbletest.py | 5 ----- tests/twisted/muc/kicked.py | 2 +- tests/twisted/muc/presence-before-closing.py | 6 +++--- tests/twisted/muc/room-config.py | 8 ++++---- tests/twisted/muc/subject.py | 2 +- tests/twisted/mucutil.py | 12 +++++------- tests/twisted/tubes/test-socks5-muc.py | 2 +- tests/twisted/vcard/test-alias-message.py | 2 +- 8 files changed, 16 insertions(+), 23 deletions(-) diff --git a/tests/twisted/gabbletest.py b/tests/twisted/gabbletest.py index 11cf3d2..fe2ce66 100644 --- a/tests/twisted/gabbletest.py +++ b/tests/twisted/gabbletest.py @@ -57,11 +57,6 @@ def send_error_reply(stream, iq, error_stanza=None): stream.send(result) -def request_muc_handle(q, conn, stream, muc_jid): - servicetest.call_async(q, conn, 'RequestHandles', 2, [muc_jid]) - event = q.expect('dbus-return', method='RequestHandles') - return event.value[0][0] - def make_muc_presence(affiliation, role, muc_jid, alias, jid=None, photo=None): presence = domish.Element((None, 'presence')) presence['from'] = '%s/%s' % (muc_jid, alias) diff --git a/tests/twisted/muc/kicked.py b/tests/twisted/muc/kicked.py index 404dd49..307b96f 100644 --- a/tests/twisted/muc/kicked.py +++ b/tests/twisted/muc/kicked.py @@ -14,7 +14,7 @@ MUC = 'deerhoof@evil.lit' def test(q, bus, conn, stream): # The user happily joins a MUC - _, chan, _, _ = join_muc(q, bus, conn, stream, MUC) + chan, _, _ = join_muc(q, bus, conn, stream, MUC) muc_self_handle = chan.Properties.Get(cs.CHANNEL_IFACE_GROUP, "SelfHandle") muc_self_jid = conn.inspect_contact_sync(muc_self_handle) diff --git a/tests/twisted/muc/presence-before-closing.py b/tests/twisted/muc/presence-before-closing.py index 5ae7e27..f2f96e5 100644 --- a/tests/twisted/muc/presence-before-closing.py +++ b/tests/twisted/muc/presence-before-closing.py @@ -15,7 +15,7 @@ from mucutil import join_muc, echo_muc_presence def test(q, bus, conn, stream): room = 'test@conf.localhost' - room_handle, chan, path, props, disco = join_muc(q, bus, conn, stream, + chan, path, props, disco = join_muc(q, bus, conn, stream, room, also_capture=[EventPattern('stream-iq', iq_type='get', query_name='query', query_ns=ns.DISCO_INFO, to=room)]) @@ -52,7 +52,7 @@ def test(q, bus, conn, stream): # now that the channel has finally closed, let's try and request # it again which should succeed! - _, chan, _, _ = join_muc(q, bus, conn, stream, room) + chan, _, _ = join_muc(q, bus, conn, stream, room) # let's clear up though. chan.Close() @@ -64,7 +64,7 @@ def test(q, bus, conn, stream): def test_then_disconnect(q, bus, conn, stream): room = 'test@conf.localhost' - room_handle, chan, path, props, disco = join_muc(q, bus, conn, stream, + chan, path, props, disco = join_muc(q, bus, conn, stream, room, also_capture=[EventPattern('stream-iq', iq_type='get', query_name='query', query_ns=ns.DISCO_INFO, to=room)]) diff --git a/tests/twisted/muc/room-config.py b/tests/twisted/muc/room-config.py index 06a34ba..c7cfd92 100644 --- a/tests/twisted/muc/room-config.py +++ b/tests/twisted/muc/room-config.py @@ -118,7 +118,7 @@ def handle_disco_info_iq(stream, stanza): stream.send(iq) def test_some_stuff(q, bus, conn, stream): - _, text_chan, _, _, disco_iq, owner_iq, _ = join_muc(q, bus, conn, stream, + text_chan, _, _, disco_iq, owner_iq, _ = join_muc(q, bus, conn, stream, 'chat@conf.localhost', role='moderator', affiliation='owner', also_capture=[ EventPattern('stream-iq', to='chat@conf.localhost', iq_type='get', @@ -255,7 +255,7 @@ def test_role_changes(q, bus, conn, stream): # The test user joins a room. Bob is an owner (and moderator); the test # user starts out with no affiliation and the rĂ´le of participant. MUC = 'aoeu@snth' - _, chan, _, immutable_props, disco = join_muc(q, bus, conn, stream, + chan, _, immutable_props, disco = join_muc(q, bus, conn, stream, MUC, role='participant', also_capture=[ EventPattern('stream-iq', to=MUC, iq_type='get', @@ -331,7 +331,7 @@ def test_role_changes(q, bus, conn, stream): def test_broken_server(q, bus, conn, stream): MUC = 'bro@ken' - _, chan, _ , _ = join_muc(q, bus, conn, stream, MUC, affiliation='owner') + chan, _ , _ = join_muc(q, bus, conn, stream, MUC, affiliation='owner') owner_iq = q.expect('stream-iq', to=MUC, iq_type='get', query_ns=ns.MUC_OWNER) handle_muc_owner_get_iq(stream, owner_iq.stanza) @@ -350,7 +350,7 @@ def test_disconnect_during_update_configuration(q, bus, conn, stream): changes to be acked. """ def join_me_up_buttercup(muc): - _, chan, _, _ = join_muc(q, bus, conn, stream, muc, affiliation='owner') + chan, _, _ = join_muc(q, bus, conn, stream, muc, affiliation='owner') # Gabble grabs the owner configuration form to see whether it's # possible to change the room description. owner_iq = q.expect('stream-iq', to=muc, iq_type='get', diff --git a/tests/twisted/muc/subject.py b/tests/twisted/muc/subject.py index ccb457d..c323331 100644 --- a/tests/twisted/muc/subject.py +++ b/tests/twisted/muc/subject.py @@ -45,7 +45,7 @@ def test_subject(q, bus, conn, stream, change_subject, send_first, moderator): room = 'test@conf.localhost' - room_handle, chan, path, props, disco = join_muc(q, bus, conn, stream, + chan, path, props, disco = join_muc(q, bus, conn, stream, room, also_capture=[EventPattern('stream-iq', iq_type='get', query_name='query', query_ns=ns.DISCO_INFO, to=room)], diff --git a/tests/twisted/mucutil.py b/tests/twisted/mucutil.py index 1edd28c..96f3dfc 100644 --- a/tests/twisted/mucutil.py +++ b/tests/twisted/mucutil.py @@ -8,7 +8,7 @@ import dbus from twisted.words.xish import xpath from servicetest import call_async, wrap_channel, EventPattern, assertLength -from gabbletest import make_muc_presence, request_muc_handle +from gabbletest import make_muc_presence import constants as cs import ns @@ -56,11 +56,10 @@ def try_to_join_muc(q, bus, conn, stream, muc, request=None): def join_muc(q, bus, conn, stream, muc, request=None, also_capture=[], role='participant', affiliation='none'): """ - Joins 'muc', returning the muc's handle, a proxy object for the channel, + Joins 'muc', returning a proxy object for the channel, its path and its immutable properties just after the CreateChannel event has fired. The room contains one other member. """ - muc_handle = request_muc_handle(q, conn, stream, muc) try_to_join_muc(q, bus, conn, stream, muc, request=request) # Send presence for other member of room. @@ -76,19 +75,18 @@ def join_muc(q, bus, conn, stream, muc, request=None, chan = wrap_channel(bus.get_object(conn.bus_name, path), 'Text', ['Messages', 'Subject.DRAFT', 'RoomConfig1', 'ChatState']) - return (muc_handle, chan, path, props) + tuple(captured[1:]) + + return (chan, path, props) + tuple(captured[1:]) def join_muc_and_check(q, bus, conn, stream, muc, request=None): """ Like join_muc(), but also checks the NewChannels and NewChannel signals and the Members property, and returns both members' handles. """ - muc_handle, chan, path, props = \ + 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, cs.CHANNEL_TYPE_TEXT, cs.HT_ROOM, muc_handle, True]) test_handle, bob_handle = conn.get_contact_handles_sync( ['%s/test' % muc, '%s/bob' % muc]) diff --git a/tests/twisted/tubes/test-socks5-muc.py b/tests/twisted/tubes/test-socks5-muc.py index 4153801..54947ec 100644 --- a/tests/twisted/tubes/test-socks5-muc.py +++ b/tests/twisted/tubes/test-socks5-muc.py @@ -27,7 +27,7 @@ def test(q, bus, conn, stream): announce_socks5_proxy(q, stream, disco_event.stanza) - text_chan = join_muc(q, bus, conn, stream, 'chat@conf.localhost') + join_muc(q, bus, conn, stream, 'chat@conf.localhost') # bob offers a stream tube stream_tube_id = 1 diff --git a/tests/twisted/vcard/test-alias-message.py b/tests/twisted/vcard/test-alias-message.py index e925fda..c8a41c2 100644 --- a/tests/twisted/vcard/test-alias-message.py +++ b/tests/twisted/vcard/test-alias-message.py @@ -68,7 +68,7 @@ def test(q, bus, conn, stream): # make it explicit. Perhaps in future we might change this test to verify # that it doesn't "work". room_jid = 'clear-air-turbulence@culture.lit' - _, muc, _, _ = join_muc(q, bus, conn, stream, room_jid) + muc, _, _ = join_muc(q, bus, conn, stream, room_jid) bob_jid = room_jid + '/bob' bob_handle = conn.get_contact_handle_sync(bob_jid) -- 1.8.3.1