diff options
Diffstat (limited to 'tests/test_stream_xep_0047.py')
-rw-r--r-- | tests/test_stream_xep_0047.py | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/tests/test_stream_xep_0047.py b/tests/test_stream_xep_0047.py index 0515bca5..ecba2445 100644 --- a/tests/test_stream_xep_0047.py +++ b/tests/test_stream_xep_0047.py @@ -1,11 +1,12 @@ +import asyncio import threading import time import unittest -from sleekxmpp.test import SleekTest +from slixmpp.test import SlixTest -class TestInBandByteStreams(SleekTest): +class TestInBandByteStreams(SlixTest): def setUp(self): self.stream_start(plugins=['xep_0047', 'xep_0030']) @@ -24,11 +25,8 @@ class TestInBandByteStreams(SleekTest): self.xmpp.add_event_handler('ibb_stream_start', on_stream_start) - t = threading.Thread(name='open_stream', - target=self.xmpp['xep_0047'].open_stream, - args=('tester@localhost/receiver',), - kwargs={'sid': 'testing'}) - t.start() + self.xmpp['xep_0047'].open_stream('tester@localhost/receiver', + sid='testing') self.send(""" <iq type="set" to="tester@localhost/receiver" id="1"> @@ -45,10 +43,6 @@ class TestInBandByteStreams(SleekTest): from="tester@localhost/receiver" /> """) - t.join() - - time.sleep(0.2) - self.assertEqual(events, ['ibb_stream_start']) def testAysncOpenStream(self): @@ -64,13 +58,9 @@ class TestInBandByteStreams(SleekTest): self.xmpp.add_event_handler('ibb_stream_start', on_stream_start) - t = threading.Thread(name='open_stream', - target=self.xmpp['xep_0047'].open_stream, - args=('tester@localhost/receiver',), - kwargs={'sid': 'testing', - 'block': False, - 'callback': stream_callback}) - t.start() + self.xmpp['xep_0047'].open_stream('tester@localhost/receiver', + sid='testing', + callback=stream_callback) self.send(""" <iq type="set" to="tester@localhost/receiver" id="1"> @@ -87,12 +77,9 @@ class TestInBandByteStreams(SleekTest): from="tester@localhost/receiver" /> """) - t.join() - - time.sleep(0.2) - self.assertEqual(events, set(['ibb_stream_start', 'callback'])) + @asyncio.coroutine def testSendData(self): """Test sending data over an in-band bytestream.""" @@ -108,11 +95,8 @@ class TestInBandByteStreams(SleekTest): self.xmpp.add_event_handler('ibb_stream_start', on_stream_start) self.xmpp.add_event_handler('ibb_stream_data', on_stream_data) - t = threading.Thread(name='open_stream', - target=self.xmpp['xep_0047'].open_stream, - args=('tester@localhost/receiver',), - kwargs={'sid': 'testing'}) - t.start() + self.xmpp['xep_0047'].open_stream('tester@localhost/receiver', + sid='testing') self.send(""" <iq type="set" to="tester@localhost/receiver" id="1"> @@ -129,15 +113,11 @@ class TestInBandByteStreams(SleekTest): from="tester@localhost/receiver" /> """) - t.join() - - time.sleep(0.2) - stream = streams[0] # Test sending data out - stream.send("Testing") + yield from stream.send("Testing") self.send(""" <iq type="set" id="2" |