[Telepathy-commits] [telepathy-gabble/master] factor out send_buddy_changed_properties_msg to olpc/util.py

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:02:30 PDT 2008


20080702152700-7fe3f-881916fa5a33faf8e84925bea6e36ef23b2b67c4.gz
---
 tests/twisted/olpc/change-notifications.py |   20 +++-----------------
 tests/twisted/olpc/util.py                 |   17 +++++++++++++++++
 2 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/tests/twisted/olpc/change-notifications.py b/tests/twisted/olpc/change-notifications.py
index 66b52e6..6df73fb 100644
--- a/tests/twisted/olpc/change-notifications.py
+++ b/tests/twisted/olpc/change-notifications.py
@@ -10,7 +10,7 @@ from gabbletest import exec_test, make_result_iq, acknowledge_iq
 
 from twisted.words.xish import domish, xpath
 
-from util import announce_gadget
+from util import announce_gadget, send_buddy_changed_properties_msg
 
 NS_OLPC_BUDDY_PROPS = "http://laptop.org/xmpp/buddy-properties"
 NS_OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities"
@@ -36,22 +36,8 @@ def test(q, bus, conn, stream):
     announce_gadget(q, stream, disco_event.stanza)
 
     # 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)
+    send_buddy_changed_properties_msg(stream, 'alice at localhost',
+            {'color': ('str', '#005FE4,#00A0FF')})
 
     event = q.expect('dbus-signal', signal='PropertiesChanged')
     contact = event.args[0]
diff --git a/tests/twisted/olpc/util.py b/tests/twisted/olpc/util.py
index dd26bfe..1bd99ee 100644
--- a/tests/twisted/olpc/util.py
+++ b/tests/twisted/olpc/util.py
@@ -10,6 +10,7 @@ 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_PUBSUB = 'http://jabber.org/protocol/pubsub'
 NS_AMP = "http://jabber.org/protocol/amp"
 
 def parse_properties(elems):
@@ -68,3 +69,19 @@ def announce_gadget(q, stream, disco_stanza):
             elem('feature', var=NS_OLPC_ACTIVITY)()))
 
     stream.send(reply)
+
+def send_buddy_changed_properties_msg(stream, from_, props):
+    message = domish.Element(('jabber:client', 'message'))
+    message['from'] = from_
+    message['to'] = 'test at localhost'
+    event = message.addElement(("%s#event" % NS_PUBSUB, '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'))
+
+    for child in properties_to_xml(props):
+        properties.addChild(child)
+
+    stream.send(message)
-- 
1.5.6.5




More information about the Telepathy-commits mailing list