[Telepathy-commits] [telepathy-gabble/master] factor out answer_to_current_act_pubsub_request to olpc/util.py
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:31 PDT 2008
20080702155245-7fe3f-0dedd31ec2dda1c9659cd1f080176cea8895292c.gz
---
tests/twisted/olpc/current-activity.py | 16 ++++------------
tests/twisted/olpc/util.py | 15 +++++++++++++++
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/tests/twisted/olpc/current-activity.py b/tests/twisted/olpc/current-activity.py
index bf3c945..663baab 100644
--- a/tests/twisted/olpc/current-activity.py
+++ b/tests/twisted/olpc/current-activity.py
@@ -10,7 +10,8 @@ from twisted.words.protocols.jabber.client import IQ
from twisted.words.xish import domish, xpath
-from util import announce_gadget, send_buddy_changed_current_act_msg
+from util import announce_gadget, send_buddy_changed_current_act_msg,\
+ answer_to_current_act_pubsub_request
NS_OLPC_BUDDY_PROPS = "http://laptop.org/xmpp/buddy-properties"
NS_OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities"
@@ -50,17 +51,8 @@ def test(q, bus, conn, stream):
# Alice's current-activity is not in the cache so Gabble sends a PEP query
event = q.expect('stream-iq', iq_type='get', query_name='pubsub')
- reply = make_result_iq(stream, event.stanza)
- reply['from'] = 'alice at localhost'
- pubsub = reply.firstChildElement()
- items = pubsub.addElement((None, 'items'))
- items['node'] = NS_OLPC_CURRENT_ACTIVITY
- item = items.addElement((None, 'item'))
- item['id'] = 'itemID'
- activity = item.addElement((NS_OLPC_CURRENT_ACTIVITY, 'activity'))
- activity['room'] = 'room1 at conference.localhost'
- activity['type'] = 'activity1'
- reply.send()
+ answer_to_current_act_pubsub_request(stream, event.stanza, 'activity1',
+ 'room1 at conference.localhost')
event = q.expect('dbus-return', method='GetCurrentActivity')
id, handles['room1'] = event.value
diff --git a/tests/twisted/olpc/util.py b/tests/twisted/olpc/util.py
index 6cfddf8..6f76ccd 100644
--- a/tests/twisted/olpc/util.py
+++ b/tests/twisted/olpc/util.py
@@ -104,3 +104,18 @@ def send_buddy_changed_current_act_msg(stream, from_, id, room):
activity['type'] = id
stream.send(message)
+
+def answer_to_current_act_pubsub_request(stream, request, id, room):
+ # TODO: check request structure
+ reply = make_result_iq(stream, request)
+ reply['from'] = request['to']
+ pubsub = reply.firstChildElement()
+ items = pubsub.addElement((None, 'items'))
+ items['node'] = NS_OLPC_CURRENT_ACTIVITY
+ item = items.addElement((None, 'item'))
+ item['id'] = 'itemID'
+ activity = item.addElement((NS_OLPC_CURRENT_ACTIVITY, 'activity'))
+ activity['room'] = room
+ activity['type'] = id
+ reply.send()
+
--
1.5.6.5
More information about the Telepathy-commits
mailing list