[Telepathy-commits] [telepathy-gabble/master] factor out answer_error_to_pubsub_request to olpc/util.py
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:32 PDT 2008
20080703090842-7fe3f-cfd29033adddb90a4dc5f4f27f905392a4d81d27.gz
---
tests/twisted/olpc/current-activity.py | 14 ++------------
tests/twisted/olpc/util.py | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/tests/twisted/olpc/current-activity.py b/tests/twisted/olpc/current-activity.py
index 663baab..e9b054f 100644
--- a/tests/twisted/olpc/current-activity.py
+++ b/tests/twisted/olpc/current-activity.py
@@ -11,7 +11,7 @@ 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,\
- answer_to_current_act_pubsub_request
+ answer_to_current_act_pubsub_request, answer_error_to_pubsub_request
NS_OLPC_BUDDY_PROPS = "http://laptop.org/xmpp/buddy-properties"
NS_OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities"
@@ -178,17 +178,7 @@ def test(q, bus, conn, stream):
iq = event.stanza
# Alice is not Bob's friend so she can't query his PEP node
- reply = IQ(stream, "error")
- reply['id'] = iq['id']
- reply['from'] = iq['to']
- pubsub = reply.addElement((NS_PUBSUB, 'pubsub'))
- items = pubsub.addElement((None, 'items'))
- items['node'] = NS_OLPC_CURRENT_ACTIVITY
- error = reply.addElement((None, 'error'))
- error['type'] = 'auth'
- error.addElement((NS_STANZA, 'not-authorized'))
- error.addElement(("%s#errors" % NS_PUBSUB, 'presence-subscription-required'))
- stream.send(reply)
+ answer_error_to_pubsub_request(stream, iq, NS_OLPC_CURRENT_ACTIVITY)
# so Bob is considererd without current activity
q.expect('dbus-return', method='GetCurrentActivity',
diff --git a/tests/twisted/olpc/util.py b/tests/twisted/olpc/util.py
index 6f76ccd..e9539ad 100644
--- a/tests/twisted/olpc/util.py
+++ b/tests/twisted/olpc/util.py
@@ -1,5 +1,6 @@
from gabbletest import make_result_iq, acknowledge_iq, elem, elem_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"
@@ -12,7 +13,9 @@ NS_DISCO_INFO = "http://jabber.org/protocol/disco#info"
NS_DISCO_ITEMS = "http://jabber.org/protocol/disco#items"
NS_PUBSUB = 'http://jabber.org/protocol/pubsub'
NS_AMP = "http://jabber.org/protocol/amp"
+NS_STANZA = "urn:ietf:params:xml:ns:xmpp-stanzas"
+# Copied from Gadget
def parse_properties(elems):
properties = {}
@@ -119,3 +122,16 @@ def answer_to_current_act_pubsub_request(stream, request, id, room):
activity['type'] = id
reply.send()
+def answer_error_to_pubsub_request(stream, request, node):
+ # FIXME: we could find the node from the request
+ reply = IQ(stream, "error")
+ reply['id'] = request['id']
+ reply['from'] = request['to']
+ pubsub = reply.addElement((NS_PUBSUB, 'pubsub'))
+ items = pubsub.addElement((None, 'items'))
+ items['node'] = node
+ error = reply.addElement((None, 'error'))
+ error['type'] = 'auth'
+ error.addElement((NS_STANZA, 'not-authorized'))
+ error.addElement(("%s#errors" % NS_PUBSUB, 'presence-subscription-required'))
+ stream.send(reply)
--
1.5.6.5
More information about the Telepathy-commits
mailing list