summaryrefslogtreecommitdiff
path: root/tests/test_stanza_xep_0369.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-12-02 19:19:14 +0100
committermathieui <mathieui@mathieui.net>2020-12-02 19:19:14 +0100
commit4d5586f4a1712050940ee582187c6d955a8e18f4 (patch)
tree3cdbdaa3e8d9537d01adfdd9277e5ac209949816 /tests/test_stanza_xep_0369.py
parent54b9721f3a67beb6580d09a307c9f8b168d96568 (diff)
parent4eb2bb7da855e67f1fff0d86470cc78c06e64c95 (diff)
downloadslixmpp-4d5586f4a1712050940ee582187c6d955a8e18f4.tar.gz
slixmpp-4d5586f4a1712050940ee582187c6d955a8e18f4.tar.bz2
slixmpp-4d5586f4a1712050940ee582187c6d955a8e18f4.tar.xz
slixmpp-4d5586f4a1712050940ee582187c6d955a8e18f4.zip
Merge branch 'mix-implementation' into 'master'
First try at a MIX implementation See merge request poezio/slixmpp!63
Diffstat (limited to 'tests/test_stanza_xep_0369.py')
-rw-r--r--tests/test_stanza_xep_0369.py117
1 files changed, 117 insertions, 0 deletions
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, """
+ <iq type="set">
+ <join xmlns='urn:xmpp:mix:core:1'>
+ <subscribe node='urn:xmpp:mix:nodes:messages'/>
+ <subscribe node='urn:xmpp:mix:nodes:participants'/>
+ <subscribe node='urn:xmpp:mix:nodes:info'/>
+ <nick>Toto</nick>
+ </join>
+ </iq>
+ """)
+
+ 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, """
+ <iq type="set">
+ <update-subscription xmlns='urn:xmpp:mix:core:1'>
+ <subscribe node='urn:xmpp:mix:nodes:someothernode'/>
+ </update-subscription>
+ </iq>
+ """)
+
+ def testMIXLeave(self):
+ iq = Iq()
+ iq['type'] = 'set'
+ iq.enable('mix_leave')
+
+ self.check(iq, """
+ <iq type="set">
+ <leave xmlns='urn:xmpp:mix:core:1'/>
+ </iq>
+ """)
+
+ def testMIXSetNick(self):
+ iq = Iq()
+ iq['type'] = 'set'
+ iq['mix_setnick']['nick'] = 'A nick'
+
+ self.check(iq, """
+ <iq type="set">
+ <setnick xmlns='urn:xmpp:mix:core:1'>
+ <nick>A nick</nick>
+ </setnick>
+ </iq>
+ """)
+
+ 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, """
+ <message type="groupchat">
+ <body>This is a message body</body>
+ <mix xmlns="urn:xmpp:mix:core:1">
+ <nick>A nick</nick>
+ <jid>toto@example.com</jid>
+ </mix>
+ </message>
+ """)
+
+ 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, """
+ <message>
+ <event xmlns='http://jabber.org/protocol/pubsub#event'>
+ <items node='urn:xmpp:mix:nodes:participants'>
+ <item id='123456'>
+ <participant xmlns='urn:xmpp:mix:core:1'>
+ <jid>titi@example.com</jid>
+ <nick>Titi</nick>
+ </participant>
+ </item>
+ </items>
+ </event>
+ </message>
+ """, use_values=False)
+
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestMIXStanza)