summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-08-31 15:04:46 -0700
committerLance Stout <lancestout@gmail.com>2011-08-31 15:04:46 -0700
commita1bbb719e17645959899f862475a1dd28a34ed55 (patch)
treec6fd711a4cb7e8fde936238b09d8392537a4e23e
parent46f23f73482fcd1e1b71eda9ec6d42803f6c7d1a (diff)
downloadslixmpp-a1bbb719e17645959899f862475a1dd28a34ed55.tar.gz
slixmpp-a1bbb719e17645959899f862475a1dd28a34ed55.tar.bz2
slixmpp-a1bbb719e17645959899f862475a1dd28a34ed55.tar.xz
slixmpp-a1bbb719e17645959899f862475a1dd28a34ed55.zip
Test publishing multiple items, and with options.
-rw-r--r--tests/test_stream_xep_0060.py100
1 files changed, 98 insertions, 2 deletions
diff --git a/tests/test_stream_xep_0060.py b/tests/test_stream_xep_0060.py
index 9feb629c..50bbe37a 100644
--- a/tests/test_stream_xep_0060.py
+++ b/tests/test_stream_xep_0060.py
@@ -471,11 +471,107 @@ class TestStreamPubsub(SleekTest):
def testPublishMulti(self):
"""Test publishing multiple items."""
- pass
+ payload1 = AtomEntry()
+ payload1['title'] = 'Test 1'
+
+ payload2 = AtomEntry()
+ payload2['title'] = 'Test 2'
+
+ register_stanza_plugin(self.xmpp['xep_0060'].stanza.Item, AtomEntry)
+
+ t = threading.Thread(name='publish_single',
+ target=self.xmpp['xep_0060'].publish,
+ args=('pubsub.example.com', 'somenode'),
+ kwargs={'items': [('ID1', payload1),
+ ('ID2', payload2)]})
+ t.start()
+
+ self.send("""
+ <iq type="set" id="1" to="pubsub.example.com">
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
+ <publish node="somenode">
+ <item id="ID1">
+ <entry xmlns="http://www.w3.org/2005/Atom">
+ <title>Test 1</title>
+ </entry>
+ </item>
+ <item id="ID2">
+ <entry xmlns="http://www.w3.org/2005/Atom">
+ <title>Test 2</title>
+ </entry>
+ </item>
+ </publish>
+ </pubsub>
+ </iq>
+ """, use_values=False)
+
+ self.recv("""
+ <iq type="result" id="1"
+ to="tester@localhost" from="pubsub.example.com" />
+ """)
+
+ t.join()
def testPublishMultiOptions(self):
"""Test publishing multiple items, with options."""
- pass
+ payload1 = AtomEntry()
+ payload1['title'] = 'Test 1'
+
+ payload2 = AtomEntry()
+ payload2['title'] = 'Test 2'
+
+ register_stanza_plugin(self.xmpp['xep_0060'].stanza.Item, AtomEntry)
+
+ options = self.xmpp['xep_0004'].make_form()
+ options.add_field(var='FORM_TYPE', ftype='hidden',
+ value='http://jabber.org/protocol/pubsub#publish-options')
+ options.add_field(var='pubsub#access_model', ftype='text-single',
+ value='presence')
+ options['type'] = 'submit'
+
+ t = threading.Thread(name='publish_single',
+ target=self.xmpp['xep_0060'].publish,
+ args=('pubsub.example.com', 'somenode'),
+ kwargs={'items': [('ID1', payload1),
+ ('ID2', payload2)],
+ 'options': options})
+ t.start()
+
+ self.send("""
+ <iq type="set" id="1" to="pubsub.example.com">
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
+ <publish node="somenode">
+ <item id="ID1">
+ <entry xmlns="http://www.w3.org/2005/Atom">
+ <title>Test 1</title>
+ </entry>
+ </item>
+ <item id="ID2">
+ <entry xmlns="http://www.w3.org/2005/Atom">
+ <title>Test 2</title>
+ </entry>
+ </item>
+ </publish>
+ <publish-options>
+ <x xmlns="jabber:x:data" type="submit">
+ <field var="FORM_TYPE">
+ <value>http://jabber.org/protocol/pubsub#publish-options</value>
+ </field>
+ <field var="pubsub#access_model">
+ <value>presence</value>
+ </field>
+ </x>
+ </publish-options>
+ </pubsub>
+ </iq>
+ """, use_values=False)
+
+ self.recv("""
+ <iq type="result" id="1"
+ to="tester@localhost" from="pubsub.example.com" />
+ """)
+
+ t.join()
def testRetract(self):
"""Test deleting an item."""