summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2013-09-20 15:57:19 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-09-23 10:38:22 +0100
commit2c47cea7cb71a7bc7d1bc3d0b3c8548ab251eca8 (patch)
treeec8bbc5dd9bf9a4ab4a3b6c1e907a536dabe5846
parentbe26cb76591d3a6e9b25d51a631bb45e6c45b45f (diff)
Add inspect_contact_sync, inspect_contacts_sync and use in simple cases
Telepathy 1.0 doesn't have InspectHandles. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69618 Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
-rw-r--r--tests/twisted/file-transfer/file_transfer_helper.py2
-rw-r--r--tests/twisted/jingle-share/file_transfer_helper.py2
-rw-r--r--tests/twisted/jingle-share/test-caps-file-transfer.py4
-rw-r--r--tests/twisted/jingle-share/test-multift.py2
-rw-r--r--tests/twisted/muc/kicked.py2
-rw-r--r--tests/twisted/muc/scrollback.py3
-rw-r--r--tests/twisted/muc/test-ensure.py4
-rw-r--r--tests/twisted/muc/test-muc-invitation.py4
-rw-r--r--tests/twisted/olpc/olpc-muc-invitation.py4
-rw-r--r--tests/twisted/olpc/olpc-muc-prop-change.py4
-rw-r--r--tests/twisted/rostertest.py2
-rw-r--r--tests/twisted/servicetest.py13
-rw-r--r--tests/twisted/text/test-text-delayed.py2
-rw-r--r--tests/twisted/text/test-text-no-body.py2
-rw-r--r--tests/twisted/text/test-text.py2
-rw-r--r--tests/twisted/tubes/offer-muc-dbus-tube.py2
-rw-r--r--tests/twisted/tubes/offer-muc-stream-tube.py2
17 files changed, 33 insertions, 23 deletions
diff --git a/tests/twisted/file-transfer/file_transfer_helper.py b/tests/twisted/file-transfer/file_transfer_helper.py
index 3679c37cf..ae17fe2a3 100644
--- a/tests/twisted/file-transfer/file_transfer_helper.py
+++ b/tests/twisted/file-transfer/file_transfer_helper.py
@@ -89,7 +89,7 @@ class FileTransferTest(object):
announce_socks5_proxy(self.q, self.stream, disco_event.stanza)
self.self_handle = self.conn.Properties.Get(cs.CONN, "SelfHandle")
- self.self_handle_name = self.conn.InspectHandles(cs.HT_CONTACT, [self.self_handle])[0]
+ self.self_handle_name = self.conn.inspect_contact_sync(self.self_handle)
def announce_contact(self, name=CONTACT_NAME, metadata=True):
self.contact_name = name
diff --git a/tests/twisted/jingle-share/file_transfer_helper.py b/tests/twisted/jingle-share/file_transfer_helper.py
index 3e8b27477..8632ef2ef 100644
--- a/tests/twisted/jingle-share/file_transfer_helper.py
+++ b/tests/twisted/jingle-share/file_transfer_helper.py
@@ -78,7 +78,7 @@ class FileTransferTest(object):
path=self.conn.object.object_path)
self.self_handle = self.conn.Properties.Get(cs.CONN, "SelfHandle")
- self.self_handle_name = self.conn.InspectHandles(cs.HT_CONTACT, [self.self_handle])[0]
+ self.self_handle_name = self.conn.inspect_contact_sync(self.self_handle)
def set_target(self, jid):
self.target = jid
diff --git a/tests/twisted/jingle-share/test-caps-file-transfer.py b/tests/twisted/jingle-share/test-caps-file-transfer.py
index 0bf869a1a..4e6c32814 100644
--- a/tests/twisted/jingle-share/test-caps-file-transfer.py
+++ b/tests/twisted/jingle-share/test-caps-file-transfer.py
@@ -65,9 +65,9 @@ def test2(q, bus, connections, streams):
conn1, conn2 = connections
stream1, stream2 = streams
conn1_handle = conn1.Properties.Get(cs.CONN, 'SelfHandle')
- conn1_jid = conn1.InspectHandles(cs.HT_CONTACT, [conn1_handle])[0]
+ conn1_jid = conn1.inspect_contact_sync(conn1_handle)
conn2_handle = conn2.Properties.Get(cs.CONN, 'SelfHandle')
- conn2_jid = conn2.InspectHandles(cs.HT_CONTACT, [conn2_handle])[0]
+ conn2_jid = conn2.inspect_contact_sync(conn2_handle)
handle1 = conn2.RequestHandles(cs.HT_CONTACT, [conn1_jid])[0]
handle2 = conn1.RequestHandles(cs.HT_CONTACT, [conn2_jid])[0]
diff --git a/tests/twisted/jingle-share/test-multift.py b/tests/twisted/jingle-share/test-multift.py
index ac9f675aa..e84276789 100644
--- a/tests/twisted/jingle-share/test-multift.py
+++ b/tests/twisted/jingle-share/test-multift.py
@@ -26,7 +26,7 @@ def test(q, bus, conn, stream):
2L, client)
self_handle = conn.Properties.Get(cs.CONN, "SelfHandle")
- jid = conn.InspectHandles(cs.HT_CONTACT, [self_handle])[0]
+ jid = conn.inspect_contact_sync(self_handle)
iq = IQ(stream, "set")
iq['to'] = jid
diff --git a/tests/twisted/muc/kicked.py b/tests/twisted/muc/kicked.py
index 42c0f5d89..6049a6382 100644
--- a/tests/twisted/muc/kicked.py
+++ b/tests/twisted/muc/kicked.py
@@ -17,7 +17,7 @@ def test(q, bus, conn, stream):
_, chan, _, _ = join_muc(q, bus, conn, stream, MUC)
muc_self_handle = chan.Properties.Get(cs.CHANNEL_IFACE_GROUP,
"SelfHandle")
- muc_self_jid, = conn.InspectHandles(cs.HT_CONTACT, [muc_self_handle])
+ muc_self_jid = conn.inspect_contact_sync(muc_self_handle)
# But then Bob kicks us.
bob_jid = '%s/bob' % MUC
diff --git a/tests/twisted/muc/scrollback.py b/tests/twisted/muc/scrollback.py
index 607d3c6f8..095e5028c 100644
--- a/tests/twisted/muc/scrollback.py
+++ b/tests/twisted/muc/scrollback.py
@@ -74,8 +74,7 @@ def test(q, bus, conn, stream):
marco = badger(m3)
assertEquals([our_jid, bob_jid, marco_jid],
- conn.InspectHandles(cs.HT_CONTACT,
- [ me, bob, marco ]))
+ conn.inspect_contacts_sync([ me, bob, marco ]))
if __name__ == '__main__':
exec_test(test)
diff --git a/tests/twisted/muc/test-ensure.py b/tests/twisted/muc/test-ensure.py
index e03ae3567..f934d1477 100644
--- a/tests/twisted/muc/test-ensure.py
+++ b/tests/twisted/muc/test-ensure.py
@@ -57,7 +57,7 @@ def test_create_ensure(q, conn, bus, stream, room_jid, room_handle):
assert local_pending == [], mc.args
assert remote_pending == [], mc.args
- members = conn.InspectHandles(1, added)
+ members = conn.inspect_contacts_sync(added)
members.sort()
assert members == ['%s/bob' % room_jid, '%s/test' % room_jid], members
@@ -121,7 +121,7 @@ def test_ensure_ensure(q, conn, bus, stream, room_jid, room_handle):
assert local_pending == [], mc.args
assert remote_pending == [], mc.args
- members = conn.InspectHandles(1, added)
+ members = conn.inspect_contacts_sync(added)
members.sort()
assert members == ['%s/bob' % room_jid, '%s/test' % room_jid], members
diff --git a/tests/twisted/muc/test-muc-invitation.py b/tests/twisted/muc/test-muc-invitation.py
index 797a4395c..9e406ecae 100644
--- a/tests/twisted/muc/test-muc-invitation.py
+++ b/tests/twisted/muc/test-muc-invitation.py
@@ -38,11 +38,11 @@ def test(q, bus, conn, stream):
remote_pending = text_chan.Group.GetRemotePendingMembers()
assert len(members) == 1
- assert conn.InspectHandles(1, members)[0] == 'bob@localhost'
+ assert conn.inspect_contact_sync(members[0]) == 'bob@localhost'
bob_handle = members[0]
assert len(local_pending) == 1
# FIXME: the username-part-is-nickname assumption
- assert conn.InspectHandles(1, local_pending)[0] == \
+ assert conn.inspect_contact_sync(local_pending[0]) == \
'chat@conf.localhost/test'
assert len(remote_pending) == 0
diff --git a/tests/twisted/olpc/olpc-muc-invitation.py b/tests/twisted/olpc/olpc-muc-invitation.py
index d121bae46..c0ceb5c92 100644
--- a/tests/twisted/olpc/olpc-muc-invitation.py
+++ b/tests/twisted/olpc/olpc-muc-invitation.py
@@ -88,10 +88,10 @@ def test(q, bus, conn, stream):
remote_pending = group_iface.GetAllMembers()[2]
assert len(members) == 1
- assert conn.InspectHandles(1, members)[0] == 'bob@localhost'
+ assert conn.inspect_contact_sync(members[0]) == 'bob@localhost'
assert len(local_pending) == 1
# FIXME: the username-part-is-nickname assumption
- assert conn.InspectHandles(1, local_pending)[0] == \
+ assert conn.inspect_contact_sync(local_pending[0]) == \
'chat@conf.localhost/test'
assert len(remote_pending) == 0
diff --git a/tests/twisted/olpc/olpc-muc-prop-change.py b/tests/twisted/olpc/olpc-muc-prop-change.py
index eb87a57f7..bad9b150c 100644
--- a/tests/twisted/olpc/olpc-muc-prop-change.py
+++ b/tests/twisted/olpc/olpc-muc-prop-change.py
@@ -70,11 +70,11 @@ def test(q, bus, conn, stream):
remote_pending = group_iface.GetAllMembers()[2]
assert len(members) == 1
- assert conn.InspectHandles(1, members)[0] == 'bob@localhost'
+ assert conn.inspect_contact_sync(members[0]) == 'bob@localhost'
bob_handle = members[0]
assert len(local_pending) == 1
# FIXME: the username-part-is-nickname assumption
- assert conn.InspectHandles(1, local_pending)[0] == \
+ assert conn.inspect_contact_sync(local_pending[0]) == \
'chat@conf.localhost/test'
assert len(remote_pending) == 0
diff --git a/tests/twisted/rostertest.py b/tests/twisted/rostertest.py
index 7e9f121ab..fcbbc0fa7 100644
--- a/tests/twisted/rostertest.py
+++ b/tests/twisted/rostertest.py
@@ -130,7 +130,7 @@ def check_contact_list_signals(q, bus, conn, signals,
members = chan.Group.GetMembers()
assertEquals(sorted(contacts),
- sorted(conn.InspectHandles(cs.HT_CONTACT, members)))
+ sorted(conn.inspect_contacts_sync(members)))
lp_handles = conn.RequestHandles(cs.HT_CONTACT, lp_contacts)
rp_handles = conn.RequestHandles(cs.HT_CONTACT, rp_contacts)
diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py
index 894d00b09..f5f99dc26 100644
--- a/tests/twisted/servicetest.py
+++ b/tests/twisted/servicetest.py
@@ -457,8 +457,19 @@ class ProxyWrapper:
return getattr(self.default_interface, name)
+class ConnWrapper(ProxyWrapper):
+ def inspect_contact_sync(self, handle):
+ return self.inspect_contacts_sync([handle])[0]
+
+ def inspect_contacts_sync(self, handles):
+ h2asv = self.Contacts.GetContactAttributes(handles, [], True)
+ ret = []
+ for h in handles:
+ ret.append(h2asv[h][cs.ATTR_CONTACT_ID])
+ return ret
+
def wrap_connection(conn):
- return ProxyWrapper(conn, tp_name_prefix + '.Connection',
+ return ConnWrapper(conn, tp_name_prefix + '.Connection',
dict([
(name, tp_name_prefix + '.Connection.Interface.' + name)
for name in ['Aliasing', 'Avatars', 'Capabilities', 'Contacts',
diff --git a/tests/twisted/text/test-text-delayed.py b/tests/twisted/text/test-text-delayed.py
index 3818e06e2..b08f148c0 100644
--- a/tests/twisted/text/test-text-delayed.py
+++ b/tests/twisted/text/test-text-delayed.py
@@ -26,7 +26,7 @@ def test(q, bus, conn, stream):
event = q.expect('dbus-signal', signal='NewChannel')
assert event.args[1] == cs.CHANNEL_TYPE_TEXT
assert event.args[2] == cs.HT_CONTACT
- jid = conn.InspectHandles(cs.HT_CONTACT, [event.args[3]])[0]
+ jid = conn.inspect_contact_sync(event.args[3])
assert jid == 'foo@bar.com'
received, message_received = q.expect_many(
diff --git a/tests/twisted/text/test-text-no-body.py b/tests/twisted/text/test-text-no-body.py
index 2c4095f1c..62773dc97 100644
--- a/tests/twisted/text/test-text-no-body.py
+++ b/tests/twisted/text/test-text-no-body.py
@@ -29,7 +29,7 @@ def test(q, bus, conn, stream):
# first message should be from Bob, not Alice
event = q.expect('dbus-signal', signal='NewChannel')
assert event.args[1] == cs.CHANNEL_TYPE_TEXT
- jid = conn.InspectHandles(cs.HT_CONTACT, [event.args[3]])[0]
+ jid = conn.inspect_contact_sync(event.args[3])
assert jid == 'bob@foo.com'
if __name__ == '__main__':
diff --git a/tests/twisted/text/test-text.py b/tests/twisted/text/test-text.py
index e7a7ddfe0..a574d0cb1 100644
--- a/tests/twisted/text/test-text.py
+++ b/tests/twisted/text/test-text.py
@@ -31,7 +31,7 @@ def test(q, bus, conn, stream):
assert event.args[1] == cs.CHANNEL_TYPE_TEXT
assert event.args[2] == cs.HT_CONTACT
foo_at_bar_dot_com_handle = event.args[3]
- jid = conn.InspectHandles(1, [foo_at_bar_dot_com_handle])[0]
+ jid = conn.inspect_contact_sync(foo_at_bar_dot_com_handle)
assert jid == 'foo@bar.com'
assert event.args[4] == False # suppress handler
diff --git a/tests/twisted/tubes/offer-muc-dbus-tube.py b/tests/twisted/tubes/offer-muc-dbus-tube.py
index fa05c91d0..9fa66b423 100644
--- a/tests/twisted/tubes/offer-muc-dbus-tube.py
+++ b/tests/twisted/tubes/offer-muc-dbus-tube.py
@@ -115,7 +115,7 @@ def test(q, bus, conn, stream, access_control):
t.check_conn_properties(q, conn)
self_handle = conn.Properties.Get(cs.CONN, "SelfHandle")
- self_name = conn.InspectHandles(1, [self_handle])[0]
+ self_name = conn.inspect_contact_sync(self_handle)
# offer a D-Bus tube to another room using new API
muc = 'chat2@conf.localhost'
diff --git a/tests/twisted/tubes/offer-muc-stream-tube.py b/tests/twisted/tubes/offer-muc-stream-tube.py
index 2188e82a9..dfb876829 100644
--- a/tests/twisted/tubes/offer-muc-stream-tube.py
+++ b/tests/twisted/tubes/offer-muc-stream-tube.py
@@ -136,7 +136,7 @@ def test(q, bus, conn, stream, bytestream_cls,
EventPattern('dbus-signal', signal='TubeChannelStateChanged', args=[cs.TUBE_CHANNEL_STATE_OPEN]))
tube_self_handle = tube_chan.GetSelfHandle(dbus_interface=cs.CHANNEL_IFACE_GROUP)
- assert conn.InspectHandles(cs.HT_CONTACT, [tube_self_handle]) == ['chat@conf.localhost/test']
+ assert conn.inspect_contact_sync(tube_self_handle) == 'chat@conf.localhost/test'
presence = stream_event.stanza
tubes_nodes = xpath.queryForNodes('/presence/tubes[@xmlns="%s"]'