[Telepathy-commits] [telepathy-gabble/master] move gadget tests to twisted/olpc
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:05 PDT 2008
20080415103412-7fe3f-4be6aaf545fb922a55a5683dbf143c350e6bb3ec.gz
---
tests/olpc-buddy-prop-change.py | 187 --------------------------
tests/olpc-buddy-search.py | 109 ---------------
tests/twisted/olpc/olpc-buddy-prop-change.py | 187 ++++++++++++++++++++++++++
tests/twisted/olpc/olpc-buddy-search.py | 109 +++++++++++++++
4 files changed, 296 insertions(+), 296 deletions(-)
delete mode 100644 tests/olpc-buddy-prop-change.py
delete mode 100644 tests/olpc-buddy-search.py
create mode 100644 tests/twisted/olpc/olpc-buddy-prop-change.py
create mode 100644 tests/twisted/olpc/olpc-buddy-search.py
diff --git a/tests/olpc-buddy-prop-change.py b/tests/olpc-buddy-prop-change.py
deleted file mode 100644
index a90c53c..0000000
--- a/tests/olpc-buddy-prop-change.py
+++ /dev/null
@@ -1,187 +0,0 @@
-"""
-test OLPC Buddy properties change notifications
-"""
-
-import dbus
-
-from servicetest import call_async, EventPattern
-from gabbletest import exec_test, make_result_iq, acknowledge_iq
-
-from twisted.words.xish import domish, xpath
-
-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_DISCO_INFO = "http://jabber.org/protocol/disco#info"
-NS_DISCO_ITEMS = "http://jabber.org/protocol/disco#items"
-NS_AMP = "http://jabber.org/protocol/amp"
-
-def test(q, bus, conn, stream):
- conn.Connect()
-
- _, iq_event, disco_event = q.expect_many(
- EventPattern('dbus-signal', signal='StatusChanged', args=[0, 1]),
- EventPattern('stream-iq', to=None, query_ns='vcard-temp',
- query_name='vCard'),
- EventPattern('stream-iq', to='localhost', query_ns=NS_DISCO_ITEMS))
-
- acknowledge_iq(stream, iq_event.stanza)
-
- # announce Gadget service
- reply = make_result_iq(stream, disco_event.stanza)
- query = xpath.queryForNodes('/iq/query', reply)[0]
- item = query.addElement((None, 'item'))
- item['jid'] = 'gadget.localhost'
- stream.send(reply)
-
- # wait for Gadget disco#info query
- event = q.expect('stream-iq', to='gadget.localhost', query_ns=NS_DISCO_INFO)
- reply = make_result_iq(stream, event.stanza)
- query = xpath.queryForNodes('/iq/query', reply)[0]
- identity = query.addElement((None, 'identity'))
- identity['category'] = 'collaboration'
- identity['type'] = 'gadget'
- identity['name'] = 'OLPC Gadget'
- feature = query.addElement((None, 'feature'))
- feature['var'] = NS_OLPC_BUDDY
- feature = query.addElement((None, 'feature'))
- feature['var'] = NS_OLPC_ACTIVITY
- stream.send(reply)
-
- # Alice, one our friends changed her properties
- 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_BUDDY_PROPS
- item = items.addElement((None, 'item'))
- properties = item.addElement((NS_OLPC_BUDDY_PROPS, 'properties'))
-
- property = properties.addElement((None, 'property'))
- property['type'] = 'str'
- property['name'] = 'color'
- property.addContent('#005FE4,#00A0FF')
- stream.send(message)
-
- event = q.expect('dbus-signal', signal='PropertiesChanged')
- contact = event.args[0]
- props = event.args[1]
-
- assert props == {'color' : '#005FE4,#00A0FF'}
-
- # The indexer informs us about a buddy properties change.
- message = domish.Element(('jabber:client', 'message'))
- message['from'] = 'gadget.localhost'
- message['to'] = 'test at localhost'
-
- 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'))
- property['type'] = 'str'
- property['name'] = 'color'
- property.addContent('#FFFFFF,#AAAAAA')
-
- amp = message.addElement((NS_AMP, 'amp'))
- rule = amp.addElement((None, 'rule'))
- rule['condition'] = 'deliver-at'
- rule['value'] = 'stored'
- rule['action'] ='error'
-
- stream.send(message)
-
- event = q.expect('dbus-signal', signal='PropertiesChanged')
- contact = event.args[0]
- props = event.args[1]
-
- 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'
-
- stream.send(message)
-
- event = q.expect('dbus-signal', signal='CurrentActivityChanged')
- contact = event.args[0]
- activity = event.args[1]
- room = event.args[2]
- room_id = conn.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'] = 'gadget.localhost'
- 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'
- stream.send(message)
-
- event = q.expect('dbus-signal', signal='CurrentActivityChanged')
- contact = event.args[0]
- activity = event.args[1]
- room = event.args[2]
- room_id = conn.InspectHandles(2, [room])[0]
-
- assert activity == 'testactivity2'
- assert room_id == 'testroom2 at conference.localhost'
-
- # The indexer informs us about an activity properties change
- message = domish.Element(('jabber:client', 'message'))
- message['from'] = 'gadget.localhost'
- message['to'] = 'test at localhost'
-
- change = message.addElement((NS_OLPC_ACTIVITY, 'change'))
- change['activity'] = 'testactivity'
- change['room'] = 'testactivity at conference.localhost'
- properties = change.addElement((NS_OLPC_ACTIVITY_PROPS, 'properties'))
- property = properties.addElement((None, 'property'))
- property['type'] = 'str'
- property['name'] = 'tags'
- property.addContent('game')
-
- amp = message.addElement((NS_AMP, 'amp'))
- rule = amp.addElement((None, 'rule'))
- rule['condition'] = 'deliver-at'
- rule['value'] = 'stored'
- rule['action'] ='error'
- stream.send(message)
-
- event = q.expect('dbus-signal', signal='ActivityPropertiesChanged')
- room = event.args[0]
- properties = event.args[1]
-
- assert properties == {'tags': 'game'}
-
-if __name__ == '__main__':
- exec_test(test)
diff --git a/tests/olpc-buddy-search.py b/tests/olpc-buddy-search.py
deleted file mode 100644
index fe25994..0000000
--- a/tests/olpc-buddy-search.py
+++ /dev/null
@@ -1,109 +0,0 @@
-"""
-test OLPC search buddy
-"""
-
-import dbus
-
-from servicetest import call_async, EventPattern
-from gabbletest import exec_test, make_result_iq, acknowledge_iq
-
-from twisted.words.xish import domish, xpath
-from twisted.words.protocols.jabber.client import IQ
-
-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_PUBSUB = "http://jabber.org/protocol/pubsub"
-NS_DISCO_INFO = "http://jabber.org/protocol/disco#info"
-NS_DISCO_ITEMS = "http://jabber.org/protocol/disco#items"
-
-
-NS_AMP = "http://jabber.org/protocol/amp"
-
-def test(q, bus, conn, stream):
- conn.Connect()
-
- _, iq_event, disco_event = q.expect_many(
- EventPattern('dbus-signal', signal='StatusChanged', args=[0, 1]),
- EventPattern('stream-iq', to=None, query_ns='vcard-temp',
- query_name='vCard'),
- EventPattern('stream-iq', to='localhost', query_ns=NS_DISCO_ITEMS))
-
- acknowledge_iq(stream, iq_event.stanza)
-
- # announce Gadget service
- reply = make_result_iq(stream, disco_event.stanza)
- query = xpath.queryForNodes('/iq/query', reply)[0]
- item = query.addElement((None, 'item'))
- item['jid'] = 'gadget.localhost'
- stream.send(reply)
-
- # wait for Gadget disco#info query
- event = q.expect('stream-iq', to='gadget.localhost', query_ns=NS_DISCO_INFO)
- reply = make_result_iq(stream, event.stanza)
- query = xpath.queryForNodes('/iq/query', reply)[0]
- identity = query.addElement((None, 'identity'))
- identity['category'] = 'collaboration'
- identity['type'] = 'gadget'
- identity['name'] = 'OLPC Gadget'
- feature = query.addElement((None, 'feature'))
- feature['var'] = NS_OLPC_BUDDY
- feature = query.addElement((None, 'feature'))
- feature['var'] = NS_OLPC_ACTIVITY
- stream.send(reply)
-
- buddy_info_iface = dbus.Interface(conn, 'org.laptop.Telepathy.BuddyInfo')
-
- call_async(q, conn, 'RequestHandles', 1, ['bob at localhost'])
-
- event = q.expect('dbus-return', method='RequestHandles')
- handles = event.value[0]
- bob_handle = handles[0]
-
- call_async(q, buddy_info_iface, 'GetProperties', bob_handle)
-
- # wait for pubsub query
- event = q.expect('stream-iq', to='bob at localhost', query_ns=NS_PUBSUB)
- query = event.stanza
- assert query['to'] == 'bob at localhost'
-
- # send an error as reply
- reply = IQ(stream, 'error')
- reply['id'] = query['id']
- reply['to'] = 'alice at localhost'
- reply['from'] = 'bob at localhost'
- stream.send(reply)
-
- # wait for buddy search query
- event = q.expect('stream-iq', to='gadget.localhost',
- query_ns=NS_OLPC_BUDDY)
- buddies = xpath.queryForNodes('/iq/query/buddy', event.stanza)
- assert len(buddies) == 1
- buddy = buddies[0]
- assert buddy['jid'] == 'bob at localhost'
-
- # send reply to the search query
- reply = make_result_iq('stream', event.stanza)
- reply['from'] = 'gadget.localhost'
- reply['to'] = 'alice at localhost'
- query = xpath.queryForNodes('/iq/query', reply)[0]
- buddy = query.addElement((None, "buddy"))
- buddy['jid'] = 'bob at localhost'
- properties = buddy.addElement((NS_OLPC_BUDDY_PROPS, "properties"))
- property = properties.addElement((None, "property"))
- property['type'] = 'str'
- property['name'] = 'color'
- property.addContent('#005FE4,#00A0FF')
- stream.send(reply)
-
- event = q.expect('dbus-return', method='GetProperties')
- props = event.value[0]
-
- assert props == {'color': '#005FE4,#00A0FF' }
-
-if __name__ == '__main__':
- exec_test(test)
diff --git a/tests/twisted/olpc/olpc-buddy-prop-change.py b/tests/twisted/olpc/olpc-buddy-prop-change.py
new file mode 100644
index 0000000..a90c53c
--- /dev/null
+++ b/tests/twisted/olpc/olpc-buddy-prop-change.py
@@ -0,0 +1,187 @@
+"""
+test OLPC Buddy properties change notifications
+"""
+
+import dbus
+
+from servicetest import call_async, EventPattern
+from gabbletest import exec_test, make_result_iq, acknowledge_iq
+
+from twisted.words.xish import domish, xpath
+
+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_DISCO_INFO = "http://jabber.org/protocol/disco#info"
+NS_DISCO_ITEMS = "http://jabber.org/protocol/disco#items"
+NS_AMP = "http://jabber.org/protocol/amp"
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+
+ _, iq_event, disco_event = q.expect_many(
+ EventPattern('dbus-signal', signal='StatusChanged', args=[0, 1]),
+ EventPattern('stream-iq', to=None, query_ns='vcard-temp',
+ query_name='vCard'),
+ EventPattern('stream-iq', to='localhost', query_ns=NS_DISCO_ITEMS))
+
+ acknowledge_iq(stream, iq_event.stanza)
+
+ # announce Gadget service
+ reply = make_result_iq(stream, disco_event.stanza)
+ query = xpath.queryForNodes('/iq/query', reply)[0]
+ item = query.addElement((None, 'item'))
+ item['jid'] = 'gadget.localhost'
+ stream.send(reply)
+
+ # wait for Gadget disco#info query
+ event = q.expect('stream-iq', to='gadget.localhost', query_ns=NS_DISCO_INFO)
+ reply = make_result_iq(stream, event.stanza)
+ query = xpath.queryForNodes('/iq/query', reply)[0]
+ identity = query.addElement((None, 'identity'))
+ identity['category'] = 'collaboration'
+ identity['type'] = 'gadget'
+ identity['name'] = 'OLPC Gadget'
+ feature = query.addElement((None, 'feature'))
+ feature['var'] = NS_OLPC_BUDDY
+ feature = query.addElement((None, 'feature'))
+ feature['var'] = NS_OLPC_ACTIVITY
+ stream.send(reply)
+
+ # Alice, one our friends changed her properties
+ 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_BUDDY_PROPS
+ item = items.addElement((None, 'item'))
+ properties = item.addElement((NS_OLPC_BUDDY_PROPS, 'properties'))
+
+ property = properties.addElement((None, 'property'))
+ property['type'] = 'str'
+ property['name'] = 'color'
+ property.addContent('#005FE4,#00A0FF')
+ stream.send(message)
+
+ event = q.expect('dbus-signal', signal='PropertiesChanged')
+ contact = event.args[0]
+ props = event.args[1]
+
+ assert props == {'color' : '#005FE4,#00A0FF'}
+
+ # The indexer informs us about a buddy properties change.
+ message = domish.Element(('jabber:client', 'message'))
+ message['from'] = 'gadget.localhost'
+ message['to'] = 'test at localhost'
+
+ 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'))
+ property['type'] = 'str'
+ property['name'] = 'color'
+ property.addContent('#FFFFFF,#AAAAAA')
+
+ amp = message.addElement((NS_AMP, 'amp'))
+ rule = amp.addElement((None, 'rule'))
+ rule['condition'] = 'deliver-at'
+ rule['value'] = 'stored'
+ rule['action'] ='error'
+
+ stream.send(message)
+
+ event = q.expect('dbus-signal', signal='PropertiesChanged')
+ contact = event.args[0]
+ props = event.args[1]
+
+ 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'
+
+ stream.send(message)
+
+ event = q.expect('dbus-signal', signal='CurrentActivityChanged')
+ contact = event.args[0]
+ activity = event.args[1]
+ room = event.args[2]
+ room_id = conn.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'] = 'gadget.localhost'
+ 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'
+ stream.send(message)
+
+ event = q.expect('dbus-signal', signal='CurrentActivityChanged')
+ contact = event.args[0]
+ activity = event.args[1]
+ room = event.args[2]
+ room_id = conn.InspectHandles(2, [room])[0]
+
+ assert activity == 'testactivity2'
+ assert room_id == 'testroom2 at conference.localhost'
+
+ # The indexer informs us about an activity properties change
+ message = domish.Element(('jabber:client', 'message'))
+ message['from'] = 'gadget.localhost'
+ message['to'] = 'test at localhost'
+
+ change = message.addElement((NS_OLPC_ACTIVITY, 'change'))
+ change['activity'] = 'testactivity'
+ change['room'] = 'testactivity at conference.localhost'
+ properties = change.addElement((NS_OLPC_ACTIVITY_PROPS, 'properties'))
+ property = properties.addElement((None, 'property'))
+ property['type'] = 'str'
+ property['name'] = 'tags'
+ property.addContent('game')
+
+ amp = message.addElement((NS_AMP, 'amp'))
+ rule = amp.addElement((None, 'rule'))
+ rule['condition'] = 'deliver-at'
+ rule['value'] = 'stored'
+ rule['action'] ='error'
+ stream.send(message)
+
+ event = q.expect('dbus-signal', signal='ActivityPropertiesChanged')
+ room = event.args[0]
+ properties = event.args[1]
+
+ assert properties == {'tags': 'game'}
+
+if __name__ == '__main__':
+ exec_test(test)
diff --git a/tests/twisted/olpc/olpc-buddy-search.py b/tests/twisted/olpc/olpc-buddy-search.py
new file mode 100644
index 0000000..fe25994
--- /dev/null
+++ b/tests/twisted/olpc/olpc-buddy-search.py
@@ -0,0 +1,109 @@
+"""
+test OLPC search buddy
+"""
+
+import dbus
+
+from servicetest import call_async, EventPattern
+from gabbletest import exec_test, make_result_iq, acknowledge_iq
+
+from twisted.words.xish import domish, xpath
+from twisted.words.protocols.jabber.client import IQ
+
+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_PUBSUB = "http://jabber.org/protocol/pubsub"
+NS_DISCO_INFO = "http://jabber.org/protocol/disco#info"
+NS_DISCO_ITEMS = "http://jabber.org/protocol/disco#items"
+
+
+NS_AMP = "http://jabber.org/protocol/amp"
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+
+ _, iq_event, disco_event = q.expect_many(
+ EventPattern('dbus-signal', signal='StatusChanged', args=[0, 1]),
+ EventPattern('stream-iq', to=None, query_ns='vcard-temp',
+ query_name='vCard'),
+ EventPattern('stream-iq', to='localhost', query_ns=NS_DISCO_ITEMS))
+
+ acknowledge_iq(stream, iq_event.stanza)
+
+ # announce Gadget service
+ reply = make_result_iq(stream, disco_event.stanza)
+ query = xpath.queryForNodes('/iq/query', reply)[0]
+ item = query.addElement((None, 'item'))
+ item['jid'] = 'gadget.localhost'
+ stream.send(reply)
+
+ # wait for Gadget disco#info query
+ event = q.expect('stream-iq', to='gadget.localhost', query_ns=NS_DISCO_INFO)
+ reply = make_result_iq(stream, event.stanza)
+ query = xpath.queryForNodes('/iq/query', reply)[0]
+ identity = query.addElement((None, 'identity'))
+ identity['category'] = 'collaboration'
+ identity['type'] = 'gadget'
+ identity['name'] = 'OLPC Gadget'
+ feature = query.addElement((None, 'feature'))
+ feature['var'] = NS_OLPC_BUDDY
+ feature = query.addElement((None, 'feature'))
+ feature['var'] = NS_OLPC_ACTIVITY
+ stream.send(reply)
+
+ buddy_info_iface = dbus.Interface(conn, 'org.laptop.Telepathy.BuddyInfo')
+
+ call_async(q, conn, 'RequestHandles', 1, ['bob at localhost'])
+
+ event = q.expect('dbus-return', method='RequestHandles')
+ handles = event.value[0]
+ bob_handle = handles[0]
+
+ call_async(q, buddy_info_iface, 'GetProperties', bob_handle)
+
+ # wait for pubsub query
+ event = q.expect('stream-iq', to='bob at localhost', query_ns=NS_PUBSUB)
+ query = event.stanza
+ assert query['to'] == 'bob at localhost'
+
+ # send an error as reply
+ reply = IQ(stream, 'error')
+ reply['id'] = query['id']
+ reply['to'] = 'alice at localhost'
+ reply['from'] = 'bob at localhost'
+ stream.send(reply)
+
+ # wait for buddy search query
+ event = q.expect('stream-iq', to='gadget.localhost',
+ query_ns=NS_OLPC_BUDDY)
+ buddies = xpath.queryForNodes('/iq/query/buddy', event.stanza)
+ assert len(buddies) == 1
+ buddy = buddies[0]
+ assert buddy['jid'] == 'bob at localhost'
+
+ # send reply to the search query
+ reply = make_result_iq('stream', event.stanza)
+ reply['from'] = 'gadget.localhost'
+ reply['to'] = 'alice at localhost'
+ query = xpath.queryForNodes('/iq/query', reply)[0]
+ buddy = query.addElement((None, "buddy"))
+ buddy['jid'] = 'bob at localhost'
+ properties = buddy.addElement((NS_OLPC_BUDDY_PROPS, "properties"))
+ property = properties.addElement((None, "property"))
+ property['type'] = 'str'
+ property['name'] = 'color'
+ property.addContent('#005FE4,#00A0FF')
+ stream.send(reply)
+
+ event = q.expect('dbus-return', method='GetProperties')
+ props = event.value[0]
+
+ assert props == {'color': '#005FE4,#00A0FF' }
+
+if __name__ == '__main__':
+ exec_test(test)
--
1.5.6.5
More information about the Telepathy-commits
mailing list