slixmpp/tests/test_stream_xep_0249.py
mathieui 1e2665df19
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
2015-02-12 12:23:47 +01:00

59 lines
1.6 KiB
Python

import time
import unittest
from slixmpp.test import SlixTest
class TestStreamDirectInvite(SlixTest):
"""
Test using the XEP-0249 plugin.
"""
def tearDown(self):
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>
""")
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 Slixmpp')
self.send("""
<message to="user@example.com">
<x xmlns="jabber:x:conference"
jid="sleek@conference.jabber.org"
reason="Need to test Slixmpp" />
</message>
""")
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamDirectInvite)