mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-24 03:00:15 +00:00
2a2ac73845
The error bubbles through the event processing loop, breaking it and hanging the application. Instead, there is now a .exception(e) method on XMLStream which may be overridden or reassigned that will receive all unhandled exceptions (read: not XMPPError) from event and stream handlers.
63 lines
1.7 KiB
Python
63 lines
1.7 KiB
Python
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):
|
|
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)
|