diff --git a/tests/twisted/client-types.py b/tests/twisted/client-types.py index bb6a3d6..d07d918 100644 --- a/tests/twisted/client-types.py +++ b/tests/twisted/client-types.py @@ -4,7 +4,8 @@ Test Conn.I.ClientTypes import random from functools import partial -from servicetest import EventPattern, assertEquals, assertLength, assertContains, assertSameSets +from servicetest import (EventPattern, assertEquals, assertLength, + assertContains, assertSameSets, sync_dbus) from gabbletest import exec_test, make_presence, sync_stream import constants as cs import ns @@ -243,6 +244,43 @@ def test2(q, bus, conn, stream): assertContains(attr, attrs[handle]) assertEquals(['pc'], attrs[handle][attr]) +def test3(q, bus, conn, stream): + # Alice has 5 available phones and 5 busy computer! + alice_phone = 'alice@good.restaurant/phone' + alice_busycomputer = 'alice@good.restaurant/busycomputer' + handle = conn.RequestHandles(cs.HT_CONTACT, [alice_phone])[0] + initial = True + disco = True + + for i in range(1, 5): + # busycomputer no i comes online + contact_online(q, conn, stream, alice_busycomputer + str(i), PC, + show='dnd', disco=disco, initial=initial) + initial = False + + types = conn.GetClientTypes([handle], + dbus_interface=cs.CONN_IFACE_CLIENT_TYPES) + assertSameSets(['pc'], types[handle]) + + # phone no i comes online + contact_online(q, conn, stream, alice_phone + str(i), PHONE, + show=None, disco=disco, initial=False) + disco = False + + types = conn.GetClientTypes([handle], + dbus_interface=cs.CONN_IFACE_CLIENT_TYPES) + assertSameSets(['phone'], types[handle]) + + # busycomputer no 5 goes offline + stream.send(make_presence(alice_busycomputer + str(5), type='unavailable')) + sync_stream(q, stream) + sync_dbus(bus, q, conn) + + types = conn.GetClientTypes([handle], + dbus_interface=cs.CONN_IFACE_CLIENT_TYPES) + assertSameSets(['phone'], types[handle]) + + def two_contacts_with_the_same_hash(q, bus, conn, stream, bare_jids): contact1 = 'bowyer.place@tfl.gov.uk' contact2 = 'albany.road@tfl.gov.uk' @@ -283,5 +321,6 @@ def two_contacts_with_the_same_hash(q, bus, conn, stream, bare_jids): if __name__ == '__main__': exec_test(test) exec_test(test2) + exec_test(test3) exec_test(partial(two_contacts_with_the_same_hash, bare_jids=False)) exec_test(partial(two_contacts_with_the_same_hash, bare_jids=True))