From cc29113099a6e73efe3c8fca6188639f08727bdc Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 20 Sep 2013 15:31:46 +0100 Subject: [PATCH 03/10] Avoid calling Group.GetSelfHandle() --- tests/twisted/muc/kicked.py | 3 ++- tests/twisted/muc/test-muc-invitation.py | 22 +++++++++++----------- tests/twisted/muc/test-muc.py | 3 ++- tests/twisted/olpc/olpc-muc-invitation.py | 10 ++++++---- tests/twisted/olpc/olpc-muc-prop-change.py | 13 +++++++------ 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/tests/twisted/muc/kicked.py b/tests/twisted/muc/kicked.py index e326488..42c0f5d 100644 --- a/tests/twisted/muc/kicked.py +++ b/tests/twisted/muc/kicked.py @@ -15,7 +15,8 @@ MUC = 'deerhoof@evil.lit' def test(q, bus, conn, stream): # The user happily joins a MUC _, chan, _, _ = join_muc(q, bus, conn, stream, MUC) - muc_self_handle = chan.Group.GetSelfHandle() + muc_self_handle = chan.Properties.Get(cs.CHANNEL_IFACE_GROUP, + "SelfHandle") muc_self_jid, = conn.InspectHandles(cs.HT_CONTACT, [muc_self_handle]) # But then Bob kicks us. diff --git a/tests/twisted/muc/test-muc-invitation.py b/tests/twisted/muc/test-muc-invitation.py index e30c68d..797a439 100644 --- a/tests/twisted/muc/test-muc-invitation.py +++ b/tests/twisted/muc/test-muc-invitation.py @@ -7,7 +7,7 @@ import dbus from twisted.words.xish import domish, xpath from gabbletest import exec_test, make_muc_presence -from servicetest import call_async, EventPattern +from servicetest import call_async, EventPattern, wrap_channel import constants as cs def test(q, bus, conn, stream): @@ -30,12 +30,12 @@ def test(q, bus, conn, stream): assert event.args[3] == 1 # handle room_handle = 1 - text_chan = bus.get_object(conn.bus_name, event.args[0]) - group_iface = dbus.Interface(text_chan, cs.CHANNEL_IFACE_GROUP) + text_chan = wrap_channel(bus.get_object(conn.bus_name, event.args[0]), + 'Text') - members = group_iface.GetMembers() - local_pending = group_iface.GetLocalPendingMembers() - remote_pending = group_iface.GetRemotePendingMembers() + members = text_chan.Group.GetMembers() + local_pending = text_chan.Group.GetLocalPendingMembers() + remote_pending = text_chan.Group.GetRemotePendingMembers() assert len(members) == 1 assert conn.InspectHandles(1, members)[0] == 'bob@localhost' @@ -46,11 +46,11 @@ def test(q, bus, conn, stream): 'chat@conf.localhost/test' assert len(remote_pending) == 0 - room_self_handle = group_iface.GetSelfHandle() + room_self_handle = text_chan.Properties.Get(cs.CHANNEL_IFACE_GROUP, + "SelfHandle") assert room_self_handle == local_pending[0] - channel_props = text_chan.GetAll( - cs.CHANNEL, dbus_interface=dbus.PROPERTIES_IFACE) + channel_props = text_chan.Properties.GetAll(cs.CHANNEL) assert channel_props['TargetID'] == 'chat@conf.localhost', channel_props assert channel_props['Requested'] == False assert channel_props['InitiatorID'] == 'bob@localhost' @@ -62,7 +62,7 @@ def test(q, bus, conn, stream): conn.SimplePresence.SetPresence('available', 'success') # accept the invitation - call_async(q, group_iface, 'AddMembers', [room_self_handle], 'Oh, OK then') + call_async(q, text_chan.Group, 'AddMembers', [room_self_handle], 'Oh, OK then') event, event2, _ = q.expect_many( EventPattern('stream-presence', to='chat@conf.localhost/test'), @@ -97,7 +97,7 @@ def test(q, bus, conn, stream): # Test sending an invitation alice_handle = conn.RequestHandles(1, ['alice@localhost'])[0] - call_async(q, group_iface, 'AddMembers', [alice_handle], + call_async(q, text_chan.Group, 'AddMembers', [alice_handle], 'I want to test invitations') event = q.expect('stream-message', to='chat@conf.localhost') diff --git a/tests/twisted/muc/test-muc.py b/tests/twisted/muc/test-muc.py index 879996b..01f00a8 100644 --- a/tests/twisted/muc/test-muc.py +++ b/tests/twisted/muc/test-muc.py @@ -265,7 +265,8 @@ def test(q, bus, conn, stream): assert x_muc_nodes is None, elem.toXml() # test that leaving the channel results in an unavailable message - chan.Group.RemoveMembers([chan.Group.GetSelfHandle()], 'booo') + chan.Group.RemoveMembers([chan.Properties.Get(cs.CHANNEL_IFACE_GROUP, + "SelfHandle")], 'booo') event = q.expect('stream-presence', to='chat@conf.localhost/test') elem = event.stanza diff --git a/tests/twisted/olpc/olpc-muc-invitation.py b/tests/twisted/olpc/olpc-muc-invitation.py index 2c9ee92..d121bae 100644 --- a/tests/twisted/olpc/olpc-muc-invitation.py +++ b/tests/twisted/olpc/olpc-muc-invitation.py @@ -7,7 +7,7 @@ import dbus from twisted.words.xish import domish, xpath from gabbletest import exec_test, make_muc_presence -from servicetest import call_async, EventPattern +from servicetest import call_async, EventPattern, wrap_channel import constants as cs import ns @@ -79,8 +79,9 @@ def test(q, bus, conn, stream): assert event.args[2] == 2 # handle type assert event.args[3] == handles['chat'] # handle - text_chan = bus.get_object(conn.bus_name, event.args[0]) - group_iface = dbus.Interface(text_chan, cs.CHANNEL_IFACE_GROUP) + text_chan = wrap_channel(bus.get_object(conn.bus_name, event.args[0]), + 'Text') + group_iface = text_chan.Group members = group_iface.GetAllMembers()[0] local_pending = group_iface.GetAllMembers()[1] @@ -94,7 +95,8 @@ def test(q, bus, conn, stream): 'chat@conf.localhost/test' assert len(remote_pending) == 0 - handles['chat_self'] = group_iface.GetSelfHandle() + handles['chat_self'] = text_chan.Properties.Get(cs.CHANNEL_IFACE_GROUP, + "SelfHandle") assert handles['chat_self'] == local_pending[0] # by now, we should have picked up the extra activity properties diff --git a/tests/twisted/olpc/olpc-muc-prop-change.py b/tests/twisted/olpc/olpc-muc-prop-change.py index 8a20303..eb87a57 100644 --- a/tests/twisted/olpc/olpc-muc-prop-change.py +++ b/tests/twisted/olpc/olpc-muc-prop-change.py @@ -7,7 +7,7 @@ import dbus from twisted.words.xish import domish, xpath from gabbletest import exec_test, acknowledge_iq, make_muc_presence -from servicetest import call_async, EventPattern +from servicetest import call_async, EventPattern, wrap_channel import constants as cs import ns @@ -61,9 +61,9 @@ def test(q, bus, conn, stream): assert event.args[3] == 1 # handle room_handle = 1 - text_chan = bus.get_object(conn.bus_name, event.args[0]) - chan_iface = dbus.Interface(text_chan, cs.CHANNEL) - group_iface = dbus.Interface(text_chan, cs.CHANNEL_IFACE_GROUP) + text_chan = wrap_channel(bus.get_object(conn.bus_name, event.args[0]), + 'Text') + group_iface = text_chan.Group members = group_iface.GetAllMembers()[0] local_pending = group_iface.GetAllMembers()[1] @@ -78,7 +78,8 @@ def test(q, bus, conn, stream): 'chat@conf.localhost/test' assert len(remote_pending) == 0 - room_self_handle = group_iface.GetSelfHandle() + room_self_handle = text_chan.Properties.Get(cs.CHANNEL_IFACE_GROUP, + "SelfHandle") assert room_self_handle == local_pending[0] # by now, we should have picked up the extra activity properties @@ -359,7 +360,7 @@ def test(q, bus, conn, stream): q.expect('dbus-return', method='SetProperties') - chan_iface.Close() + text_chan.Close() # we must echo the MUC presence so the room will actually close event = q.expect('stream-presence', to='chat@conf.localhost/test', -- 1.8.4.rc3