[Telepathy-commits] [telepathy-gabble/master] olpc-buddy-prop-change.py: test current-activity changes notifications
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:01:58 PDT 2008
20071207133210-7fe3f-6a7462c0637f280de15b0a2594514382c8c9c041.gz
---
tests/olpc-buddy-prop-change.py | 68 +++++++++++++++++++++++++++++++++++++-
1 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/tests/olpc-buddy-prop-change.py b/tests/olpc-buddy-prop-change.py
index e9c03a3..e27aec8 100644
--- a/tests/olpc-buddy-prop-change.py
+++ b/tests/olpc-buddy-prop-change.py
@@ -18,6 +18,10 @@ NS_OLPC_BUDDY_PROPS = "http://laptop.org/xmpp/buddy-properties"
NS_OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities"
NS_OLPC_CURRENT_ACTIVITY = "http://laptop.org/xmpp/current-activity"
NS_OLPC_ACTIVITY_PROPS = "http://laptop.org/xmpp/activity-properties"
+NS_OLPC_BUDDY = "http://laptop.org/xmpp/buddy"
+NS_OLPC_ACTIVITY = "http://laptop.org/xmpp/activity"
+
+NS_AMP = "http://jabber.org/protocol/amp"
@match('dbus-signal', signal='StatusChanged', args=[0, 1])
def expect_connected(event, data):
@@ -55,7 +59,7 @@ def expect_friends_properties_changed(event, data):
message['from'] = 'index.jabber.laptop.org'
message['to'] = 'test at localhost'
- change = message.addElement(('http://laptop.org/xmpp/buddy', 'change'))
+ change = message.addElement((NS_OLPC_BUDDY, 'change'))
change['jid'] = 'bob at localhost'
properties = change.addElement((NS_OLPC_BUDDY_PROPS, 'properties'))
property = properties.addElement((None, 'property'))
@@ -63,7 +67,7 @@ def expect_friends_properties_changed(event, data):
property['name'] = 'color'
property.addContent('#FFFFFF,#AAAAAA')
- amp = message.addElement(('http://jabber.org/protocol/amp', 'amp'))
+ amp = message.addElement((NS_AMP, 'amp'))
rule = amp.addElement((None, 'rule'))
rule['condition'] = 'deliver-at'
rule['value'] = 'stored'
@@ -79,6 +83,66 @@ def expect_indexer_properties_changed(event, data):
assert props == {'color' : '#FFFFFF,#AAAAAA'}
+ # Alice changes now her current-activity
+ message = domish.Element(('jabber:client', 'message'))
+ message['from'] = 'alice at localhost'
+ message['to'] = 'test at localhost'
+ event = message.addElement(('http://jabber.org/protocol/pubsub#event',
+ 'event'))
+
+ items = event.addElement((None, 'items'))
+ items['node'] = NS_OLPC_CURRENT_ACTIVITY
+ item = items.addElement((None, 'item'))
+
+ activity = item.addElement((NS_OLPC_CURRENT_ACTIVITY, 'activity'))
+ activity['room'] = 'testroom at conference.localhost'
+ activity['type'] = 'testactivity'
+
+ data['stream'].send(message)
+
+ return True
+
+ at match('dbus-signal', signal='CurrentActivityChanged')
+def expect_friends_current_activity_changed(event, data):
+ contact = event.args[0]
+ activity = event.args[1]
+ room = event.args[2]
+ room_id = data['conn_iface'].InspectHandles(2, [room])[0]
+
+ assert activity == 'testactivity'
+ assert room_id == 'testroom at conference.localhost'
+
+ # The indexer informs us about a buddy current-activity change.
+ message = domish.Element(('jabber:client', 'message'))
+ message['from'] = 'index.jabber.laptop.org'
+ message['to'] = 'test at localhost'
+
+ change = message.addElement((NS_OLPC_BUDDY, 'change'))
+ change['jid'] = 'bob at localhost'
+ activity = change.addElement((NS_OLPC_CURRENT_ACTIVITY, 'activity'))
+ activity['type'] = 'testactivity2'
+ activity['room'] = 'testroom2 at conference.localhost'
+
+ amp = message.addElement((NS_AMP, 'amp'))
+ rule = amp.addElement((None, 'rule'))
+ rule['condition'] = 'deliver-at'
+ rule['value'] = 'stored'
+ rule['action'] ='error'
+
+ data['stream'].send(message)
+
+ return True
+
+ at match('dbus-signal', signal='CurrentActivityChanged')
+def expect_indexer_current_activity_changed(event, data):
+ contact = event.args[0]
+ activity = event.args[1]
+ room = event.args[2]
+ room_id = data['conn_iface'].InspectHandles(2, [room])[0]
+
+ assert activity == 'testactivity2'
+ assert room_id == 'testroom2 at conference.localhost'
+
return True
if __name__ == '__main__':
--
1.5.6.5
More information about the Telepathy-commits
mailing list