summaryrefslogtreecommitdiff
path: root/tests/test_stream_xep_0030.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-11-18 15:50:45 -0500
committerLance Stout <lancestout@gmail.com>2010-11-18 15:50:45 -0500
commitab25301953138343d3d295aaa8872de9c5bc2cf9 (patch)
treeaf0c9bf9edd0814320d67f7a41550732095497ad /tests/test_stream_xep_0030.py
parent291b118aca29b32679f1b2e55d0de98918fe4455 (diff)
downloadslixmpp-ab25301953138343d3d295aaa8872de9c5bc2cf9.tar.gz
slixmpp-ab25301953138343d3d295aaa8872de9c5bc2cf9.tar.bz2
slixmpp-ab25301953138343d3d295aaa8872de9c5bc2cf9.tar.xz
slixmpp-ab25301953138343d3d295aaa8872de9c5bc2cf9.zip
Adding stream tests for XEP-0030.
Fixed some errors when responding to disco requests.
Diffstat (limited to 'tests/test_stream_xep_0030.py')
-rw-r--r--tests/test_stream_xep_0030.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/test_stream_xep_0030.py b/tests/test_stream_xep_0030.py
new file mode 100644
index 00000000..5efce788
--- /dev/null
+++ b/tests/test_stream_xep_0030.py
@@ -0,0 +1,83 @@
+import time
+from sleekxmpp.test import *
+
+
+class TestStreamDisco(SleekTest):
+ """
+ Test using the XEP-0030 plugin.
+ """
+
+ def tearDown(self):
+ self.stream_close()
+
+ def testInfoEmptyNode(self):
+ """
+ Info queries to a node MUST have at least one identity
+ and feature, namely http://jabber.org/protocol/disco#info.
+
+ Since the XEP-0030 plugin is loaded, a disco response should
+ be generated and not an error result.
+ """
+ self.stream_start(plugins=['xep_0030'])
+
+ self.recv("""
+ <iq type="get" id="test">
+ <query xmlns="http://jabber.org/protocol/disco#info" />
+ </iq>
+ """)
+
+ self.send("""
+ <iq type="result" id="test">
+ <query xmlns="http://jabber.org/protocol/disco#info">
+ <identity category="client" type="bot" />
+ <feature var="http://jabber.org/protocol/disco#info" />
+ </query>
+ </iq>""")
+
+ def testInfoEmptyNodeComponent(self):
+ """
+ Test requesting an empty node using a Component.
+ """
+ self.stream_start(mode='component',
+ plugins=['xep_0030'])
+
+ self.recv("""
+ <iq type="get" id="test">
+ <query xmlns="http://jabber.org/protocol/disco#info" />
+ </iq>
+ """)
+
+ self.send("""
+ <iq type="result" id="test">
+ <query xmlns="http://jabber.org/protocol/disco#info">
+ <identity category="component" type="generic" />
+ <feature var="http://jabber.org/protocol/disco#info" />
+ </query>
+ </iq>""")
+
+ def testInfoIncludeNode(self):
+ """
+ Results for info queries directed to a particular node MUST
+ include the node in the query response.
+ """
+ self.stream_start(plugins=['xep_0030'])
+
+ self.xmpp['xep_0030'].add_node('testing')
+
+ self.recv("""
+ <iq type="get" id="test">
+ <query xmlns="http://jabber.org/protocol/disco#info"
+ node="testing" />
+ </iq>
+ """)
+
+ self.send("""
+ <iq type="result" id="test">
+ <query xmlns="http://jabber.org/protocol/disco#info"
+ node="testing">
+ </query>
+ </iq>""",
+ method='mask')
+
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamDisco)