summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-05-24 15:00:20 +0200
committermathieui <mathieui@mathieui.net>2020-05-24 15:00:20 +0200
commit28123083f7077c990efaf8807fc88246274880b3 (patch)
tree6a8ba0c35ab6e14aa7c70a785f3ca2bbd8d00171
parentef961392beaf3111d01c32e4d183df681b03d492 (diff)
downloadslixmpp-28123083f7077c990efaf8807fc88246274880b3.tar.gz
slixmpp-28123083f7077c990efaf8807fc88246274880b3.tar.bz2
slixmpp-28123083f7077c990efaf8807fc88246274880b3.tar.xz
slixmpp-28123083f7077c990efaf8807fc88246274880b3.zip
Add stanza tests for 0377
-rw-r--r--slixmpp/plugins/xep_0377/__init__.py2
-rw-r--r--tests/test_stanza_xep_0377.py56
2 files changed, 57 insertions, 1 deletions
diff --git a/slixmpp/plugins/xep_0377/__init__.py b/slixmpp/plugins/xep_0377/__init__.py
index b0802f86..6ae7a097 100644
--- a/slixmpp/plugins/xep_0377/__init__.py
+++ b/slixmpp/plugins/xep_0377/__init__.py
@@ -8,7 +8,7 @@
from slixmpp.plugins.base import register_plugin
-from slixmpp.plugins.xep_0377.stanza import Report
+from slixmpp.plugins.xep_0377.stanza import Report, Text
from slixmpp.plugins.xep_0377.spam_reporting import XEP_0377
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)