diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-04-19 11:08:30 +0100 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-04-19 11:08:30 +0100 |
commit | 45577ef24a72dfad362ecda11caee9dbe6bc2368 (patch) | |
tree | b57648b9bbbf887726142d219d3c50bc6f9caa24 /tests/twisted | |
parent | a06f0e7cff4afac90f69057e31b80d52a896121b (diff) |
status: test setting from multiple services but cleaning up at the right time
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'tests/twisted')
-rw-r--r-- | tests/twisted/salut/status.py | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/tests/twisted/salut/status.py b/tests/twisted/salut/status.py index 9f028c2..6218d28 100644 --- a/tests/twisted/salut/status.py +++ b/tests/twisted/salut/status.py @@ -141,7 +141,47 @@ def test(q, bus, conn): assertEquals({'testsuite@testsuite': {CAP_NAME: {'ants.in.their.pants': status_str}}}, discovered) - # unset the status + # set another + el = Element(('urn:ytstenut:status', 'status')) + el['activity'] = 'rofling' + desc = el.addElement('ytstenut:description', content='U MAD?') + desc['xml:lang'] = 'en-GB' + + call_async(q, status, 'AdvertiseStatus', CAP_NAME, + 'bananaman.on.holiday', el.toXml()) + + e, _, sig = q.expect_many(EventPattern('stream-message', connection=incoming), + EventPattern('dbus-return', method='AdvertiseStatus'), + EventPattern('dbus-signal', signal='StatusChanged', + interface=ycs.STATUS_IFACE)) + + # check message + message = e.stanza + event = message.children[0] + items = event.children[0] + item = items.children[0] + status_el = item.children[0] + + assertEquals('status', status_el.name) + assertEquals('rofling', status_el['activity']) + assertEquals('bananaman.on.holiday', status_el['from-service']) + assertEquals(CAP_NAME, status_el['capability']) + + # check signal + contact_id, capability, service_name, bananaman_status_str = sig.args + assertEquals(CAP_NAME, capability) + assertEquals('bananaman.on.holiday', service_name) + assertNotEquals('', bananaman_status_str) + + # check property + discovered = status.Get(ycs.STATUS_IFACE, 'DiscoveredStatuses', + dbus_interface=dbus.PROPERTIES_IFACE) + assertEquals({'testsuite@testsuite': {CAP_NAME: { + 'ants.in.their.pants': status_str, + 'bananaman.on.holiday': bananaman_status_str}}}, + discovered) + + # unset the status from one service call_async(q, status, 'AdvertiseStatus', CAP_NAME, 'ants.in.their.pants', '') @@ -172,6 +212,41 @@ def test(q, bus, conn): # check property discovered = status.Get(ycs.STATUS_IFACE, 'DiscoveredStatuses', dbus_interface=dbus.PROPERTIES_IFACE) + assertEquals({'testsuite@testsuite': {CAP_NAME: { + 'bananaman.on.holiday': bananaman_status_str}}}, + discovered) + + # unset the status from the other service + call_async(q, status, 'AdvertiseStatus', CAP_NAME, + 'bananaman.on.holiday', '') + + e, _, sig = q.expect_many(EventPattern('stream-message', connection=incoming), + EventPattern('dbus-return', method='AdvertiseStatus'), + EventPattern('dbus-signal', signal='StatusChanged', + interface=ycs.STATUS_IFACE)) + + # check message + message = e.stanza + event = message.children[0] + items = event.children[0] + item = items.children[0] + status_el = item.children[0] + + assertEquals('status', status_el.name) + assertEquals('bananaman.on.holiday', status_el['from-service']) + assertEquals(CAP_NAME, status_el['capability']) + assert 'activity' not in status_el.attributes + assertEquals([], status_el.children) + + # check signal + contact_id, capability, service_name, status_str = sig.args + assertEquals(CAP_NAME, capability) + assertEquals('bananaman.on.holiday', service_name) + assertEquals('', status_str) + + # check property + discovered = status.Get(ycs.STATUS_IFACE, 'DiscoveredStatuses', + dbus_interface=dbus.PROPERTIES_IFACE) assertEquals({}, discovered) if __name__ == '__main__': |