summaryrefslogtreecommitdiff
path: root/tests/test_stanza_xep_0425.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_stanza_xep_0425.py')
-rw-r--r--tests/test_stanza_xep_0425.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/test_stanza_xep_0425.py b/tests/test_stanza_xep_0425.py
new file mode 100644
index 00000000..96d979e8
--- /dev/null
+++ b/tests/test_stanza_xep_0425.py
@@ -0,0 +1,47 @@
+import unittest
+from slixmpp import Message, Iq, JID
+from slixmpp.test import SlixTest
+from slixmpp.plugins.xep_0425 import stanza
+
+
+class TestModeration(SlixTest):
+
+ def setUp(self):
+ stanza.register_plugins()
+
+ def testModerate(self):
+ iq = Iq()
+ iq['type'] = 'set'
+ iq['id'] = 'a'
+ iq['apply_to']['id'] = 'some-id'
+ iq['apply_to']['moderate'].enable('retract')
+ iq['apply_to']['moderate']['reason'] = 'R'
+
+ self.check(iq, """
+<iq type='set' id='a'>
+ <apply-to id="some-id" xmlns="urn:xmpp:fasten:0">
+ <moderate xmlns='urn:xmpp:message-moderate:0'>
+ <retract xmlns='urn:xmpp:message-retract:0'/>
+ <reason>R</reason>
+ </moderate>
+ </apply-to>
+</iq>
+ """, use_values=False)
+
+ def testModerated(self):
+ message = Message()
+ message['moderated']['by'] = JID('toto@titi')
+ message['moderated']['retracted']['stamp'] = '2019-09-20T23:09:32Z'
+ message['moderated']['reason'] = 'R'
+
+ self.check(message, """
+<message>
+ <moderated xmlns="urn:xmpp:message-moderate:0" by="toto@titi">
+ <retracted stamp="2019-09-20T23:09:32Z" xmlns="urn:xmpp:message-retract:0" />
+ <reason>R</reason>
+ </moderated>
+</message>
+ """)
+
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestModeration)