From 1e2665df19a866d5676abec566b9d8f190ecdc80 Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 12 Feb 2015 12:23:47 +0100 Subject: Update the test suite. - monkey-patch our own monkey-patched idle_call to run events immediatly rather than adding them to the event queue, and add a fake transport with a fake socket. - remove the test file related to xep_0059 as it relies on blocking behavior, and comment out one xep_0030 test uses xep_0059 - remove many instances of threading and sleep()s because they do nothing except waste time and introduce race conditions. - keep exactly two sleep() in IoT xeps because they rely on timeouts --- tests/test_stream_xep_0030.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (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 98d51618..f85dfaea 100644 --- a/tests/test_stream_xep_0030.py +++ b/tests/test_stream_xep_0030.py @@ -288,10 +288,7 @@ class TestStreamDisco(SlixTest): self.xmpp.add_event_handler('disco_info', handle_disco_info) - t = threading.Thread(name="get_info", - target=self.xmpp['xep_0030'].get_info, - args=('user@localhost', 'foo')) - t.start() + self.xmpp['xep_0030'].get_info('user@localhost', 'foo') self.send(""" @@ -310,11 +307,6 @@ class TestStreamDisco(SlixTest): """) - # Wait for disco#info request to be received. - t.join() - - time.sleep(0.1) - self.assertEqual(events, set(('disco_info',)), "Disco info event was not triggered: %s" % events) @@ -491,10 +483,7 @@ class TestStreamDisco(SlixTest): self.xmpp.add_event_handler('disco_items', handle_disco_items) - t = threading.Thread(name="get_items", - target=self.xmpp['xep_0030'].get_items, - args=('user@localhost', 'foo')) - t.start() + self.xmpp['xep_0030'].get_items('user@localhost', 'foo') self.send(""" @@ -513,11 +502,6 @@ class TestStreamDisco(SlixTest): """) - # Wait for disco#items request to be received. - t.join() - - time.sleep(0.1) - items = set([('user@localhost', 'bar', 'Test'), ('user@localhost', 'baz', 'Test 2')]) self.assertEqual(events, set(('disco_items',)), @@ -525,6 +509,7 @@ class TestStreamDisco(SlixTest): self.assertEqual(results, items, "Unexpected items: %s" % results) + ''' def testGetItemsIterator(self): """Test interaction between XEP-0030 and XEP-0059 plugins.""" @@ -571,6 +556,7 @@ class TestStreamDisco(SlixTest): self.assertEqual(raised_exceptions, [True], "StopIteration was not raised: %s" % raised_exceptions) + ''' suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamDisco) -- cgit v1.2.3