diff options
author | Marco Barisione <marco@barisione.org> | 2011-09-16 18:57:56 +0100 |
---|---|---|
committer | Marco Barisione <marco@barisione.org> | 2011-09-16 19:01:19 +0100 |
commit | 40b5b45203098ce308a51b6c88c4ab31d40e047d (patch) | |
tree | cadfd3ad99c17a821bcf5f39c5870ef53885b7b6 /tests | |
parent | d4cfda9cd64923c81d87b8f875b5f20658023a17 (diff) |
roster: emit a single signal for all the aliases updated at the same time
Diffstat (limited to 'tests')
-rw-r--r-- | tests/twisted/Makefile.am | 1 | ||||
-rw-r--r-- | tests/twisted/roster/test-initial-aliases.py | 56 |
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index 1b026943..6d7be144 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -64,6 +64,7 @@ TWISTED_TESTS = \ roster/ensure.py \ roster/groups.py \ roster/groups-12791.py \ + roster/initial-aliases.py \ roster/push-from-contact.py \ roster/push-without-id.py \ roster/removed-from-rp-subscribe.py \ diff --git a/tests/twisted/roster/test-initial-aliases.py b/tests/twisted/roster/test-initial-aliases.py new file mode 100644 index 00000000..d1aeb42a --- /dev/null +++ b/tests/twisted/roster/test-initial-aliases.py @@ -0,0 +1,56 @@ +""" +Test retrieving the aliases after connection. +""" + +from servicetest import ( + assertContains, assertLength + ) +from gabbletest import ( + exec_test, make_result_iq + ) +import constants as cs +import ns + +def add_contact(iq, jid, alias): + query = iq.firstChildElement() + item = query.addElement('item') + item['jid'] = jid + item['name'] = alias + item['subscription'] = 'both' + +def test(q, bus, conn, stream): + """ + Check that when we receive a roster update we emit a single AliasesChanged + for all the contacts. + """ + + conn.Connect() + + # Gabble asks the server for the initial roster + event = q.expect('stream-iq', iq_type='get', query_ns=ns.ROSTER) + result = make_result_iq(stream, event.stanza) + + # We reply with a roster with two contacts + bob_jid = 'bob.smith@example.com' + bob_alias = 'Bob Smith' + add_contact(result, bob_jid, bob_alias) + + alice_jid = 'alice@example.com' + alice_alias = 'Alice' + add_contact(result, alice_jid, alice_alias) + + stream.send(result) + + # Check we get a single AliasesChanged for both contacts + event = q.expect('dbus-signal', signal='AliasesChanged') + added = event.args[0] + + bob_handle, alice_handle = conn.RequestHandles(cs.HT_CONTACT, + [bob_jid, alice_jid]) + + assertLength(2, added) + assertContains((bob_handle, bob_alias), added) + assertContains((alice_handle, alice_alias), added) + +if __name__ == '__main__': + exec_test(test, do_connect=False) |