Add the 'connecting' event
[slixmpp.git] / tests / test_stream_xep_0249.py
blob920425222aef29db26e607d1e7ab484909583977
1 import time
3 import unittest
4 from slixmpp.test import SlixTest
7 class TestStreamDirectInvite(SlixTest):
9 """
10 Test using the XEP-0249 plugin.
11 """
13 def tearDown(self):
14 self.stream_close()
16 def testReceiveInvite(self):
17 self.stream_start(mode='client',
18 plugins=['xep_0030',
19 'xep_0249'])
21 events = []
23 def handle_invite(msg):
24 events.append(True)
26 self.xmpp.add_event_handler('groupchat_direct_invite',
27 handle_invite)
29 self.recv("""
30 <message>
31 <x xmlns="jabber:x:conference"
32 jid="sleek@conference.jabber.org"
33 password="foo"
34 reason="For testing" />
35 </message>
36 """)
38 time.sleep(.5)
40 self.failUnless(events == [True],
41 "Event not raised: %s" % events)
43 def testSentDirectInvite(self):
44 self.stream_start(mode='client',
45 plugins=['xep_0030',
46 'xep_0249'])
48 self.xmpp['xep_0249'].send_invitation('user@example.com',
49 'sleek@conference.jabber.org',
50 reason='Need to test Slixmpp')
52 self.send("""
53 <message to="user@example.com">
54 <x xmlns="jabber:x:conference"
55 jid="sleek@conference.jabber.org"
56 reason="Need to test Slixmpp" />
57 </message>
58 """)
61 suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamDirectInvite)