summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stream_xep_0060.py106
1 files changed, 106 insertions, 0 deletions
diff --git a/tests/test_stream_xep_0060.py b/tests/test_stream_xep_0060.py
new file mode 100644
index 00000000..cb93bbf6
--- /dev/null
+++ b/tests/test_stream_xep_0060.py
@@ -0,0 +1,106 @@
+import sys
+import time
+import threading
+
+from sleekxmpp.test import *
+
+
+class TestStreamPubsub(SleekTest):
+
+ """
+ Test using the XEP-0030 plugin.
+ """
+
+ def setUp(self):
+ self.stream_start()
+
+ def tearDown(self):
+ self.stream_close()
+
+ def testCreateInstantNode(self):
+ """Test creating an instant node"""
+ t = threading.Thread(name='create_node',
+ target=self.xmpp['xep_0060'].create_node,
+ args=('pubsub.example.com', None))
+ t.start()
+
+ self.send("""
+ <iq type="set" id="1" to="pubsub.example.com">
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
+ <create />
+ </pubsub>
+ </iq>
+ """)
+
+ self.recv("""
+ <iq type="result" id="1"
+ to="tester@localhost" from="pubsub.example.com">
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
+ <create node="25e3d37dabbab9541f7523321421edc5bfeb2dae" />
+ </pubsub>
+ </iq>
+ """)
+
+ t.join()
+
+ def testCreateNodeNoConfig(self):
+ """Test creating a node without a config"""
+ t = threading.Thread(name='create_node',
+ target=self.xmpp['xep_0060'].create_node,
+ args=('pubsub.example.com', 'princely_musings'))
+ t.start()
+
+ self.send("""
+ <iq type="set" id="1" to="pubsub.example.com">
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
+ <create node="princely_musings" />
+ </pubsub>
+ </iq>
+ """)
+
+ self.recv("""
+ <iq type="result" id="1"
+ to="tester@localhost" from="pubsub.example.com" />
+ """)
+
+ t.join()
+
+ def testCreateNodeConfig(self):
+ """Test creating a node with a config"""
+ form = self.xmpp['xep_0004'].stanza.Form()
+ form['type'] = 'submit'
+ form.add_field(var='pubsub#access_model', value='whitelist')
+
+ t = threading.Thread(name='create_node',
+ target=self.xmpp['xep_0060'].create_node,
+ args=('pubsub.example.com', 'princely_musings'),
+ kwargs={'config': form})
+ t.start()
+
+ self.send("""
+ <iq type="set" id="1" to="pubsub.example.com">
+ <pubsub xmlns="http://jabber.org/protocol/pubsub">
+ <create node="princely_musings" />
+ <configure>
+ <x xmlns="jabber:x:data" type="submit">
+ <field var="pubsub#access_model">
+ <value>whitelist</value>
+ </field>
+ <field var="FORM_TYPE">
+ <value>http://jabber.org/protocol/pubsub#node_config</value>
+ </field>
+ </x>
+ </configure>
+ </pubsub>
+ </iq>
+ """)
+
+ self.recv("""
+ <iq type="result" id="1"
+ to="tester@localhost" from="pubsub.example.com" />
+ """)
+
+ t.join()
+
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPubsub)