summaryrefslogtreecommitdiff
path: root/tests/test_stream_xep_0030.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_stream_xep_0030.py')
-rw-r--r--tests/test_stream_xep_0030.py60
1 files changed, 54 insertions, 6 deletions
diff --git a/tests/test_stream_xep_0030.py b/tests/test_stream_xep_0030.py
index 1f989745..c960fc7a 100644
--- a/tests/test_stream_xep_0030.py
+++ b/tests/test_stream_xep_0030.py
@@ -1,3 +1,4 @@
+import sys
import time
import threading
@@ -11,6 +12,7 @@ class TestStreamDisco(SleekTest):
"""
def tearDown(self):
+ sys.excepthook = sys.__excepthook__
self.stream_close()
def testInfoEmptyDefaultNode(self):
@@ -406,10 +408,10 @@ class TestStreamDisco(SleekTest):
self.xmpp['xep_0030'].make_static(jid='tester@localhost',
node='testing')
- self.xmpp['xep_0030'].add_item(jid='tester@localhost',
+ self.xmpp['xep_0030'].add_item(ijid='tester@localhost',
node='testing',
- ijid='tester@localhost',
- inode='foo',
+ jid='tester@localhost',
+ subnode='foo',
name='Test')
self.recv("""
@@ -446,10 +448,10 @@ class TestStreamDisco(SleekTest):
self.xmpp['xep_0030'].make_static(jid='user@tester.localhost',
node='testing')
- self.xmpp['xep_0030'].add_item(jid='user@tester.localhost',
+ self.xmpp['xep_0030'].add_item(ijid='user@tester.localhost',
node='testing',
- ijid='user@tester.localhost',
- inode='foo',
+ jid='user@tester.localhost',
+ subnode='foo',
name='Test')
self.recv("""
@@ -524,5 +526,51 @@ class TestStreamDisco(SleekTest):
self.assertEqual(results, items,
"Unexpected items: %s" % results)
+ def testGetItemsIterator(self):
+ """Test interaction between XEP-0030 and XEP-0059 plugins."""
+
+ raised_exceptions = []
+
+ def catch_exception(*args, **kwargs):
+ raised_exceptions.append(True)
+
+ sys.excepthook = catch_exception
+
+ self.stream_start(mode='client',
+ plugins=['xep_0030', 'xep_0059'])
+
+ results = self.xmpp['xep_0030'].get_items(jid='foo@localhost',
+ node='bar',
+ iterator=True)
+ results.amount = 10
+
+ t = threading.Thread(name="get_items_iterator",
+ target=results.next)
+ t.start()
+
+ self.send("""
+ <iq id="2" type="get" to="foo@localhost">
+ <query xmlns="http://jabber.org/protocol/disco#items"
+ node="bar">
+ <set xmlns="http://jabber.org/protocol/rsm">
+ <max>10</max>
+ </set>
+ </query>
+ </iq>
+ """)
+ self.recv("""
+ <iq id="2" type="result" to="tester@localhost">
+ <query xmlns="http://jabber.org/protocol/disco#items">
+ <set xmlns="http://jabber.org/protocol/rsm">
+ </set>
+ </query>
+ </iq>
+ """)
+
+ t.join()
+
+ self.assertEqual(raised_exceptions, [True],
+ "StopIteration was not raised: %s" % raised_exceptions)
+
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamDisco)