From 3d1615ea54ac71e8d2301507a77265c758e6c047 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 23 Nov 2020 21:16:02 +0100 Subject: XEP-0369: add basic stanza tests --- tests/test_stanza_xep_0369.py | 117 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 tests/test_stanza_xep_0369.py (limited to 'tests') diff --git a/tests/test_stanza_xep_0369.py b/tests/test_stanza_xep_0369.py new file mode 100644 index 00000000..8c3e2a6b --- /dev/null +++ b/tests/test_stanza_xep_0369.py @@ -0,0 +1,117 @@ +import unittest +from slixmpp import Iq, Message, JID +from slixmpp.test import SlixTest +from slixmpp.plugins.xep_0369 import stanza +from slixmpp.plugins.xep_0060 import stanza as pstanza +from slixmpp.plugins.xep_0369.mix_core import BASE_NODES + + +class TestMIXStanza(SlixTest): + + def setUp(self): + stanza.register_plugins() + + def testMIXJoin(self): + """Test that data is converted to base64""" + iq = Iq() + iq['type'] = 'set' + for node in BASE_NODES: + sub = stanza.Subscribe() + sub['node'] = node + iq['mix_join'].append(sub) + iq['mix_join']['nick'] = 'Toto' + + self.check(iq, """ + + + + + + Toto + + + """) + + def testMIXUpdateSub(self): + iq = Iq() + iq['type'] = 'set' + iq.enable('mix_updatesub') + sub = stanza.Subscribe() + sub['node'] = 'urn:xmpp:mix:nodes:someothernode' + iq['mix_updatesub'].append(sub) + + self.check(iq, """ + + + + + + """) + + def testMIXLeave(self): + iq = Iq() + iq['type'] = 'set' + iq.enable('mix_leave') + + self.check(iq, """ + + + + """) + + def testMIXSetNick(self): + iq = Iq() + iq['type'] = 'set' + iq['mix_setnick']['nick'] = 'A nick' + + self.check(iq, """ + + + A nick + + + """) + + def testMIXMessage(self): + msg = Message() + msg['type'] = 'groupchat' + msg['body'] = 'This is a message body' + msg['mix']['nick'] = 'A nick' + msg['mix']['jid'] = JID('toto@example.com') + + self.check(msg, """ + + This is a message body + + A nick + toto@example.com + + + """) + + def testMIXNewParticipant(self): + msg = Message() + msg['pubsub_event']['items']['node'] = 'urn:xmpp:mix:nodes:participants' + item = pstanza.EventItem() + item['id'] = '123456' + item['mix_participant']['jid'] = JID('titi@example.com') + item['mix_participant']['nick'] = 'Titi' + msg['pubsub_event']['items'].append(item) + + self.check(msg, """ + + + + + + titi@example.com + Titi + + + + + + """, use_values=False) + + +suite = unittest.TestLoader().loadTestsFromTestCase(TestMIXStanza) -- cgit v1.2.3 From 15bf6bc827261fa8fa7208da5eb873f5c26f3b6a Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 29 Nov 2020 13:37:24 +0100 Subject: XEP-0405: add basic stanza tests --- tests/test_stanza_xep_0405.py | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/test_stanza_xep_0405.py (limited to 'tests') diff --git a/tests/test_stanza_xep_0405.py b/tests/test_stanza_xep_0405.py new file mode 100644 index 00000000..5d834cf1 --- /dev/null +++ b/tests/test_stanza_xep_0405.py @@ -0,0 +1,55 @@ +import unittest +from slixmpp import Iq, Message, JID +from slixmpp.test import SlixTest +from slixmpp.plugins.xep_0405 import stanza +from slixmpp.plugins.xep_0369 import stanza as mstanza +from slixmpp.plugins.xep_0405.mix_pam import BASE_NODES + + +class TestMIXPAMStanza(SlixTest): + + def setUp(self): + stanza.register_plugins() + mstanza.register_plugins() + + def testMIXPAMJoin(self): + """Test that data is converted to base64""" + iq = Iq() + iq['type'] = 'set' + iq['client_join']['channel'] = JID('mix@example.com') + for node in BASE_NODES: + sub = mstanza.Subscribe() + sub['node'] = node + iq['client_join']['mix_join'].append(sub) + iq['client_join']['mix_join']['nick'] = 'Toto' + + self.check(iq, """ + + + + + + + Toto + + + + """) + + + def testMIXPAMLeave(self): + iq = Iq() + iq['type'] = 'set' + iq['client_leave']['channel'] = JID('mix@example.com') + iq['client_leave'].enable('mix_leave') + + self.check(iq, """ + + + + + + """) + + +suite = unittest.TestLoader().loadTestsFromTestCase(TestMIXPAMStanza) -- cgit v1.2.3