summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2011-06-23 16:39:59 +0100
committerWill Thompson <will.thompson@collabora.co.uk>2011-06-24 15:30:48 +0100
commitfa0990a9810b9629d32dd53840aa415e2d5dbe7d (patch)
treee56c4dc3b221337a1f1ea682ca83caf6181ad357 /tests
parentd1f7941c3343b1c498e55543c66ae72fa2b880f5 (diff)
Roster: don't emit presence updates for available contacts
Previously, when we received the roster we would announce that the presence of everyone on it we're subscribed to has changed, just for the side-effect of signalling that offline contacts really are offline, not just unknown. This offended me. :)
Diffstat (limited to 'tests')
-rw-r--r--tests/twisted/presence/initial-contact-presence.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/twisted/presence/initial-contact-presence.py b/tests/twisted/presence/initial-contact-presence.py
index 200e5a57..dabfc8c5 100644
--- a/tests/twisted/presence/initial-contact-presence.py
+++ b/tests/twisted/presence/initial-contact-presence.py
@@ -11,6 +11,7 @@ import ns
from twisted.words.xish import domish
+AVAILABLE = (cs.PRESENCE_AVAILABLE, u'available', u'')
OFFLINE = (cs.PRESENCE_OFFLINE, u'offline', u'')
UNKNOWN = (cs.PRESENCE_UNKNOWN, u'unknown', u'')
@@ -23,14 +24,16 @@ def make_roster_item(jid, subscription):
def test(q, bus, conn, stream):
event = q.expect('stream-iq', query_ns=ns.ROSTER)
- amy, bob, che, dre = conn.RequestHandles(cs.HT_CONTACT,
- ['amy@foo.com', 'bob@foo.com', 'che@foo.com', 'dre@foo.com'])
+ amy, bob, che, dre, eve = conn.RequestHandles(cs.HT_CONTACT,
+ ['amy@foo.com', 'bob@foo.com', 'che@foo.com', 'dre@foo.com',
+ 'eve@foo.com'])
assertEquals({amy: UNKNOWN,
bob: UNKNOWN,
che: UNKNOWN,
dre: UNKNOWN,
+ eve: UNKNOWN,
},
- conn.SimplePresence.GetPresences([amy, bob, che, dre]))
+ conn.SimplePresence.GetPresences([amy, bob, che, dre, eve]))
# Before the server sends Gabble the roster, it relays an 'unavailable'
# presence for one of the contacts we're subscribed to. This seems to
@@ -44,14 +47,18 @@ def test(q, bus, conn, stream):
# unknown---so it shouldn't be signalled.
q.forbid_events([EventPattern('dbus-signal', signal='PresencesChanged',
args=[{dre: UNKNOWN}])])
- sync_stream(q, stream)
- sync_dbus(bus, q, conn)
+
+ # We also receive an available presence from Eve before the roster arrives:
+ # this presence should behave normally.
+ stream.send(make_presence('eve@foo.com'))
+ q.expect('dbus-signal', signal='PresencesChanged', args=[{eve: AVAILABLE}])
event.stanza['type'] = 'result'
event.query.addChild(make_roster_item('amy@foo.com', 'both'))
event.query.addChild(make_roster_item('bob@foo.com', 'from'))
event.query.addChild(make_roster_item('che@foo.com', 'to'))
event.query.addChild(make_roster_item('dre@foo.com', 'both'))
+ event.query.addChild(make_roster_item('eve@foo.com', 'both'))
stream.send(event.stanza)
# The presence for contacts on the roster whose subscription is 'to' or
@@ -70,8 +77,9 @@ def test(q, bus, conn, stream):
bob: UNKNOWN,
che: OFFLINE,
dre: OFFLINE,
+ eve: AVAILABLE,
},
- conn.SimplePresence.GetPresences([amy, bob, che, dre]))
+ conn.SimplePresence.GetPresences([amy, bob, che, dre, eve]))
if __name__ == '__main__':
exec_test(test)