From 086bf89d699c88ab89ad1e1975d6022335ca5c04 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sun, 3 Jul 2011 00:35:36 -0700 Subject: Added XEP-0066: Out-of-Band Data --- tests/test_stream_xep_0066.py | 72 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tests/test_stream_xep_0066.py (limited to 'tests') diff --git a/tests/test_stream_xep_0066.py b/tests/test_stream_xep_0066.py new file mode 100644 index 00000000..3dbaf840 --- /dev/null +++ b/tests/test_stream_xep_0066.py @@ -0,0 +1,72 @@ +import time +import threading + +from sleekxmpp.test import * + + +class TestOOB(SleekTest): + + def tearDown(self): + self.stream_close() + + def testSendOOB(self): + """Test sending an OOB transfer request.""" + self.stream_start(plugins=['xep_0066', 'xep_0030']) + + url = 'http://github.com/fritzy/SleekXMPP/blob/master/README' + + t = threading.Thread( + name='send_oob', + target=self.xmpp['xep_0066'].send_oob, + args=('user@example.com', url), + kwargs={'desc': 'SleekXMPP README'}) + + t.start() + + self.send(""" + + + http://github.com/fritzy/SleekXMPP/blob/master/README + SleekXMPP README + + + """) + + self.recv(""" + + """) + + t.join() + + def testReceiveOOB(self): + """Test receiving an OOB request.""" + self.stream_start(plugins=['xep_0066', 'xep_0030']) + + events = [] + + def receive_oob(iq): + events.append(iq['oob_transfer']['url']) + + self.xmpp.add_event_handler('oob_transfer', receive_oob) + + self.recv(""" + + + http://github.com/fritzy/SleekXMPP/blob/master/README + SleekXMPP README + + + """) + + time.sleep(0.1) + + self.assertEqual(events, + ['http://github.com/fritzy/SleekXMPP/blob/master/README'], + 'URL was not received: %s' % events) + + +suite = unittest.TestLoader().loadTestsFromTestCase(TestOOB) -- cgit v1.2.3