summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMaxime Buquet <pep@bouah.net>2020-05-24 15:05:24 +0200
committerMaxime Buquet <pep@bouah.net>2020-05-24 15:05:24 +0200
commit6f4e9b485f743bc55ab0c2ae08afcdae89451110 (patch)
treec6d3fd080d08046b31c2862dd085a0a040bc64db /tests
parent8a52730f111f8d91331892ae77fb9df87f25ec82 (diff)
parent28123083f7077c990efaf8807fc88246274880b3 (diff)
downloadslixmpp-6f4e9b485f743bc55ab0c2ae08afcdae89451110.tar.gz
slixmpp-6f4e9b485f743bc55ab0c2ae08afcdae89451110.tar.bz2
slixmpp-6f4e9b485f743bc55ab0c2ae08afcdae89451110.tar.xz
slixmpp-6f4e9b485f743bc55ab0c2ae08afcdae89451110.zip
Merge branch 'plugin-377' into 'master'
Add a plugin for XEP-0377: spam reporting See merge request poezio/slixmpp!53
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stanza_xep_0377.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/test_stanza_xep_0377.py b/tests/test_stanza_xep_0377.py
new file mode 100644
index 00000000..321a26a8
--- /dev/null
+++ b/tests/test_stanza_xep_0377.py
@@ -0,0 +1,56 @@
+import unittest
+from slixmpp import Iq
+from slixmpp.test import SlixTest
+import slixmpp.plugins.xep_0191 as xep_0191
+import slixmpp.plugins.xep_0377 as xep_0377
+from slixmpp.xmlstream import register_stanza_plugin
+
+
+class TestSpamReporting(SlixTest):
+
+ def setUp(self):
+ register_stanza_plugin(Iq, xep_0191.Block)
+ register_stanza_plugin(
+ xep_0191.Block,
+ xep_0377.Report,
+ )
+ register_stanza_plugin(
+ xep_0377.Report,
+ xep_0377.Text,
+ )
+
+ def testCreateReport(self):
+ report = """
+ <iq type="set">
+ <block xmlns="urn:xmpp:blocking">
+ <report xmlns="urn:xmpp:reporting:0">
+ <spam/>
+ </report>
+ </block>
+ </iq>
+ """
+
+ iq = self.Iq()
+ iq['type'] = 'set'
+ iq['block']['report']['spam'] = True
+
+ self.check(iq, report)
+
+ def testEnforceOnlyOneSubElement(self):
+ report = """
+ <iq type="set">
+ <block xmlns="urn:xmpp:blocking">
+ <report xmlns="urn:xmpp:reporting:0">
+ <abuse/>
+ </report>
+ </block>
+ </iq>
+ """
+
+ iq = self.Iq()
+ iq['type'] = 'set'
+ iq['block']['report']['spam'] = True
+ iq['block']['report']['abuse'] = True
+ self.check(iq, report)
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestSpamReporting)