[Telepathy-commits] [telepathy-gabble/master] factor out send_buddy_changed_current_act_msg to olpc/util.py
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:30 PDT 2008
20080702153950-7fe3f-063c40ffe28cbd04ffb027341640e55db2e3552d.gz
---
tests/twisted/olpc/current-activity.py | 19 +++----------------
tests/twisted/olpc/util.py | 23 ++++++++++++++++++++---
2 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/tests/twisted/olpc/current-activity.py b/tests/twisted/olpc/current-activity.py
index 3a4d31a..bf3c945 100644
--- a/tests/twisted/olpc/current-activity.py
+++ b/tests/twisted/olpc/current-activity.py
@@ -10,7 +10,7 @@ from twisted.words.protocols.jabber.client import IQ
from twisted.words.xish import domish, xpath
-from util import announce_gadget
+from util import announce_gadget, send_buddy_changed_current_act_msg
NS_OLPC_BUDDY_PROPS = "http://laptop.org/xmpp/buddy-properties"
NS_OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities"
@@ -75,21 +75,8 @@ def test(q, bus, conn, stream):
('activity1', handles['room1'])
# Alice changed 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'] = 'room2 at conference.localhost'
- activity['type'] = 'activity2'
-
- stream.send(message)
+ send_buddy_changed_current_act_msg(stream, 'alice at localhost', 'activity2',
+ 'room2 at conference.localhost')
event = q.expect('dbus-signal', signal='CurrentActivityChanged')
contact, id, handles['room2'] = event.args
diff --git a/tests/twisted/olpc/util.py b/tests/twisted/olpc/util.py
index 2e0505d..6cfddf8 100644
--- a/tests/twisted/olpc/util.py
+++ b/tests/twisted/olpc/util.py
@@ -70,20 +70,37 @@ def announce_gadget(q, stream, disco_stanza):
stream.send(reply)
-def send_buddy_changed_properties_msg(stream, from_, props):
+def _make_pubsub_event_msg(from_, node):
# TODO: Would be cool to use elem() but there is no API
- # to get a pointer on the properties node...
+ # to get a pointer on the item node...
message = domish.Element(('jabber:client', 'message'))
message['from'] = from_
message['to'] = 'test at localhost'
event = message.addElement(("%s#event" % NS_PUBSUB, 'event'))
items = event.addElement((None, 'items'))
- items['node'] = NS_OLPC_BUDDY_PROPS
+ items['node'] = node
item = items.addElement((None, 'item'))
+
+ return message, item
+
+def send_buddy_changed_properties_msg(stream, from_, props):
+ message, item = _make_pubsub_event_msg(from_,
+ NS_OLPC_BUDDY_PROPS)
+
properties = item.addElement((NS_OLPC_BUDDY_PROPS, 'properties'))
for child in properties_to_xml(props):
properties.addChild(child)
stream.send(message)
+
+def send_buddy_changed_current_act_msg(stream, from_, id, room):
+ message, item = _make_pubsub_event_msg(from_,
+ NS_OLPC_CURRENT_ACTIVITY)
+
+ activity = item.addElement((NS_OLPC_CURRENT_ACTIVITY, 'activity'))
+ activity['room'] = room
+ activity['type'] = id
+
+ stream.send(message)
--
1.5.6.5
More information about the Telepathy-commits
mailing list