From 314ab4d1584838e0e8829991575b7fbd85d8a09b Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 9 Oct 2013 17:29:33 -0400 Subject: Use RequestAvatars instead of RequestAvatar --- tests/twisted/vcard/test-avatar-async.py | 21 +++++++++------------ tests/twisted/vcard/test-avatar.py | 10 +++++----- tests/twisted/vcard/test-vcard-cache.py | 9 ++------- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/tests/twisted/vcard/test-avatar-async.py b/tests/twisted/vcard/test-avatar-async.py index df1f72a38..a3e250ab5 100644 --- a/tests/twisted/vcard/test-avatar-async.py +++ b/tests/twisted/vcard/test-avatar-async.py @@ -180,10 +180,12 @@ def test(q, bus, conn, stream): # Gabble must reply without asking the vCard to the server because the # avatar must be in the cache q.forbid_events([avatar_request_event]) - data, mime = conn.Avatars.RequestAvatar(self_handle, byte_arrays=True) - assertEquals('\o/', data) - data, mime = conn.Avatars.RequestAvatar(handle, byte_arrays=True) - assertEquals('hello', data) + conn.Avatars.RequestAvatars([self_handle]) + e = q.expect('dbus-signal', signal='AvatarRetrieved') + assertEquals('\o/', e.args[2]) + conn.Avatars.RequestAvatars([handle]) + e = q.expect('dbus-signal', signal='AvatarRetrieved') + assertEquals('hello', e.args[2]) q.unforbid_events([avatar_request_event]) # First, ensure the pipeline is full @@ -192,14 +194,9 @@ def test(q, bus, conn, stream): 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 - # (LP#445847). So, we assert that the error is NotAvailable (rather - # than the error returned when the service crashes). - try: - conn.Avatars.RequestAvatar(handles[-1]) - except dbus.DBusException, e: - assertEquals(cs.NOT_AVAILABLE, e.get_dbus_name()) - else: - assert False + # (LP#445847). + conn.Avatars.RequestAvatars([handles[-1]]) + sync_dbus(bus, q, conn) if __name__ == '__main__': exec_test(test) diff --git a/tests/twisted/vcard/test-avatar.py b/tests/twisted/vcard/test-avatar.py index e5e3f5423..834c9e7fa 100644 --- a/tests/twisted/vcard/test-avatar.py +++ b/tests/twisted/vcard/test-avatar.py @@ -5,9 +5,8 @@ Test avatar support. import base64 -from servicetest import call_async, EventPattern +from servicetest import call_async, assertEquals from gabbletest import exec_test, acknowledge_iq, make_result_iq -import constants as cs def test(q, bus, conn, stream): event = q.expect('stream-iq', to=None, query_ns='vcard-temp', @@ -16,7 +15,7 @@ def test(q, bus, conn, stream): acknowledge_iq(stream, event.stanza) handle = conn.get_contact_handle_sync('bob@foo.com') - call_async(q, conn.Avatars, 'RequestAvatar', handle, byte_arrays=True) + call_async(q, conn.Avatars, 'RequestAvatars', [handle]) event = q.expect('stream-iq', iq_type='get', to='bob@foo.com', query_ns='vcard-temp', query_name='vCard') @@ -26,8 +25,9 @@ def test(q, bus, conn, stream): photo.addElement('BINVAL', content=base64.b64encode('hello')) stream.send(result) - q.expect('dbus-return', method='RequestAvatar', - value=('hello', 'image/png')) + e = q.expect('dbus-signal', signal='AvatarRetrieved') + assertEquals('hello', e.args[2]) + assertEquals('image/png', e.args[3]) if __name__ == '__main__': exec_test(test) diff --git a/tests/twisted/vcard/test-vcard-cache.py b/tests/twisted/vcard/test-vcard-cache.py index 4c28810f5..f1cbfcd98 100644 --- a/tests/twisted/vcard/test-vcard-cache.py +++ b/tests/twisted/vcard/test-vcard-cache.py @@ -18,7 +18,7 @@ def test(q, bus, conn, stream): # Request our alias and avatar, expect them to be resolved from cache. handle = conn.Properties.Get(cs.CONN, "SelfHandle") - call_async(q, conn.Avatars, 'RequestAvatar', handle) + call_async(q, conn.Avatars, 'RequestAvatars', [handle]) call_async(q, conn.Aliasing, 'RequestAliases', [handle]) # FIXME - find out why RequestAliases returns before RequestAvatar even @@ -30,15 +30,10 @@ def test(q, bus, conn, stream): r1, r2 = q.expect_many( EventPattern('dbus-return', method='RequestAliases'), - EventPattern('dbus-error', method='RequestAvatar')) + EventPattern('dbus-return', method='RequestAvatars')) # Default alias is our jid assert r1.value[0] == ['test@localhost'] - # We don't have a vCard yet - assert r2.error.get_dbus_name() == cs.NOT_AVAILABLE, \ - r2.error.get_dbus_name() - assert r2.error.args[0] == 'contact vCard has no photo' - if __name__ == '__main__': exec_test(test) -- cgit v1.2.1