From 2b50093281b9f41477c3064a4b1b158c4bb65436 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 20 Sep 2013 16:53:57 +0100 Subject: [PATCH 10/10] Add get_contact_handle_sync, get_contact_handles_sync; use in simple cases Telepathy 1.0 doesn't have RequestHandles. --- tests/twisted/caps/caps-persistent-cache.py | 4 ++-- tests/twisted/caps/from-bare-jid.py | 2 +- tests/twisted/caps/jingle-caps.py | 2 +- tests/twisted/caps/offline.py | 2 +- tests/twisted/caps/receive-jingle.py | 2 +- tests/twisted/caps/tube-caps.py | 2 +- tests/twisted/caps_helper.py | 2 +- tests/twisted/client-types.py | 8 ++++---- tests/twisted/file-transfer/file_transfer_helper.py | 2 +- tests/twisted/file-transfer/ft-client-caps.py | 2 +- .../file-transfer/test-send-file-to-unknown-contact.py | 2 +- tests/twisted/jingle-share/file_transfer_helper.py | 2 +- tests/twisted/jingle-share/test-caps-file-transfer.py | 4 ++-- tests/twisted/jingle/call-codecoffer.py | 2 +- tests/twisted/jingle/call_helper.py | 2 +- tests/twisted/jingle/stun-server.py | 2 +- tests/twisted/muc/avatars.py | 2 +- tests/twisted/muc/kicked.py | 2 +- tests/twisted/muc/name-conflict.py | 2 +- tests/twisted/muc/only-text-when-needed.py | 4 ++-- tests/twisted/muc/renamed.py | 2 +- tests/twisted/muc/test-muc-invitation.py | 4 ++-- tests/twisted/mucutil.py | 2 +- tests/twisted/olpc/change-notifications.py | 2 +- tests/twisted/olpc/current-activity.py | 2 +- tests/twisted/olpc/olpc-muc-invitation.py | 5 ++--- tests/twisted/olpc/olpc-muc-prop-change.py | 2 +- tests/twisted/presence/decloak.py | 4 ++-- tests/twisted/presence/error.py | 2 +- tests/twisted/presence/initial-contact-presence.py | 2 +- tests/twisted/presence/presence.py | 2 +- tests/twisted/roster/authorize.py | 2 +- tests/twisted/roster/edit-before-roster.py | 2 +- tests/twisted/roster/groups.py | 2 +- tests/twisted/roster/initial-aliases.py | 4 ++-- tests/twisted/roster/push-without-id.py | 2 +- tests/twisted/roster/removed-from-rp-subscribe.py | 2 +- tests/twisted/roster/test-google-roster.py | 12 ++++++------ tests/twisted/roster/test-roster-item-deletion.py | 2 +- tests/twisted/roster/test-roster-subscribe.py | 2 +- tests/twisted/roster/test-roster.py | 2 +- tests/twisted/roster/test-save-alias-to-roster.py | 8 ++++---- tests/twisted/rostertest.py | 4 ++-- tests/twisted/servicetest.py | 6 ++++++ tests/twisted/test-location.py | 4 ++-- tests/twisted/text/destroy.py | 5 +---- tests/twisted/text/ensure.py | 5 +---- tests/twisted/text/initiate-requestotron.py | 2 +- tests/twisted/text/initiate.py | 5 +---- tests/twisted/text/respawn.py | 2 +- tests/twisted/text/send-error.py | 10 ++-------- tests/twisted/text/test-chat-state.py | 2 +- tests/twisted/tubes/accept-private-dbus-tube.py | 2 +- tests/twisted/tubes/ensure-si-tube.py | 2 +- tests/twisted/tubes/offer-muc-dbus-tube.py | 2 +- tests/twisted/tubes/offer-muc-stream-tube.py | 4 ++-- tests/twisted/tubes/offer-private-dbus-tube.py | 2 +- tests/twisted/tubes/offer-private-stream-tube.py | 2 +- tests/twisted/vcard/disconnect-during-pep.py | 2 +- tests/twisted/vcard/get-contact-info.py | 2 +- tests/twisted/vcard/refresh-contact-info.py | 2 +- tests/twisted/vcard/test-alias-empty-vcard.py | 2 +- tests/twisted/vcard/test-alias-message.py | 4 ++-- tests/twisted/vcard/test-alias-pep.py | 2 +- tests/twisted/vcard/test-alias.py | 2 +- tests/twisted/vcard/test-avatar-async.py | 8 ++++---- tests/twisted/vcard/test-avatar-retrieved.py | 2 +- tests/twisted/vcard/test-avatar-tokens.py | 2 +- tests/twisted/vcard/test-avatar.py | 2 +- 69 files changed, 100 insertions(+), 110 deletions(-) diff --git a/tests/twisted/caps/caps-persistent-cache.py b/tests/twisted/caps/caps-persistent-cache.py index c62f84e..b4725a8 100644 --- a/tests/twisted/caps/caps-persistent-cache.py +++ b/tests/twisted/caps/caps-persistent-cache.py @@ -53,7 +53,7 @@ def capabilities_changed(q, contact_handle): assertContains(xiangqi_tube_cap, e.args[0][contact_handle]) def test1(q, bus, conn, stream): - contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact_bare_jid])[0] + contact_handle = conn.get_contact_handle_sync(contact_bare_jid) send_presence(q, stream, contact_jid, 'client/pc//thane') handle_disco(q, stream, contact_jid, 'client/pc//thane') capabilities_changed(q, contact_handle) @@ -61,7 +61,7 @@ def test1(q, bus, conn, stream): def test2(q, bus, conn, stream): # The second time around, the capabilities are retrieved from the cache, # so no disco request is sent. - contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact_bare_jid])[0] + contact_handle = conn.get_contact_handle_sync(contact_bare_jid) send_presence(q, stream, contact_jid, 'client/pc//thane') capabilities_changed(q, contact_handle) diff --git a/tests/twisted/caps/from-bare-jid.py b/tests/twisted/caps/from-bare-jid.py index e56e022..122aaf6 100644 --- a/tests/twisted/caps/from-bare-jid.py +++ b/tests/twisted/caps/from-bare-jid.py @@ -23,7 +23,7 @@ def test(q, bus, conn, stream): client = 'http://example.com/perverse-client' contact_bare_jid = 'edgecase@example.com' contact_with_resource = 'edgecase@example.com/hi' - contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact_bare_jid])[0] + contact_handle = conn.get_contact_handle_sync(contact_bare_jid) # Gabble gets a presence stanza from a bare JID, which is a tad surprising. features = [ diff --git a/tests/twisted/caps/jingle-caps.py b/tests/twisted/caps/jingle-caps.py index 44bdaa2..692b60d 100644 --- a/tests/twisted/caps/jingle-caps.py +++ b/tests/twisted/caps/jingle-caps.py @@ -189,7 +189,7 @@ def test_google_caps(q, bus, conn, stream): 'ver': '1.1', 'ext': ' '.join(ext_set) } - handle = conn.RequestHandles(cs.HT_CONTACT, [jid])[0] + handle = conn.get_contact_handle_sync(jid) send_presence(q, conn, stream, jid, gcaps, initial=True) diff --git a/tests/twisted/caps/offline.py b/tests/twisted/caps/offline.py index 0d46055..f448c0e 100644 --- a/tests/twisted/caps/offline.py +++ b/tests/twisted/caps/offline.py @@ -26,7 +26,7 @@ def test(q, bus, conn, stream): q.expect('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]), - bob_handle = conn.RequestHandles(cs.HT_CONTACT, [jid])[0] + bob_handle = conn.get_contact_handle_sync(jid) # new ContactCapabilities ccaps_map = conn.ContactCapabilities.GetContactCapabilities([bob_handle]) diff --git a/tests/twisted/caps/receive-jingle.py b/tests/twisted/caps/receive-jingle.py index 80ceec7..90ee8e7 100644 --- a/tests/twisted/caps/receive-jingle.py +++ b/tests/twisted/caps/receive-jingle.py @@ -17,7 +17,7 @@ if not VOIP_ENABLED: raise SystemExit(77) def test(q, bus, conn, stream): - bob, = conn.RequestHandles(cs.HT_CONTACT, ['bob@foo.com']) + bob = conn.get_contact_handle_sync('bob@foo.com') presence = make_presence('bob@foo.com/Foo', status='hello') stream.send(presence) diff --git a/tests/twisted/caps/tube-caps.py b/tests/twisted/caps/tube-caps.py index 903b240..3a30168 100644 --- a/tests/twisted/caps/tube-caps.py +++ b/tests/twisted/caps/tube-caps.py @@ -144,7 +144,7 @@ def receive_caps(q, conn, stream, contact, contact_handle, features, assertSameElements(caps[contact_handle], caps_via_contacts_iface) def test_tube_caps_from_contact(q, bus, conn, stream, contact): - contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact])[0] + contact_handle = conn.get_contact_handle_sync(contact) # Check that we don't crash if we haven't seen any caps/presence for this # contact yet. diff --git a/tests/twisted/caps_helper.py b/tests/twisted/caps_helper.py index 7e71c55..c573b74 100644 --- a/tests/twisted/caps_helper.py +++ b/tests/twisted/caps_helper.py @@ -316,7 +316,7 @@ def presence_and_disco(q, conn, stream, contact, disco, return h def send_presence(q, conn, stream, contact, caps, initial=True, show=None): - h = conn.RequestHandles(cs.HT_CONTACT, [contact])[0] + h = conn.get_contact_handle_sync(contact) if initial: stream.send(make_presence(contact, status='hello')) diff --git a/tests/twisted/client-types.py b/tests/twisted/client-types.py index 2eaeebe..fd30adc 100644 --- a/tests/twisted/client-types.py +++ b/tests/twisted/client-types.py @@ -50,7 +50,7 @@ def build_stuff(identities): def contact_online(q, conn, stream, contact, identities, disco=True, dataforms={}, initial=True, show=None): (caps, client, types) = build_stuff(identities) - handle = conn.RequestHandles(cs.HT_CONTACT, [contact])[0] + handle = conn.get_contact_handle_sync(contact) # make contact come online presence_and_disco (q, conn, stream, contact, @@ -76,7 +76,7 @@ def test(q, bus, conn, stream): meredith_one = 'meredith@foo.com/One' meredith_two = 'meredith@foo.com/Two' meredith_three = 'meredith@foo.com/Three' - meredith_handle = conn.RequestHandles(cs.HT_CONTACT, [meredith_one])[0] + meredith_handle = conn.get_contact_handle_sync(meredith_one) # Meredith signs in from one resource contact_online(q, conn, stream, meredith_one, PC, show='chat') @@ -201,7 +201,7 @@ def test(q, bus, conn, stream): def test2(q, bus, conn, stream): marco_pidgin = 'marco@fancy.italian.restaurant/Pidgin' marco_phone = 'marco@fancy.italian.restaurant/N900' - handle = conn.RequestHandles(cs.HT_CONTACT, [marco_pidgin])[0] + handle = conn.get_contact_handle_sync(marco_pidgin) # pidgin comes online contact_online(q, conn, stream, marco_pidgin, PC) @@ -249,7 +249,7 @@ def two_contacts_with_the_same_hash(q, bus, conn, stream, bare_jids): contact1 += '/lol' contact2 += '/whut' - h1, h2 = conn.RequestHandles(cs.HT_CONTACT, [contact1, contact2]) + h1, h2 = conn.get_contact_handles_sync([contact1, contact2]) ver = compute_caps_hash(BANANAPHONE, features, {}) caps = { # Uniquify slightly with a stringified boolean ;-) diff --git a/tests/twisted/file-transfer/file_transfer_helper.py b/tests/twisted/file-transfer/file_transfer_helper.py index ae17fe2..42e1006 100644 --- a/tests/twisted/file-transfer/file_transfer_helper.py +++ b/tests/twisted/file-transfer/file_transfer_helper.py @@ -94,7 +94,7 @@ class FileTransferTest(object): def announce_contact(self, name=CONTACT_NAME, metadata=True): self.contact_name = name self.contact_full_jid = '%s/Telepathy' % name - self.handle = self.conn.RequestHandles(cs.HT_CONTACT, [name])[0] + self.handle = self.conn.get_contact_handle_sync(name) presence = domish.Element(('jabber:client', 'presence')) presence['from'] = self.contact_full_jid diff --git a/tests/twisted/file-transfer/ft-client-caps.py b/tests/twisted/file-transfer/ft-client-caps.py index fc327ac..59bdff3 100644 --- a/tests/twisted/file-transfer/ft-client-caps.py +++ b/tests/twisted/file-transfer/ft-client-caps.py @@ -119,7 +119,7 @@ def receive_caps(q, conn, stream, contact, contact_handle, features, assertSameElements(caps[contact_handle], caps_via_contacts_iface) def test_ft_caps_from_contact(q, bus, conn, stream, contact): - contact_handle = conn.RequestHandles(cs.HT_CONTACT, [contact])[0] + contact_handle = conn.get_contact_handle_sync(contact) # Check that we don't crash if we haven't seen any caps/presence for this # contact yet. diff --git a/tests/twisted/file-transfer/test-send-file-to-unknown-contact.py b/tests/twisted/file-transfer/test-send-file-to-unknown-contact.py index 17d0799..dc1d691 100644 --- a/tests/twisted/file-transfer/test-send-file-to-unknown-contact.py +++ b/tests/twisted/file-transfer/test-send-file-to-unknown-contact.py @@ -17,7 +17,7 @@ class SendFileTransferToUnknownContactTest(SendFileTest): def my_request_ft_channel(self): self.contact_name = 'jean@localhost' - self.handle = self.conn.RequestHandles(cs.HT_CONTACT, [self.contact_name])[0] + self.handle = self.conn.get_contact_handle_sync(self.contact_name) try: self.request_ft_channel() diff --git a/tests/twisted/jingle-share/file_transfer_helper.py b/tests/twisted/jingle-share/file_transfer_helper.py index 8632ef2..f396d8d 100644 --- a/tests/twisted/jingle-share/file_transfer_helper.py +++ b/tests/twisted/jingle-share/file_transfer_helper.py @@ -82,7 +82,7 @@ class FileTransferTest(object): def set_target(self, jid): self.target = jid - self.handle = self.conn.RequestHandles(cs.HT_CONTACT, [jid])[0] + self.handle = self.conn.get_contact_handle_sync(jid) def set_ft_caps(self): caps_iface = dbus.Interface(self.conn, cs.CONN_IFACE_CONTACT_CAPS) diff --git a/tests/twisted/jingle-share/test-caps-file-transfer.py b/tests/twisted/jingle-share/test-caps-file-transfer.py index 4e6c328..196be9d 100644 --- a/tests/twisted/jingle-share/test-caps-file-transfer.py +++ b/tests/twisted/jingle-share/test-caps-file-transfer.py @@ -68,8 +68,8 @@ def test2(q, bus, connections, streams): conn1_jid = conn1.inspect_contact_sync(conn1_handle) conn2_handle = conn2.Properties.Get(cs.CONN, 'SelfHandle') 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] + handle1 = conn2.get_contact_handle_sync(conn1_jid) + handle2 = conn1.get_contact_handle_sync(conn2_jid) q.expect_many(EventPattern('dbus-signal', signal='ContactCapabilitiesChanged', diff --git a/tests/twisted/jingle/call-codecoffer.py b/tests/twisted/jingle/call-codecoffer.py index 0353d9f..34a3a8a 100644 --- a/tests/twisted/jingle/call-codecoffer.py +++ b/tests/twisted/jingle/call-codecoffer.py @@ -77,7 +77,7 @@ def prepare_test(jp, q, bus, conn, stream): jt2.prepare() self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") - remote_handle = conn.RequestHandles(1, ["foo@bar.com/Foo"])[0] + remote_handle = conn.get_contact_handle_sync("foo@bar.com/Foo") # Advertise that we can do new style calls conn.ContactCapabilities.UpdateCapabilities([ diff --git a/tests/twisted/jingle/call_helper.py b/tests/twisted/jingle/call_helper.py index b9cc0e5..6554e04 100644 --- a/tests/twisted/jingle/call_helper.py +++ b/tests/twisted/jingle/call_helper.py @@ -57,7 +57,7 @@ class CallTest(object): self.can_change_direction = (jp.dialect not in ['gtalk-v0.3', 'gtalk-v0.4']) self.self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") - self.peer_handle = conn.RequestHandles(1, [self.PEER_JID])[0] + self.peer_handle = conn.get_contact_handle_sync(self.PEER_JID) def check_channel_state(self, state, wait = False): """Optionnally wait for channel state to be reached and check that the diff --git a/tests/twisted/jingle/stun-server.py b/tests/twisted/jingle/stun-server.py index 3631ea3..aa481c0 100644 --- a/tests/twisted/jingle/stun-server.py +++ b/tests/twisted/jingle/stun-server.py @@ -77,7 +77,7 @@ def init_test(jp, q, conn, stream, google=False, google_push_replacements=None): jt.send_presence_and_caps() - remote_handle = conn.RequestHandles(1, ["foo@bar.com/Foo"])[0] + remote_handle = conn.get_contact_handle_sync("foo@bar.com/Foo") return jt, remote_handle diff --git a/tests/twisted/muc/avatars.py b/tests/twisted/muc/avatars.py index 5e6f68c..f9a42e5 100644 --- a/tests/twisted/muc/avatars.py +++ b/tests/twisted/muc/avatars.py @@ -107,7 +107,7 @@ def test(q, bus, conn, stream): members = chan.Properties.Get(cs.CHANNEL_IFACE_GROUP, 'Members') assertLength(3, members) - fredrik, wendy, muc_self_handle = conn.RequestHandles(cs.HT_CONTACT, + fredrik, wendy, muc_self_handle = conn.get_contact_handles_sync( ['%s/%s' % (MUC, x) for x in ["fredrik", "wendy", "test"]]) known = conn.Avatars.GetKnownAvatarTokens(members) diff --git a/tests/twisted/muc/kicked.py b/tests/twisted/muc/kicked.py index 6049a63..404dd49 100644 --- a/tests/twisted/muc/kicked.py +++ b/tests/twisted/muc/kicked.py @@ -21,7 +21,7 @@ def test(q, bus, conn, stream): # But then Bob kicks us. bob_jid = '%s/bob' % MUC - bob_handle, = conn.RequestHandles(cs.HT_CONTACT, [bob_jid]) + bob_handle = conn.get_contact_handle_sync(bob_jid) stream.send( elem('presence', from_=muc_self_jid, type='unavailable')( elem(ns.MUC_USER, 'x')( diff --git a/tests/twisted/muc/name-conflict.py b/tests/twisted/muc/name-conflict.py index 01d9ca2..e476fd7 100644 --- a/tests/twisted/muc/name-conflict.py +++ b/tests/twisted/muc/name-conflict.py @@ -78,7 +78,7 @@ def test_join(q, bus, conn, stream, room_jid, transient_conflict): text_chan = wrap_channel(bus.get_object(conn.bus_name, path), 'Text') group_props = unwrap(text_chan.Properties.GetAll(cs.CHANNEL_IFACE_GROUP)) - t, t_ = conn.RequestHandles(cs.HT_CONTACT, [member, member_]) + t, t_ = conn.get_contact_handles_sync([member, member_]) # Check that Gabble think our nickname in the room is test_, not test muc_self_handle = group_props['SelfHandle'] diff --git a/tests/twisted/muc/only-text-when-needed.py b/tests/twisted/muc/only-text-when-needed.py index 260d26c..ef0bf2d 100644 --- a/tests/twisted/muc/only-text-when-needed.py +++ b/tests/twisted/muc/only-text-when-needed.py @@ -295,7 +295,7 @@ def test_message(q, bus, conn, stream): tube_chan, tube_path, _ = stream_tube(q, bus, conn, stream, 'CreateChannel', jid) bob_jid = '%s/bob' % jid - bob_handle = conn.RequestHandles(cs.HT_CONTACT, [bob_jid])[0] + bob_handle = conn.get_contact_handle_sync(bob_jid) # now let's send a message stream.send( @@ -337,7 +337,7 @@ def test_requested_message(q, bus, conn, stream): presence=False) bob_jid = '%s/bob' % jid - bob_handle = conn.RequestHandles(cs.HT_CONTACT, [bob_jid])[0] + bob_handle = conn.get_contact_handle_sync(bob_jid) # make sure it says we requested it props = text_chan.Properties.GetAll(cs.CHANNEL) diff --git a/tests/twisted/muc/renamed.py b/tests/twisted/muc/renamed.py index 215b7d6..c8f8f43 100644 --- a/tests/twisted/muc/renamed.py +++ b/tests/twisted/muc/renamed.py @@ -54,7 +54,7 @@ def test(q, bus, conn, stream): group_props = unwrap(text_chan.GetAll(CHANNEL_IFACE_GROUP, dbus_interface=dbus.PROPERTIES_IFACE)) - liz, toofer, expected_handle = conn.RequestHandles(HT_CONTACT, + liz, toofer, expected_handle = conn.get_contact_handles_sync( ["%s/%s" % (room_jid, m) for m in ['liz', 'toofer', 'test']]) # Check that Gabble think our nickname in the room is toofer not test diff --git a/tests/twisted/muc/test-muc-invitation.py b/tests/twisted/muc/test-muc-invitation.py index 9e406ec..5235751 100644 --- a/tests/twisted/muc/test-muc-invitation.py +++ b/tests/twisted/muc/test-muc-invitation.py @@ -92,11 +92,11 @@ def test(q, bus, conn, stream): event = q.expect('dbus-signal', signal='MembersChanged') - room_bob_handle = conn.RequestHandles(cs.HT_CONTACT, ['chat@conf.localhost/bob'])[0] + room_bob_handle = conn.get_contact_handle_sync('chat@conf.localhost/bob') assert event.args == ['', [room_self_handle, room_bob_handle], [], [], [], 0, 0] # Test sending an invitation - alice_handle = conn.RequestHandles(1, ['alice@localhost'])[0] + alice_handle = conn.get_contact_handle_sync('alice@localhost') call_async(q, text_chan.Group, 'AddMembers', [alice_handle], 'I want to test invitations') diff --git a/tests/twisted/mucutil.py b/tests/twisted/mucutil.py index 103b68b..cadbfcc 100644 --- a/tests/twisted/mucutil.py +++ b/tests/twisted/mucutil.py @@ -90,7 +90,7 @@ def join_muc_and_check(q, bus, conn, stream, muc, request=None): q.expect('dbus-signal', signal='NewChannel', args=[path, cs.CHANNEL_TYPE_TEXT, cs.HT_ROOM, muc_handle, True]) - test_handle, bob_handle = conn.RequestHandles(cs.HT_CONTACT, + test_handle, bob_handle = conn.get_contact_handles_sync( ['%s/test' % muc, '%s/bob' % muc]) members = chan.Get(cs.CHANNEL_IFACE_GROUP, 'Members', diff --git a/tests/twisted/olpc/change-notifications.py b/tests/twisted/olpc/change-notifications.py index 648ef5d..3b637df 100644 --- a/tests/twisted/olpc/change-notifications.py +++ b/tests/twisted/olpc/change-notifications.py @@ -19,7 +19,7 @@ def test(q, bus, conn, stream): handles = {} - handles['alice'] = conn.RequestHandles(1, ['alice@localhost'])[0] + handles['alice'] = conn.get_contact_handle_sync('alice@localhost') # Alice, one our friends changed her properties send_buddy_changed_properties_msg(stream, 'alice@localhost', diff --git a/tests/twisted/olpc/current-activity.py b/tests/twisted/olpc/current-activity.py index 0906f4a..3821102 100644 --- a/tests/twisted/olpc/current-activity.py +++ b/tests/twisted/olpc/current-activity.py @@ -24,7 +24,7 @@ def test(q, bus, conn, stream): handles = {} # Alice is one of our friend so we receive her PEP notifications - handles['alice'] = conn.RequestHandles(1, ['alice@localhost'])[0] + handles['alice'] = conn.get_contact_handle_sync('alice@localhost') # Try to get Alice's currrent-activity call_async(q, buddy_info_iface, "GetCurrentActivity", handles['alice']) diff --git a/tests/twisted/olpc/olpc-muc-invitation.py b/tests/twisted/olpc/olpc-muc-invitation.py index c0ceb5c..8307e29 100644 --- a/tests/twisted/olpc/olpc-muc-invitation.py +++ b/tests/twisted/olpc/olpc-muc-invitation.py @@ -13,7 +13,7 @@ import ns def test(q, bus, conn, stream): handles = {} - handles['bob'] = conn.RequestHandles(1, ['bob@localhost'])[0] + handles['bob'] = conn.get_contact_handle_sync('bob@localhost') buddy_iface = dbus.Interface(conn, 'org.laptop.Telepathy.BuddyInfo') act_prop_iface = dbus.Interface(conn, 'org.laptop.Telepathy.ActivityProperties') @@ -150,8 +150,7 @@ def test(q, bus, conn, stream): q.expect('dbus-return', method='SetProperties') # Test sending an invitation - handles['alice'] = conn.RequestHandles(1, - ['alice@localhost'])[0] + handles['alice'] = conn.get_contact_handle_sync('alice@localhost') call_async(q, group_iface, 'AddMembers', [handles['alice']], 'I want to test invitations') diff --git a/tests/twisted/olpc/olpc-muc-prop-change.py b/tests/twisted/olpc/olpc-muc-prop-change.py index bad9b15..d18788c 100644 --- a/tests/twisted/olpc/olpc-muc-prop-change.py +++ b/tests/twisted/olpc/olpc-muc-prop-change.py @@ -21,7 +21,7 @@ def test(q, bus, conn, stream): buddy_iface = dbus.Interface(conn, 'org.laptop.Telepathy.BuddyInfo') act_prop_iface = dbus.Interface(conn, 'org.laptop.Telepathy.ActivityProperties') - bob_handle = conn.RequestHandles(1, ['bob@localhost'])[0] + bob_handle = conn.get_contact_handle_sync('bob@localhost') # Bob invites us to a chatroom, pre-seeding properties message = domish.Element(('jabber:client', 'message')) diff --git a/tests/twisted/presence/decloak.py b/tests/twisted/presence/decloak.py index 235116c..541762d 100644 --- a/tests/twisted/presence/decloak.py +++ b/tests/twisted/presence/decloak.py @@ -21,7 +21,7 @@ def test(q, bus, conn, stream, should_decloak=False): worker(q, bus, conn, stream, should_decloak) # Trivial test for SendDirectedPresence() - bob_handle = conn.RequestHandles(1, ['bob@foo.com'])[0] + bob_handle = conn.get_contact_handle_sync('bob@foo.com') conn.SendDirectedPresence(bob_handle, False, dbus_interface=cs.CONN_IFACE_GABBLE_DECLOAK) q.expect('stream-presence', to='bob@foo.com') @@ -31,7 +31,7 @@ def worker(q, bus, conn, stream, should_decloak): 'DecloakAutomatically', dbus_interface=cs.PROPERTIES_IFACE) assertEquals(should_decloak, decloak_automatically) - amy_handle = conn.RequestHandles(1, ['amy@foo.com'])[0] + amy_handle = conn.get_contact_handle_sync('amy@foo.com') # Amy directs presence to us diff --git a/tests/twisted/presence/error.py b/tests/twisted/presence/error.py index 53f3703..33339e6 100644 --- a/tests/twisted/presence/error.py +++ b/tests/twisted/presence/error.py @@ -13,7 +13,7 @@ def test(q, bus, conn, stream): 'thehawk@unreachable.example.net', ] gregory, hawk = jids - gregory_handle, hawk_handle = conn.RequestHandles(cs.HT_CONTACT, jids) + gregory_handle, hawk_handle = conn.get_contact_handles_sync(jids) event = q.expect('stream-iq', query_ns=ns.ROSTER) event.stanza['type'] = 'result' diff --git a/tests/twisted/presence/initial-contact-presence.py b/tests/twisted/presence/initial-contact-presence.py index 881316c..c4cf28e 100644 --- a/tests/twisted/presence/initial-contact-presence.py +++ b/tests/twisted/presence/initial-contact-presence.py @@ -29,7 +29,7 @@ def make_roster_item(jid, subscription): def test(q, bus, conn, stream): event = q.expect('stream-iq', query_ns=ns.ROSTER) - amy, bob, che, dre, eve = conn.RequestHandles(cs.HT_CONTACT, + amy, bob, che, dre, eve = conn.get_contact_handles_sync( ['amy@foo.com', 'bob@foo.com', 'che@foo.com', 'dre@foo.com', 'eve@foo.com']) assertEquals({amy: UNKNOWN, diff --git a/tests/twisted/presence/presence.py b/tests/twisted/presence/presence.py index 2f1439b..8d35e28 100644 --- a/tests/twisted/presence/presence.py +++ b/tests/twisted/presence/presence.py @@ -12,7 +12,7 @@ import constants as cs def test(q, bus, conn, stream): event = q.expect('stream-iq', query_ns=ns.ROSTER) - amy_handle = conn.RequestHandles(1, ['amy@foo.com'])[0] + amy_handle = conn.get_contact_handle_sync('amy@foo.com') event.stanza['type'] = 'result' diff --git a/tests/twisted/roster/authorize.py b/tests/twisted/roster/authorize.py index 8d52435..f175bf5 100644 --- a/tests/twisted/roster/authorize.py +++ b/tests/twisted/roster/authorize.py @@ -27,7 +27,7 @@ def test(q, bus, conn, stream, modern=True, remove=False): event.stanza['type'] = 'result' stream.send(event.stanza) - holly, dave, arnold, kristine, cat = conn.RequestHandles(cs.HT_CONTACT, + holly, dave, arnold, kristine, cat = conn.get_contact_handles_sync( ['holly@example.com', 'dave@example.com', 'arnold@example.com', 'kristine@example.com', 'cat@example.com']) diff --git a/tests/twisted/roster/edit-before-roster.py b/tests/twisted/roster/edit-before-roster.py index cc0da22..44dd72f 100644 --- a/tests/twisted/roster/edit-before-roster.py +++ b/tests/twisted/roster/edit-before-roster.py @@ -30,7 +30,7 @@ def test(q, bus, conn, stream): item.addElement('group', content='men') # Before we get the roster, try to change something. It won't work. - amy, bob, che = conn.RequestHandles(cs.HT_CONTACT, + amy, bob, che = conn.get_contact_handles_sync( ['amy@foo.com', 'bob@foo.com', 'che@foo.com']) call_async(q, conn.ContactGroups, 'AddToGroup', 'Amy & Bob', [amy, bob]) diff --git a/tests/twisted/roster/groups.py b/tests/twisted/roster/groups.py index a0ba99b..614b930 100644 --- a/tests/twisted/roster/groups.py +++ b/tests/twisted/roster/groups.py @@ -77,7 +77,7 @@ def test(q, bus, conn, stream): predicate=lambda e: 'men' in e.args[1]), ]) - amy, bob, che = conn.RequestHandles(cs.HT_CONTACT, + amy, bob, che = conn.get_contact_handles_sync( ['amy@foo.com', 'bob@foo.com', 'che@foo.com']) assertEquals([[amy], ['women'], []], groups_changed[0].args) diff --git a/tests/twisted/roster/initial-aliases.py b/tests/twisted/roster/initial-aliases.py index d1aeb42..48a3676 100644 --- a/tests/twisted/roster/initial-aliases.py +++ b/tests/twisted/roster/initial-aliases.py @@ -45,8 +45,8 @@ def test(q, bus, conn, stream): event = q.expect('dbus-signal', signal='AliasesChanged') added = event.args[0] - bob_handle, alice_handle = conn.RequestHandles(cs.HT_CONTACT, - [bob_jid, alice_jid]) + bob_handle, alice_handle = conn.get_contact_handles_sync( + [bob_jid, alice_jid]) assertLength(2, added) assertContains((bob_handle, bob_alias), added) diff --git a/tests/twisted/roster/push-without-id.py b/tests/twisted/roster/push-without-id.py index ed373d3..3a7c6b7 100644 --- a/tests/twisted/roster/push-without-id.py +++ b/tests/twisted/roster/push-without-id.py @@ -29,7 +29,7 @@ def test(q, bus, conn, stream): del iq['id'] stream.send(iq) - h = conn.RequestHandles(cs.HT_CONTACT, [jid])[0] + h = conn.get_contact_handle_sync(jid) q.expect_many( EventPattern('dbus-signal', signal='MembersChanged', args=['', [h], [], [], [], 0, 0], path=stored.object_path), diff --git a/tests/twisted/roster/removed-from-rp-subscribe.py b/tests/twisted/roster/removed-from-rp-subscribe.py index a4e05ab..d6d3dea 100644 --- a/tests/twisted/roster/removed-from-rp-subscribe.py +++ b/tests/twisted/roster/removed-from-rp-subscribe.py @@ -31,7 +31,7 @@ def test(q, bus, conn, stream, remove, local, modern): assertLength(0, pairs) # i.e. we've checked all of them self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") - h = conn.RequestHandles(cs.HT_CONTACT, [jid])[0] + h = conn.get_contact_handle_sync(jid) # Another client logged into our account (Gajim, say) wants to subscribe to # Marco's presence. First, per RFC 3921 it 'SHOULD perform a "roster set" diff --git a/tests/twisted/roster/test-google-roster.py b/tests/twisted/roster/test-google-roster.py index e5fb3f3..a7bedbe 100644 --- a/tests/twisted/roster/test-google-roster.py +++ b/tests/twisted/roster/test-google-roster.py @@ -138,7 +138,7 @@ def test_flickering(q, bus, conn, stream, subscribe): self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") contact = 'bob@foo.com' - handle = conn.RequestHandles(cs.HT_CONTACT, ['bob@foo.com'])[0] + handle = conn.get_contact_handle_sync('bob@foo.com') # request subscription call_async(q, subscribe.Group, 'AddMembers', [handle], "") @@ -274,7 +274,7 @@ def test_local_pending(q, bus, conn, stream, subscribe): """ contact = 'alice@foo.com' - handle = conn.RequestHandles(cs.HT_CONTACT, [contact])[0] + handle = conn.get_contact_handle_sync(contact) # Alice asks to subscribes to us presence = domish.Element(('jabber:client', 'presence')) @@ -350,7 +350,7 @@ def test_deny_simple(q, bus, conn, stream, stored, deny): remaining on 'deny'. """ contact = 'blocked-but-subscribed@boards.ca' - handle = conn.RequestHandles(cs.HT_CONTACT, [contact])[0] + handle = conn.get_contact_handle_sync(contact) assertContains(handle, stored.Properties.Get(cs.CHANNEL_IFACE_GROUP, "Members")) call_async(q, stored.Group, 'RemoveMembers', [handle], "") @@ -398,7 +398,7 @@ def test_deny_overlap_one(q, bus, conn, stream, subscribe, stored, deny): # As we saw in test_flickering(), we have a subscription to Bob, # everything's peachy. contact = 'bob@foo.com' - handle = conn.RequestHandles(cs.HT_CONTACT, ['bob@foo.com'])[0] + handle = conn.get_contact_handle_sync(contact) assertContains(handle, stored.Properties.Get(cs.CHANNEL_IFACE_GROUP, "Members")) @@ -475,7 +475,7 @@ def test_deny_overlap_two(q, bus, conn, stream, # This contact was on our roster when we started. contact = 'lp-bug-398293@gmail.com' - handle = conn.RequestHandles(cs.HT_CONTACT, [contact])[0] + handle = conn.get_contact_handle_sync(contact) assertContains(handle, stored.Properties.Get(cs.CHANNEL_IFACE_GROUP, "Members")) @@ -533,7 +533,7 @@ def test_deny_unblock_remove(q, bus, conn, stream, stored, deny): # This contact was on our roster, blocked and subscribed, when we started. contact = 'music-is-math@boards.ca' - handle = conn.RequestHandles(cs.HT_CONTACT, [contact])[0] + handle = conn.get_contact_handle_sync(contact) # They're blocked, and we have a bidi subscription, so they should be on # deny and stored. (We already checked this earlier, but we've been messing diff --git a/tests/twisted/roster/test-roster-item-deletion.py b/tests/twisted/roster/test-roster-item-deletion.py index 0274468..7b2d091 100644 --- a/tests/twisted/roster/test-roster-item-deletion.py +++ b/tests/twisted/roster/test-roster-item-deletion.py @@ -29,7 +29,7 @@ def test(q, bus, conn, stream, modern=True, queued=False): item['jid'] = 'quux@foo.com' item['subscription'] = 'none' - quux_handle = conn.RequestHandles(cs.HT_CONTACT, ['quux@foo.com'])[0] + quux_handle = conn.get_contact_handle_sync('quux@foo.com') stream.send(event.stanza) diff --git a/tests/twisted/roster/test-roster-subscribe.py b/tests/twisted/roster/test-roster-subscribe.py index 23979d3..a28aafe 100644 --- a/tests/twisted/roster/test-roster-subscribe.py +++ b/tests/twisted/roster/test-roster-subscribe.py @@ -78,7 +78,7 @@ def test(q, bus, conn, stream, modern=True, remove=False, remote='accept'): 'ContactList') # request subscription - alice, bob = conn.RequestHandles(cs.HT_CONTACT, + alice, bob = conn.get_contact_handles_sync( ['alice@foo.com', 'bob@foo.com']) # Repeated subscription requests are *not* idempotent: the second request diff --git a/tests/twisted/roster/test-roster.py b/tests/twisted/roster/test-roster.py index 04fee09..28d46b3 100644 --- a/tests/twisted/roster/test-roster.py +++ b/tests/twisted/roster/test-roster.py @@ -42,7 +42,7 @@ def test(q, bus, conn, stream): s = q.expect('dbus-signal', signal='ContactsChanged', interface=cs.CONN_IFACE_CONTACT_LIST, path=conn.object_path) - amy, bob, che = conn.RequestHandles(cs.HT_CONTACT, + amy, bob, che = conn.get_contact_handles_sync( ['amy@foo.com', 'bob@foo.com', 'che@foo.com']) assertEquals([{ diff --git a/tests/twisted/roster/test-save-alias-to-roster.py b/tests/twisted/roster/test-save-alias-to-roster.py index 2164915..83aa3ca 100644 --- a/tests/twisted/roster/test-save-alias-to-roster.py +++ b/tests/twisted/roster/test-save-alias-to-roster.py @@ -60,7 +60,7 @@ def test(q, bus, conn, stream): chan = bus.get_object(conn.bus_name, path) group_iface = dbus.Interface(chan, cs.CHANNEL_IFACE_GROUP) assert group_iface.GetMembers() == [] - handle = conn.RequestHandles(1, ['bob@foo.com'])[0] + handle = conn.get_contact_handle_sync('bob@foo.com') call_async(q, group_iface, 'AddMembers', [handle], '') event = q.expect('stream-iq', iq_type='set', query_ns=ns.ROSTER) @@ -88,7 +88,7 @@ def test(q, bus, conn, stream): # the current semantics where the alias is always meant to be something you # could show, even if it's just their JID), so let's forbid that. jid = 'parts@labor.lit' - handle = conn.RequestHandles(cs.HT_CONTACT, [jid])[0] + handle = conn.get_contact_handle_sync(jid) q.forbid_events([EventPattern('dbus-signal', signal='AliasesChanged', args=[[(handle, '')]])]) @@ -110,7 +110,7 @@ def test(q, bus, conn, stream): # because we've cached that they have no alias. Gabble shouldn't make # unsolicited PEP or vCard queries to them. jid = 'friendly@faith.plate' - handle = conn.RequestHandles(cs.HT_CONTACT, [jid])[0] + handle = conn.get_contact_handle_sync(jid) q.forbid_events([ EventPattern('stream-iq', query_ns=ns.PUBSUB, to=jid), @@ -148,7 +148,7 @@ def test(q, bus, conn, stream): # Here's a contact we haven't seen before, pushed to our roster with a # nickname already there. jid = 'glados@aperture.lit' - handle = conn.RequestHandles(cs.HT_CONTACT, [jid])[0] + handle = conn.get_contact_handle_sync(jid) nick = 'Potato' send_roster_push(stream, jid, 'both', name=nick) diff --git a/tests/twisted/rostertest.py b/tests/twisted/rostertest.py index fcbbc0f..d861962 100644 --- a/tests/twisted/rostertest.py +++ b/tests/twisted/rostertest.py @@ -132,8 +132,8 @@ def check_contact_list_signals(q, bus, conn, signals, assertEquals(sorted(contacts), sorted(conn.inspect_contacts_sync(members))) - lp_handles = conn.RequestHandles(cs.HT_CONTACT, lp_contacts) - rp_handles = conn.RequestHandles(cs.HT_CONTACT, rp_contacts) + lp_handles = conn.get_contact_handles_sync(lp_contacts) + rp_handles = conn.get_contact_handles_sync(rp_contacts) # NB. comma: we're unpacking args. Thython! info, = new_signal.args diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py index f5f99dc..ab606fc 100644 --- a/tests/twisted/servicetest.py +++ b/tests/twisted/servicetest.py @@ -468,6 +468,12 @@ class ConnWrapper(ProxyWrapper): ret.append(h2asv[h][cs.ATTR_CONTACT_ID]) return ret + def get_contact_handle_sync(self, identifier): + return self.Contacts.GetContactByID(identifier, [])[0] + + def get_contact_handles_sync(self, ids): + return [self.get_contact_handle_sync(i) for i in ids] + def wrap_connection(conn): return ConnWrapper(conn, tp_name_prefix + '.Connection', dict([ diff --git a/tests/twisted/test-location.py b/tests/twisted/test-location.py index cb18173..92c5941 100644 --- a/tests/twisted/test-location.py +++ b/tests/twisted/test-location.py @@ -158,7 +158,7 @@ def test(q, bus, conn, stream): q.expect('dbus-error', method='SetLocation') # Request Bob's location - bob_handle = conn.RequestHandles(1, ['bob@foo.com'])[0] + bob_handle = conn.get_contact_handle_sync('bob@foo.com') call_async(q, conn.Location, 'GetLocations', [bob_handle]) # Gabble should not send a pubsub query. The point of PEP is that we don't @@ -214,7 +214,7 @@ def test(q, bus, conn, stream): assertLength(1, locations) assertEquals(locations[bob_handle], location) - charles_handle = conn.RequestHandles(cs.HT_CONTACT, ['charles@foo.com'])[0] + charles_handle = conn.get_contact_handle_sync('charles@foo.com') # check that Contacts interface supports location attributes = conn.Contacts.GetContactAttributes( diff --git a/tests/twisted/text/destroy.py b/tests/twisted/text/destroy.py index 8c8c059..21510c4 100644 --- a/tests/twisted/text/destroy.py +++ b/tests/twisted/text/destroy.py @@ -15,10 +15,7 @@ def test(q, bus, conn, stream): self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") jid = 'foo@bar.com' - call_async(q, conn, 'RequestHandles', 1, [jid]) - - event = q.expect('dbus-return', method='RequestHandles') - foo_handle = event.value[0][0] + foo_handle = conn.get_contact_handle_sync(jid) call_async(q, conn, 'RequestChannel', cs.CHANNEL_TYPE_TEXT, cs.HT_CONTACT, foo_handle, True) diff --git a/tests/twisted/text/ensure.py b/tests/twisted/text/ensure.py index 438a0c1..9cd017f 100644 --- a/tests/twisted/text/ensure.py +++ b/tests/twisted/text/ensure.py @@ -12,10 +12,7 @@ def test(q, bus, conn, stream): self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") jids = ['foo@bar.com', 'truc@cafe.fr'] - call_async(q, conn, 'RequestHandles', 1, jids) - - event = q.expect('dbus-return', method='RequestHandles') - handles = event.value[0] + handles = conn.get_contact_handles_sync(jids) properties = conn.GetAll( cs.CONN_IFACE_REQUESTS, dbus_interface=cs.PROPERTIES_IFACE) diff --git a/tests/twisted/text/initiate-requestotron.py b/tests/twisted/text/initiate-requestotron.py index d23ad07..da2184d 100644 --- a/tests/twisted/text/initiate-requestotron.py +++ b/tests/twisted/text/initiate-requestotron.py @@ -13,7 +13,7 @@ def test(q, bus, conn, stream): self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") jid = 'foo@bar.com' - foo_handle = conn.RequestHandles(cs.HT_CONTACT, [jid])[0] + foo_handle = conn.get_contact_handle_sync(jid) properties = conn.GetAll( cs.CONN_IFACE_REQUESTS, dbus_interface=dbus.PROPERTIES_IFACE) diff --git a/tests/twisted/text/initiate.py b/tests/twisted/text/initiate.py index 9e817a6..5fed9e9 100644 --- a/tests/twisted/text/initiate.py +++ b/tests/twisted/text/initiate.py @@ -14,10 +14,7 @@ def test(q, bus, conn, stream): self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") jid = 'foo@bar.com' - call_async(q, conn, 'RequestHandles', cs.HT_CONTACT, [jid]) - - event = q.expect('dbus-return', method='RequestHandles') - foo_handle = event.value[0][0] + foo_handle = conn.get_contact_handle_sync(jid) call_async(q, conn, 'RequestChannel', cs.CHANNEL_TYPE_TEXT, cs.HT_CONTACT, foo_handle, True) diff --git a/tests/twisted/text/respawn.py b/tests/twisted/text/respawn.py index 5a43b14..9fba707 100644 --- a/tests/twisted/text/respawn.py +++ b/tests/twisted/text/respawn.py @@ -14,7 +14,7 @@ def test(q, bus, conn, stream): self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") jid = 'foo@bar.com' - foo_handle = conn.RequestHandles(cs.HT_CONTACT, [jid])[0] + foo_handle = conn.get_contact_handle_sync(jid) call_async(q, conn, 'RequestChannel', cs.CHANNEL_TYPE_TEXT, cs.HT_CONTACT, foo_handle, True) diff --git a/tests/twisted/text/send-error.py b/tests/twisted/text/send-error.py index 8a0f786..1844421 100644 --- a/tests/twisted/text/send-error.py +++ b/tests/twisted/text/send-error.py @@ -14,10 +14,7 @@ def test_temporary_error(q, bus, conn, stream): self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") jid = 'foo@bar.com' - call_async(q, conn, 'RequestHandles', 1, [jid]) - - event = q.expect('dbus-return', method='RequestHandles') - foo_handle = event.value[0][0] + foo_handle = conn.get_contact_handle_sync(jid) path = conn.Requests.CreateChannel( { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, @@ -95,10 +92,7 @@ def test_permanent_error(q, bus, conn, stream): self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") jid = 'wee@ninja.jp' - call_async(q, conn, 'RequestHandles', 1, [jid]) - - event = q.expect('dbus-return', method='RequestHandles') - ninja_handle = event.value[0][0] + ninja_handle = conn.get_contact_handle_sync(jid) path = conn.Requests.CreateChannel( { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, diff --git a/tests/twisted/text/test-chat-state.py b/tests/twisted/text/test-chat-state.py index 8d54658..49813a9 100644 --- a/tests/twisted/text/test-chat-state.py +++ b/tests/twisted/text/test-chat-state.py @@ -42,7 +42,7 @@ def test(q, bus, conn, stream): jid = 'foo@bar.com' full_jid = 'foo@bar.com/Foo' - foo_handle = conn.RequestHandles(cs.HT_CONTACT, [jid])[0] + foo_handle = conn.get_contact_handle_sync(jid) path = conn.Requests.CreateChannel( { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT, diff --git a/tests/twisted/tubes/accept-private-dbus-tube.py b/tests/twisted/tubes/accept-private-dbus-tube.py index 8122dac..fb81cb6 100644 --- a/tests/twisted/tubes/accept-private-dbus-tube.py +++ b/tests/twisted/tubes/accept-private-dbus-tube.py @@ -81,7 +81,7 @@ def test(q, bus, conn, stream, bytestream_cls, access_control): # RequestChannel are the ones we wanted. sync_dbus(bus, q, conn) - bob_handle = conn.RequestHandles(cs.HT_CONTACT, ['bob@localhost'])[0] + bob_handle = conn.get_contact_handle_sync('bob@localhost') # let's try to accept a D-Bus tube using the new API bytestream = bytestream_cls(stream, q, 'gamma', bob_full_jid, diff --git a/tests/twisted/tubes/ensure-si-tube.py b/tests/twisted/tubes/ensure-si-tube.py index dccb337..259c464 100644 --- a/tests/twisted/tubes/ensure-si-tube.py +++ b/tests/twisted/tubes/ensure-si-tube.py @@ -70,7 +70,7 @@ def test(q, bus, conn, stream): feature['var'] = ns.TUBES stream.send(result) - bob_handle = conn.RequestHandles(1, ['bob@localhost'])[0] + bob_handle = conn.get_contact_handle_sync('bob@localhost') def new_chan_predicate(e): types = [] diff --git a/tests/twisted/tubes/offer-muc-dbus-tube.py b/tests/twisted/tubes/offer-muc-dbus-tube.py index 9fa66b4..f778cdc 100644 --- a/tests/twisted/tubes/offer-muc-dbus-tube.py +++ b/tests/twisted/tubes/offer-muc-dbus-tube.py @@ -188,7 +188,7 @@ def test(q, bus, conn, stream, access_control): dbus_tube_adr = return_event.value[0] bob_bus_name = ':2.Ym9i' - bob_handle = conn.RequestHandles(cs.HT_CONTACT, ['chat2@conf.localhost/bob'])[0] + bob_handle = conn.get_contact_handle_sync('chat2@conf.localhost/bob') def bob_in_tube(): presence = elem('presence', from_='chat2@conf.localhost/bob', to='chat2@conf.localhost')( diff --git a/tests/twisted/tubes/offer-muc-stream-tube.py b/tests/twisted/tubes/offer-muc-stream-tube.py index dfb8768..e7a7e29 100644 --- a/tests/twisted/tubes/offer-muc-stream-tube.py +++ b/tests/twisted/tubes/offer-muc-stream-tube.py @@ -74,7 +74,7 @@ def test(q, bus, conn, stream, bytestream_cls, t.check_conn_properties(q, conn) - bob_handle = conn.RequestHandles(cs.HT_CONTACT, ['chat@conf.localhost/bob'])[0] + bob_handle = conn.get_contact_handle_sync('chat@conf.localhost/bob') address = t.create_server(q, address_type) @@ -165,7 +165,7 @@ def test(q, bus, conn, stream, bytestream_cls, params[node['name']] = (node['type'], str(node)) assert params == {'foo': ('str', 'bar')} - bob_handle = conn.RequestHandles(cs.HT_CONTACT, ['chat@conf.localhost/bob'])[0] + bob_handle = conn.get_contact_handle_sync('chat@conf.localhost/bob') bytestream = connect_to_tube(stream, q, bytestream_cls, 'chat@conf.localhost', stream_tube_id) diff --git a/tests/twisted/tubes/offer-private-dbus-tube.py b/tests/twisted/tubes/offer-private-dbus-tube.py index 2d5ecf5..ee4e190 100644 --- a/tests/twisted/tubes/offer-private-dbus-tube.py +++ b/tests/twisted/tubes/offer-private-dbus-tube.py @@ -203,7 +203,7 @@ def test(q, bus, conn, stream, bytestream_cls, access_control): t.check_conn_properties(q, conn) self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") - alice_handle = conn.RequestHandles(cs.HT_CONTACT, ["alice@localhost"])[0] + alice_handle = conn.get_contact_handle_sync('alice@localhost') # send Alice's presence caps = { 'ext': '', 'ver': '0.0.0', diff --git a/tests/twisted/tubes/offer-private-stream-tube.py b/tests/twisted/tubes/offer-private-stream-tube.py index e7652ec..807959d 100644 --- a/tests/twisted/tubes/offer-private-stream-tube.py +++ b/tests/twisted/tubes/offer-private-stream-tube.py @@ -96,7 +96,7 @@ def test(q, bus, conn, stream, bytestream_cls, sync_dbus(bus, q, conn) # Test tubes with Bob. Bob has tube capabilities. - bob_handle = conn.RequestHandles(1, ['bob@localhost'])[0] + bob_handle = conn.get_contact_handle_sync('bob@localhost') # Try CreateChannel with correct properties # Gabble must succeed diff --git a/tests/twisted/vcard/disconnect-during-pep.py b/tests/twisted/vcard/disconnect-during-pep.py index cb05ad5..38f7d00 100644 --- a/tests/twisted/vcard/disconnect-during-pep.py +++ b/tests/twisted/vcard/disconnect-during-pep.py @@ -15,7 +15,7 @@ def test(q, bus, conn, stream): acknowledge_iq(stream, event.stanza) - handle = conn.RequestHandles(cs.HT_CONTACT, ['bob@foo.com'])[0] + handle = conn.get_contact_handle_sync('bob@foo.com') call_async(q, conn.Aliasing, 'RequestAliases', [handle]) # First, Gabble sends a PEP query diff --git a/tests/twisted/vcard/get-contact-info.py b/tests/twisted/vcard/get-contact-info.py index 2a509f8..e7d8284 100644 --- a/tests/twisted/vcard/get-contact-info.py +++ b/tests/twisted/vcard/get-contact-info.py @@ -17,7 +17,7 @@ def test(q, bus, conn, stream): # returning an empty vcard will cause ContactInfoChanged to fire q.expect('dbus-signal', signal='ContactInfoChanged') - handle = conn.RequestHandles(1, ['bob@foo.com'])[0] + handle = conn.get_contact_handle_sync('bob@foo.com') call_async(q, conn.ContactInfo, 'RefreshContactInfo', [handle]) event = q.expect('stream-iq', to='bob@foo.com', query_ns='vcard-temp', diff --git a/tests/twisted/vcard/refresh-contact-info.py b/tests/twisted/vcard/refresh-contact-info.py index 3fc87d3..84630da 100644 --- a/tests/twisted/vcard/refresh-contact-info.py +++ b/tests/twisted/vcard/refresh-contact-info.py @@ -15,7 +15,7 @@ def test(q, bus, conn, stream): acknowledge_iq(stream, event.stanza) - handle = conn.RequestHandles(1, ['bob@foo.com'])[0] + handle = conn.get_contact_handle_sync('bob@foo.com') call_async(q, conn.ContactInfo, 'RefreshContactInfo', [handle]) event = q.expect('stream-iq', to='bob@foo.com', query_ns='vcard-temp', diff --git a/tests/twisted/vcard/test-alias-empty-vcard.py b/tests/twisted/vcard/test-alias-empty-vcard.py index 8a03737..c711a07 100644 --- a/tests/twisted/vcard/test-alias-empty-vcard.py +++ b/tests/twisted/vcard/test-alias-empty-vcard.py @@ -14,7 +14,7 @@ def test(q, bus, conn, stream): acknowledge_iq(stream, event.stanza) - handle = conn.RequestHandles(1, ['bob@foo.com'])[0] + handle = conn.get_contact_handle_sync('bob@foo.com') call_async(q, conn.Aliasing, 'RequestAliases', [handle]) # Nack PEP query. diff --git a/tests/twisted/vcard/test-alias-message.py b/tests/twisted/vcard/test-alias-message.py index 362036a..e925fda 100644 --- a/tests/twisted/vcard/test-alias-message.py +++ b/tests/twisted/vcard/test-alias-message.py @@ -19,7 +19,7 @@ def test(q, bus, conn, stream): jid = u'bora.horza.gobuchul@culture.lit' alias = u'Horza' - handle = conn.RequestHandles(cs.HT_CONTACT, [jid])[0] + handle = conn.get_contact_handle_sync(jid) # We don't have an interesting alias for Horza assertEquals({handle: jid}, conn.Aliasing.GetAliases([handle])) @@ -71,7 +71,7 @@ def test(q, bus, conn, stream): _, muc, _, _ = join_muc(q, bus, conn, stream, room_jid) bob_jid = room_jid + '/bob' - bob_handle = conn.RequestHandles(cs.HT_CONTACT, [bob_jid])[0] + bob_handle = conn.get_contact_handle_sync(bob_jid) assertEquals({bob_handle: 'bob'}, conn.Aliasing.GetAliases([bob_handle])) diff --git a/tests/twisted/vcard/test-alias-pep.py b/tests/twisted/vcard/test-alias-pep.py index 0adc2b9..201eeee 100644 --- a/tests/twisted/vcard/test-alias-pep.py +++ b/tests/twisted/vcard/test-alias-pep.py @@ -15,7 +15,7 @@ def test(q, bus, conn, stream): acknowledge_iq(stream, event.stanza) - handle = conn.RequestHandles(cs.HT_CONTACT, ['bob@foo.com'])[0] + handle = conn.get_contact_handle_sync('bob@foo.com') call_async(q, conn.Aliasing, 'RequestAliases', [handle]) event = q.expect('stream-iq', to='bob@foo.com', iq_type='get', diff --git a/tests/twisted/vcard/test-alias.py b/tests/twisted/vcard/test-alias.py index 7e8dff2..72d0bf5 100644 --- a/tests/twisted/vcard/test-alias.py +++ b/tests/twisted/vcard/test-alias.py @@ -13,7 +13,7 @@ def test(q, bus, conn, stream): acknowledge_iq(stream, event.stanza) - handle = conn.RequestHandles(1, ['bob@foo.com'])[0] + handle = conn.get_contact_handle_sync('bob@foo.com') call_async(q, conn.Aliasing, 'RequestAliases', [handle]) # Nack PEP query. diff --git a/tests/twisted/vcard/test-avatar-async.py b/tests/twisted/vcard/test-avatar-async.py index cd4b9fd..df1f72a 100644 --- a/tests/twisted/vcard/test-avatar-async.py +++ b/tests/twisted/vcard/test-avatar-async.py @@ -66,7 +66,7 @@ def test(q, bus, conn, stream): q.unforbid_events([avatar_request_event, avatar_retrieved_event]) # Request on the first contact. Test the cache. - handle = conn.RequestHandles(cs.HT_CONTACT, ['bob@foo.com'])[0] + handle = conn.get_contact_handle_sync('bob@foo.com') test_get_avatar(q, bus, conn, stream, 'bob@foo.com', handle, in_cache=False) test_get_avatar(q, bus, conn, stream, 'bob@foo.com', handle, @@ -74,7 +74,7 @@ def test(q, bus, conn, stream): # Request another vCard and get resource-constraint busy_contact = 'jean@busy-server.com' - busy_handle = conn.RequestHandles(cs.HT_CONTACT, [busy_contact])[0] + busy_handle = conn.get_contact_handle_sync(busy_contact) conn.Avatars.RequestAvatars([busy_handle]) iq_event = q.expect('stream-iq', to=busy_contact, query_ns='vcard-temp', @@ -97,7 +97,7 @@ def test(q, bus, conn, stream): # Request on a different contact, on another server # We should get the avatar - handle = conn.RequestHandles(cs.HT_CONTACT, ['bob2@foo.com'])[0] + handle = conn.get_contact_handle_sync('bob2@foo.com') test_get_avatar(q, bus, conn, stream, 'bob2@foo.com', handle) # Try again the contact on the busy server. @@ -188,7 +188,7 @@ def test(q, bus, conn, stream): # First, ensure the pipeline is full contacts = ['random_user_%s@bigserver.com' % i for i in range(1, 100) ] - handles = conn.RequestHandles(cs.HT_CONTACT, contacts) + handles = conn.get_contact_handles_sync(contacts) conn.Avatars.RequestAvatars(handles) # Then, request yet another avatar. The request will time out before # the IQ is sent, which used to trigger a crash in Gabble diff --git a/tests/twisted/vcard/test-avatar-retrieved.py b/tests/twisted/vcard/test-avatar-retrieved.py index b612ca9..c332d5c 100644 --- a/tests/twisted/vcard/test-avatar-retrieved.py +++ b/tests/twisted/vcard/test-avatar-retrieved.py @@ -16,7 +16,7 @@ def test(q, bus, conn, stream): acknowledge_iq(stream, iq_event.stanza) - handle = conn.RequestHandles(1, ['bob@foo.com'])[0] + handle = conn.get_contact_handle_sync('bob@foo.com') conn.Avatars.RequestAvatars([handle]) conn.Avatars.RequestAvatars([handle]) conn.Avatars.RequestAvatars([handle]) diff --git a/tests/twisted/vcard/test-avatar-tokens.py b/tests/twisted/vcard/test-avatar-tokens.py index 59f01c0..705fe38 100644 --- a/tests/twisted/vcard/test-avatar-tokens.py +++ b/tests/twisted/vcard/test-avatar-tokens.py @@ -41,7 +41,7 @@ def test(q, bus, conn, stream): stream.send(make_presence('che@foo.com', None)) q.expect('dbus-signal', signal='AvatarUpdated') - handles = conn.RequestHandles(1, [ + handles = conn.get_contact_handles_sync([ 'amy@foo.com', 'bob@foo.com', 'che@foo.com', 'daf@foo.com' ]) tokens = unwrap(conn.Avatars.GetAvatarTokens(handles)) diff --git a/tests/twisted/vcard/test-avatar.py b/tests/twisted/vcard/test-avatar.py index f72e8ed..e5e3f54 100644 --- a/tests/twisted/vcard/test-avatar.py +++ b/tests/twisted/vcard/test-avatar.py @@ -15,7 +15,7 @@ def test(q, bus, conn, stream): acknowledge_iq(stream, event.stanza) - handle = conn.RequestHandles(1, ['bob@foo.com'])[0] + handle = conn.get_contact_handle_sync('bob@foo.com') call_async(q, conn.Avatars, 'RequestAvatar', handle, byte_arrays=True) event = q.expect('stream-iq', iq_type='get', to='bob@foo.com', -- 1.8.4.rc3