diff options
author | Lance Stout <lancestout@gmail.com> | 2011-08-26 12:14:57 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2011-08-26 12:14:57 -0700 |
commit | d12949ff1cf1a6405d6f430bc8ca77567b7cc9be (patch) | |
tree | 20d702c74c13d31b465029de96a53a355e576073 /tests/test_stream_xep_0060.py | |
parent | e3e985220e9599ed34158acc61866619e8f06308 (diff) | |
download | slixmpp-d12949ff1cf1a6405d6f430bc8ca77567b7cc9be.tar.gz slixmpp-d12949ff1cf1a6405d6f430bc8ca77567b7cc9be.tar.bz2 slixmpp-d12949ff1cf1a6405d6f430bc8ca77567b7cc9be.tar.xz slixmpp-d12949ff1cf1a6405d6f430bc8ca77567b7cc9be.zip |
Fix typos in XEP-0060, start of docs and tests.
Diffstat (limited to 'tests/test_stream_xep_0060.py')
-rw-r--r-- | tests/test_stream_xep_0060.py | 106 |
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) |