Created
October 20, 2016 09:15
-
-
Save jamestait/c4b36068a80ea9c5ad87f097fd784f05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sleekxmpp import ComponentXMPP | |
from sleekxmpp.test import sleektest | |
class Component(ComponentXMPP): | |
def __init__(self, jid, secret, host=None, port=None, | |
plugin_config={}, plugin_whitelist=[], use_jc_ns=False): | |
super().__init__(jid, secret, host, port) | |
self.add_event_handler('message', self.message) | |
def message(self, msg): | |
msg.reply('Thanks for sending "%(body)s" to %(to)s!' % msg).send() | |
sleektest.ComponentXMPP = Component | |
class ComponentTest(sleektest.SleekTest): | |
def test_component(self): | |
self.stream_start(mode='component') | |
self.recv( | |
b'<message from="user@localhost" to="tester.localhost">' | |
b'<body>Hi!</body></message>') | |
self.send( | |
b'<message to="user@localhost" from="tester.localhost"><body>' | |
b'Thanks for sending "Hi!" to tester.localhost!</body></message>') | |
def tearDown(self): | |
self.stream_close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment