From 7c7fa0f00826f304dab12faad297ef339a7de2a0 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sat, 8 Jan 2011 11:19:31 -0500 Subject: Add support for XEP-0059 to XEP-0030 plugin. --- tests/test_stream_xep_0030.py | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'tests/test_stream_xep_0030.py') diff --git a/tests/test_stream_xep_0030.py b/tests/test_stream_xep_0030.py index 25a41027..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): @@ -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(""" + + + + 10 + + + + """) + self.recv(""" + + + + + + + """) + + t.join() + + self.assertEqual(raised_exceptions, [True], + "StopIteration was not raised: %s" % raised_exceptions) + suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamDisco) -- cgit v1.2.3