summaryrefslogtreecommitdiff
path: root/tests/test_stream_xep_0066.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-07-03 00:39:14 -0700
committerLance Stout <lancestout@gmail.com>2011-07-03 00:39:14 -0700
commit20df6348a4c8262a40578d84c934f9a15431d925 (patch)
treec6dc62a271c0125bf623a2376cc64c08e00ae7ad /tests/test_stream_xep_0066.py
parent847510c6b577f889cdba5deaa0bb271475cc7c7f (diff)
parent086bf89d699c88ab89ad1e1975d6022335ca5c04 (diff)
downloadslixmpp-20df6348a4c8262a40578d84c934f9a15431d925.tar.gz
slixmpp-20df6348a4c8262a40578d84c934f9a15431d925.tar.bz2
slixmpp-20df6348a4c8262a40578d84c934f9a15431d925.tar.xz
slixmpp-20df6348a4c8262a40578d84c934f9a15431d925.zip
Merge branch 'develop' into exceptions
Diffstat (limited to 'tests/test_stream_xep_0066.py')
-rw-r--r--tests/test_stream_xep_0066.py72
1 files changed, 72 insertions, 0 deletions
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("""
+ <iq to="user@example.com" type="set" id="1">
+ <query xmlns="jabber:iq:oob">
+ <url>http://github.com/fritzy/SleekXMPP/blob/master/README</url>
+ <desc>SleekXMPP README</desc>
+ </query>
+ </iq>
+ """)
+
+ self.recv("""
+ <iq id="1" type="result"
+ to="tester@localhost"
+ from="user@example.com" />
+ """)
+
+ 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("""
+ <iq to="tester@localhost"
+ from="user@example.com"
+ type="set" id="1">
+ <query xmlns="jabber:iq:oob">
+ <url>http://github.com/fritzy/SleekXMPP/blob/master/README</url>
+ <desc>SleekXMPP README</desc>
+ </query>
+ </iq>
+ """)
+
+ 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)