[Telepathy-commits] [telepathy-gabble/master] olpc-buddy-prop-change.py: use disco to discover gadget's jid
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:01 PDT 2008
20071214143106-7fe3f-8d685c607340e6957fc033c63be8b14235472bb5.gz
---
tests/olpc-buddy-prop-change.py | 34 +++++++++++++++++++++++++++++-----
1 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/tests/olpc-buddy-prop-change.py b/tests/olpc-buddy-prop-change.py
index c74bbe5..a90c53c 100644
--- a/tests/olpc-buddy-prop-change.py
+++ b/tests/olpc-buddy-prop-change.py
@@ -16,18 +16,42 @@ 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 = q.expect_many(
+ _, 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'))
+ 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'
@@ -54,7 +78,7 @@ def test(q, bus, conn, stream):
# The indexer informs us about a buddy properties change.
message = domish.Element(('jabber:client', 'message'))
- message['from'] = 'index.jabber.laptop.org'
+ message['from'] = 'gadget.localhost'
message['to'] = 'test at localhost'
change = message.addElement((NS_OLPC_BUDDY, 'change'))
@@ -107,7 +131,7 @@ def test(q, bus, conn, stream):
# The indexer informs us about a buddy current-activity change.
message = domish.Element(('jabber:client', 'message'))
- message['from'] = 'index.jabber.laptop.org'
+ message['from'] = 'gadget.localhost'
message['to'] = 'test at localhost'
change = message.addElement((NS_OLPC_BUDDY, 'change'))
@@ -134,7 +158,7 @@ def test(q, bus, conn, stream):
# The indexer informs us about an activity properties change
message = domish.Element(('jabber:client', 'message'))
- message['from'] = 'index.jabber.laptop.org'
+ message['from'] = 'gadget.localhost'
message['to'] = 'test at localhost'
change = message.addElement((NS_OLPC_ACTIVITY, 'change'))
--
1.5.6.5
More information about the Telepathy-commits
mailing list