summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-03-23 10:01:10 -0400
committerLance Stout <lancestout@gmail.com>2011-03-23 10:01:10 -0400
commit393259c24b017a9005a16338e3297da5c79e9b9a (patch)
tree012572a0f00b0404eff4e33273e773e5dd92b6a1 /tests
parent756c4c032f820285455c7c57e4925887f9c8e213 (diff)
parentf2449009d197e8e6f29caff6b78a9c9c87ae2909 (diff)
downloadslixmpp-393259c24b017a9005a16338e3297da5c79e9b9a.tar.gz
slixmpp-393259c24b017a9005a16338e3297da5c79e9b9a.tar.bz2
slixmpp-393259c24b017a9005a16338e3297da5c79e9b9a.tar.xz
slixmpp-393259c24b017a9005a16338e3297da5c79e9b9a.zip
Merge branch 'develop' into roster
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stream_xep_0249.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/test_stream_xep_0249.py b/tests/test_stream_xep_0249.py
new file mode 100644
index 00000000..f49d1f7e
--- /dev/null
+++ b/tests/test_stream_xep_0249.py
@@ -0,0 +1,64 @@
+import sys
+import time
+import threading
+
+from sleekxmpp.test import *
+from sleekxmpp.xmlstream import ElementBase
+
+
+class TestStreamDirectInvite(SleekTest):
+
+ """
+ Test using the XEP-0249 plugin.
+ """
+
+ def tearDown(self):
+ sys.excepthook = sys.__excepthook__
+ self.stream_close()
+
+ def testReceiveInvite(self):
+ self.stream_start(mode='client',
+ plugins=['xep_0030',
+ 'xep_0249'])
+
+ events = []
+
+ def handle_invite(msg):
+ events.append(True)
+
+ self.xmpp.add_event_handler('groupchat_direct_invite',
+ handle_invite)
+
+ self.recv("""
+ <message>
+ <x xmlns="jabber:x:conference"
+ jid="sleek@conference.jabber.org"
+ password="foo"
+ reason="For testing" />
+ </message>
+ """)
+
+ time.sleep(.5)
+
+ self.failUnless(events == [True],
+ "Event not raised: %s" % events)
+
+ def testSentDirectInvite(self):
+ self.stream_start(mode='client',
+ plugins=['xep_0030',
+ 'xep_0249'])
+
+ self.xmpp['xep_0249'].send_invitation('user@example.com',
+ 'sleek@conference.jabber.org',
+ reason='Need to test Sleek')
+
+ self.send("""
+ <message to="user@example.com">
+ <x xmlns="jabber:x:conference"
+ jid="sleek@conference.jabber.org"
+ reason="Need to test Sleek" />
+ </message>
+ """)
+
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamDirectInvite)