[Telepathy-commits] [telepathy-gabble/master] use request_random_activity_view in olpc-activity-search.py
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:31 PDT 2008
20080703120824-7fe3f-5644e957f660ae87ac2bcb389943585b10627f05.gz
---
tests/twisted/olpc/olpc-activity-search.py | 55 ++++++----------------------
tests/twisted/olpc/util.py | 15 +++++++-
2 files changed, 25 insertions(+), 45 deletions(-)
diff --git a/tests/twisted/olpc/olpc-activity-search.py b/tests/twisted/olpc/olpc-activity-search.py
index 9ced730..5f0d289 100644
--- a/tests/twisted/olpc/olpc-activity-search.py
+++ b/tests/twisted/olpc/olpc-activity-search.py
@@ -9,7 +9,7 @@ from gabbletest import exec_test, make_result_iq, acknowledge_iq, sync_stream
from twisted.words.xish import domish, xpath
from twisted.words.protocols.jabber.client import IQ
-from util import announce_gadget
+from util import announce_gadget, request_random_activity_view
NS_OLPC_BUDDY_PROPS = "http://laptop.org/xmpp/buddy-properties"
NS_OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities"
@@ -54,43 +54,15 @@ def test(q, bus, conn, stream):
sync_stream(q, stream)
# request 3 random activities (view 0)
- call_async(q, gadget_iface, 'RequestRandomActivities', 3)
+ view_path = request_random_activity_view(q, stream, conn, 3, '0',
+ [('activity1', 'room1 at conference.localhost',
+ {'color': ('str', '#005FE4,#00A0FF')},
+ [('lucien at localhost', {'color': ('str', '#AABBCC,#CCBBAA')}),
+ ('jean at localhost', {})]),])
- iq_event, return_event = q.expect_many(
- EventPattern('stream-iq', to='gadget.localhost',
- query_ns=NS_OLPC_ACTIVITY),
- EventPattern('dbus-return', method='RequestRandomActivities'))
-
- view = iq_event.stanza.firstChildElement()
- assert view.name == 'view'
- assert view['id'] == '0'
- random = xpath.queryForNodes('/iq/view/random', iq_event.stanza)
- assert len(random) == 1
- assert random[0]['max'] == '3'
- # reply to random query
- reply = make_result_iq(stream, iq_event.stanza)
- reply['from'] = 'gadget.localhost'
- reply['to'] = 'alice at localhost'
- view = xpath.queryForNodes('/iq/view', reply)[0]
- activity = view.addElement((None, "activity"))
- activity['room'] = 'room1 at conference.localhost'
- activity['id'] = 'activity1'
- properties = activity.addElement((NS_OLPC_ACTIVITY_PROPS, "properties"))
- property = properties.addElement((None, "property"))
- property['type'] = 'str'
- property['name'] = 'color'
- property.addContent('#005FE4,#00A0FF')
- buddy = activity.addElement((None, 'buddy'))
- buddy['jid'] = 'lucien at localhost'
- properties = buddy.addElement((NS_OLPC_BUDDY_PROPS, "properties"))
- property = properties.addElement((None, "property"))
- property['type'] = 'str'
- property['name'] = 'color'
- property.addContent('#AABBCC,#CCBBAA')
- buddy = activity.addElement((None, 'buddy'))
- buddy['jid'] = 'jean at localhost'
- stream.send(reply)
+ view0 = bus.get_object(conn.bus_name, view_path)
+ view0_iface = dbus.Interface(view0, 'org.laptop.Telepathy.View')
## Current views ##
# view 0: activity 1 (with: Lucien, Jean)
@@ -98,13 +70,10 @@ def test(q, bus, conn, stream):
handles['lucien'], handles['jean'] = \
conn.RequestHandles(1, ['lucien at localhost', 'jean at localhost'])
- view_path = return_event.value[0]
- view0 = bus.get_object(conn.bus_name, view_path)
- view0_iface = dbus.Interface(view0, 'org.laptop.Telepathy.View')
-
event = q.expect('dbus-signal', signal='ActivityPropertiesChanged')
handles['room1'], props = event.args
- assert conn.InspectHandles(2, [handles['room1']])[0] == 'room1 at conference.localhost'
+ assert conn.InspectHandles(2, [handles['room1']])[0] == \
+ 'room1 at conference.localhost'
assert props == {'color': '#005FE4,#00A0FF'}
# participants are added to view
diff --git a/tests/twisted/olpc/util.py b/tests/twisted/olpc/util.py
index d5c7349..4ae6bb7 100644
--- a/tests/twisted/olpc/util.py
+++ b/tests/twisted/olpc/util.py
@@ -178,10 +178,21 @@ def request_random_activity_view(q, stream, conn, max, id, activities):
activity = view.addElement((None, "activity"))
activity['room'] = room
activity['id'] = id
- # TODO: activity props
+ if props:
+ properties = activity.addElement((NS_OLPC_ACTIVITY_PROPS,
+ "properties"))
+ for child in properties_to_xml(props):
+ properties.addChild(child)
+
for jid, props in buddies:
- # TODO: buddy props
buddy = activity.addElement((None, 'buddy'))
buddy['jid'] = jid
+ if props:
+ properties = buddy.addElement((NS_OLPC_BUDDY_PROPS,
+ "properties"))
+ for child in properties_to_xml(props):
+ properties.addChild(child)
stream.send(reply)
+
+ return return_event.value[0]
--
1.5.6.5
More information about the Telepathy-commits
mailing list