slixmpp/tests/test_stream_xep_0249.py

60 lines
1.6 KiB
Python
Raw Normal View History

2011-03-23 14:00:32 +00:00
import time
2013-07-26 11:02:26 +00:00
import unittest
2014-07-17 12:19:04 +00:00
from slixmpp.test import SlixTest
2011-03-23 14:00:32 +00:00
2014-07-17 12:19:04 +00:00
class TestStreamDirectInvite(SlixTest):
2011-03-23 14:00:32 +00:00
"""
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>
""")
2018-10-08 21:25:23 +00:00
self.assertTrue(events == [True],
2011-03-23 14:00:32 +00:00
"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',
2014-07-17 12:19:04 +00:00
reason='Need to test Slixmpp')
2011-03-23 14:00:32 +00:00
self.send("""
<message to="user@example.com">
<x xmlns="jabber:x:conference"
jid="sleek@conference.jabber.org"
2014-07-17 12:19:04 +00:00
reason="Need to test Slixmpp" />
2011-03-23 14:00:32 +00:00
</message>
""")
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamDirectInvite)