telepathy-gabble: Avoid calling Group.GetSelfHandle()

Simon McVittie smcv at kemper.freedesktop.org
Mon Sep 23 02:38:40 PDT 2013


Module: telepathy-gabble
Branch: master
Commit: 5735643a1e823ae9b9b50d7b7089531e1f7c8924
URL:    http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=5735643a1e823ae9b9b50d7b7089531e1f7c8924

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Fri Sep 20 15:31:46 2013 +0100

Avoid calling Group.GetSelfHandle()

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69618
Reviewed-by: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>

---

 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 at 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 at localhost'
@@ -46,11 +46,11 @@ def test(q, bus, conn, stream):
             'chat at 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 at conf.localhost', channel_props
     assert channel_props['Requested'] == False
     assert channel_props['InitiatorID'] == 'bob at 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 at conf.localhost/test'),
@@ -97,7 +97,7 @@ def test(q, bus, conn, stream):
 
     # Test sending an invitation
     alice_handle = conn.RequestHandles(1, ['alice at 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 at 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 at 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 at 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 at 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 at conf.localhost/test',



More information about the telepathy-commits mailing list