From f8c948498ee34d248cd55d5e883f6f999cbb89f6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 17 Sep 2013 16:19:07 +0100 Subject: [PATCH] Add regression test coverage for the presence of a non-roster contact --- tests/twisted/constants.py | 1 + tests/twisted/presence/presence.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py index c194ee3..3f6cec0 100644 --- a/tests/twisted/constants.py +++ b/tests/twisted/constants.py @@ -186,6 +186,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 4997469..2f1439b 100644 --- a/tests/twisted/presence/presence.py +++ b/tests/twisted/presence/presence.py @@ -1,13 +1,11 @@ """ A simple smoke-test for C.I.SimplePresence - -FIXME: test C.I.Presence too """ from twisted.words.xish import domish from gabbletest import exec_test, make_presence -from servicetest import EventPattern +from servicetest import EventPattern, assertEquals import ns import constants as cs @@ -31,9 +29,18 @@ def test(q, bus, conn, stream): stream.send(make_presence( 'amy@foo.com', show='chat', status='I may have been drinking')) - q.expect('dbus-signal', signal='PresencesChanged', + e = q.expect('dbus-signal', signal='PresencesChanged', args=[{amy_handle: (cs.PRESENCE_AVAILABLE, 'chat', 'I may have been drinking')}]) + amy_handle, asv = conn.Contacts.GetContactByID('amy@foo.com', + [cs.CONN_IFACE_SIMPLE_PRESENCE]) + assertEquals(e.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)) + if __name__ == '__main__': exec_test(test) -- 1.8.4.rc3