[Telepathy-commits] [telepathy-gabble/master] factor out announce_gadget to olpc_test_helper
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:28 PDT 2008
20080702091819-7fe3f-dd70a4dfe2a838f0a304e9a22718952eaebcb26e.gz
---
tests/twisted/olpc/change-notifications.py | 22 +----------------
tests/twisted/olpc/current-activity.py | 22 +----------------
tests/twisted/olpc/gadget-invite.py | 24 ++----------------
tests/twisted/olpc/gadget-publish.py | 24 ++----------------
tests/twisted/olpc/olpc-activity-search.py | 23 +----------------
tests/twisted/olpc/olpc-buddy-search.py | 24 ++----------------
tests/twisted/olpc/olpc_test_helper.py | 35 ++++++++++++++++++++++++++++
7 files changed, 50 insertions(+), 124 deletions(-)
create mode 100644 tests/twisted/olpc/olpc_test_helper.py
diff --git a/tests/twisted/olpc/change-notifications.py b/tests/twisted/olpc/change-notifications.py
index 121308a..bd14f48 100644
--- a/tests/twisted/olpc/change-notifications.py
+++ b/tests/twisted/olpc/change-notifications.py
@@ -9,6 +9,7 @@ from servicetest import call_async, EventPattern
from gabbletest import exec_test, make_result_iq, acknowledge_iq
from twisted.words.xish import domish, xpath
+from olpc_test_helper import announce_gadget
NS_OLPC_BUDDY_PROPS = "http://laptop.org/xmpp/buddy-properties"
NS_OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities"
@@ -32,26 +33,7 @@ def test(q, bus, conn, stream):
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)
+ announce_gadget(q, stream, disco_event.stanza)
# Alice, one our friends changed her properties
message = domish.Element(('jabber:client', 'message'))
diff --git a/tests/twisted/olpc/current-activity.py b/tests/twisted/olpc/current-activity.py
index 2a1bb6e..80960a2 100644
--- a/tests/twisted/olpc/current-activity.py
+++ b/tests/twisted/olpc/current-activity.py
@@ -9,6 +9,7 @@ from gabbletest import exec_test, make_result_iq, acknowledge_iq
from twisted.words.protocols.jabber.client import IQ
from twisted.words.xish import domish, xpath
+from olpc_test_helper import announce_gadget
NS_OLPC_BUDDY_PROPS = "http://laptop.org/xmpp/buddy-properties"
NS_OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities"
@@ -34,26 +35,7 @@ def test(q, bus, conn, stream):
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)
+ announce_gadget(q, stream, disco_event.stanza)
buddy_info_iface = dbus.Interface(conn, 'org.laptop.Telepathy.BuddyInfo')
gadget_iface = dbus.Interface(conn, 'org.laptop.Telepathy.Gadget')
diff --git a/tests/twisted/olpc/gadget-invite.py b/tests/twisted/olpc/gadget-invite.py
index 15547f0..9929871 100644
--- a/tests/twisted/olpc/gadget-invite.py
+++ b/tests/twisted/olpc/gadget-invite.py
@@ -10,6 +10,8 @@ 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 olpc_test_helper import announce_gadget
+
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"
@@ -63,31 +65,11 @@ def test(q, bus, conn, stream):
EventPattern('stream-iq', to='localhost', query_ns=NS_DISCO_ITEMS))
acknowledge_iq(stream, iq_event.stanza)
+ announce_gadget(q, stream, disco_event.stanza)
act_prop_iface = dbus.Interface(conn, 'org.laptop.Telepathy.ActivityProperties')
buddy_info_iface = dbus.Interface(conn, 'org.laptop.Telepathy.BuddyInfo')
- # 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)
-
q.expect_many(EventPattern('dbus-signal', signal='BuddyGadgetDiscovered'),
EventPattern('dbus-signal', signal='ActivityGadgetDiscovered'))
diff --git a/tests/twisted/olpc/gadget-publish.py b/tests/twisted/olpc/gadget-publish.py
index 4ece4b4..1ef83eb 100644
--- a/tests/twisted/olpc/gadget-publish.py
+++ b/tests/twisted/olpc/gadget-publish.py
@@ -10,6 +10,8 @@ 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 olpc_test_helper import announce_gadget
+
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"
@@ -34,27 +36,7 @@ def test(q, bus, conn, stream):
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)
+ announce_gadget(q, stream, disco_event.stanza)
q.expect_many(EventPattern('dbus-signal', signal='BuddyGadgetDiscovered'),
EventPattern('dbus-signal', signal='ActivityGadgetDiscovered'))
diff --git a/tests/twisted/olpc/olpc-activity-search.py b/tests/twisted/olpc/olpc-activity-search.py
index bf42e5d..3b30e9f 100644
--- a/tests/twisted/olpc/olpc-activity-search.py
+++ b/tests/twisted/olpc/olpc-activity-search.py
@@ -9,6 +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 olpc_test_helper import announce_gadget
NS_OLPC_BUDDY_PROPS = "http://laptop.org/xmpp/buddy-properties"
NS_OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities"
@@ -43,27 +44,7 @@ def test(q, bus, conn, stream):
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)
+ announce_gadget(q, stream, disco_event.stanza)
activity_prop_iface = dbus.Interface(conn,
'org.laptop.Telepathy.ActivityProperties')
diff --git a/tests/twisted/olpc/olpc-buddy-search.py b/tests/twisted/olpc/olpc-buddy-search.py
index c6ccd0d..73fe2a5 100644
--- a/tests/twisted/olpc/olpc-buddy-search.py
+++ b/tests/twisted/olpc/olpc-buddy-search.py
@@ -10,6 +10,8 @@ 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
+from olpc_test_helper import announce_gadget
+
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"
@@ -34,27 +36,7 @@ def test(q, bus, conn, stream):
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)
+ announce_gadget(q, stream, disco_event.stanza)
buddy_info_iface = dbus.Interface(conn, 'org.laptop.Telepathy.BuddyInfo')
gadget_iface = dbus.Interface(conn, 'org.laptop.Telepathy.Gadget')
diff --git a/tests/twisted/olpc/olpc_test_helper.py b/tests/twisted/olpc/olpc_test_helper.py
new file mode 100644
index 0000000..81e2c60
--- /dev/null
+++ b/tests/twisted/olpc/olpc_test_helper.py
@@ -0,0 +1,35 @@
+from gabbletest import 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 announce_gadget(q, stream, disco_stanza):
+ # announce Gadget service
+ reply = make_result_iq(stream, disco_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)
--
1.5.6.5
More information about the Telepathy-commits
mailing list