From 535d8c788c3b1a4cf15eb1ccbb5a6bbcceffb93d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 17 Sep 2013 16:19:23 +0100 Subject: [PATCH 2/2] Test unknown presences --- tests/twisted/constants.py | 1 + tests/twisted/presence/presence.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py index d541c75..37d6d52 100644 --- a/tests/twisted/constants.py +++ b/tests/twisted/constants.py @@ -195,6 +195,7 @@ CONN_IFACE_CONTACT_BLOCKING = CONN + '.Interface.ContactBlocking' CONN_IFACE_ADDRESSING = CONN + '.Interface.Addressing1' ATTR_CONTACT_CAPABILITIES = CONN_IFACE_CONTACT_CAPS + '/capabilities' +ATTR_PRESENCE = CONN_IFACE_SIMPLE_PRESENCE + '/presence' STREAM_HANDLER = 'org.freedesktop.Telepathy.Media.StreamHandler' diff --git a/tests/twisted/presence/presence.py b/tests/twisted/presence/presence.py index a3c5854..e35616e 100644 --- a/tests/twisted/presence/presence.py +++ b/tests/twisted/presence/presence.py @@ -1,7 +1,5 @@ """ A simple smoke-test for C.I.SimplePresence - -FIXME: test C.I.Presence too """ import dbus @@ -9,7 +7,9 @@ import dbus from twisted.words.xish import domish, xpath from twisted.words.protocols.jabber.client import IQ +from servicetest import assertEquals from hazetest import exec_test +import constants as cs def test(q, bus, conn, stream): amy_handle = conn.RequestHandles(1, ['amy@foo.com'])[0] @@ -48,6 +48,15 @@ def test(q, bus, conn, stream): # produces. assert event.args[0] == { amy_handle: (2, 'available', 'I may have been drinking') } + amy_handle, asv = conn.Contacts.GetContactByID('amy@foo.com', + [cs.CONN_IFACE_SIMPLE_PRESENCE]) + assertEquals(event.args[0][amy_handle], asv.get(cs.ATTR_PRESENCE)) + + bob_handle, asv = conn.Contacts.GetContactByID('bob@foo.com', + [cs.CONN_IFACE_SIMPLE_PRESENCE]) + assertEquals((cs.PRESENCE_UNKNOWN, 'unknown', ''), + asv.get(cs.ATTR_PRESENCE)) + conn.Disconnect() q.expect('dbus-signal', signal='StatusChanged', args=[2, 1]) -- 1.8.4.rc3