summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-03-08 21:47:25 +0100
committermathieui <mathieui@mathieui.net>2021-03-09 19:52:53 +0100
commitd7d4baefa3877afef462b37afec502ff9b42a9e5 (patch)
treea14b55e74ff6d28a6447d868eb1241f7ff997631 /tests
parent1289cf575c7a2c3db4a425b4ca4ee128098d9966 (diff)
downloadslixmpp-d7d4baefa3877afef462b37afec502ff9b42a9e5.tar.gz
slixmpp-d7d4baefa3877afef462b37afec502ff9b42a9e5.tar.bz2
slixmpp-d7d4baefa3877afef462b37afec502ff9b42a9e5.tar.xz
slixmpp-d7d4baefa3877afef462b37afec502ff9b42a9e5.zip
tests: Add XEP-0313 stanza tests
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stanza_xep_0313.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/test_stanza_xep_0313.py b/tests/test_stanza_xep_0313.py
new file mode 100644
index 00000000..5c7b42a9
--- /dev/null
+++ b/tests/test_stanza_xep_0313.py
@@ -0,0 +1,82 @@
+import unittest
+from slixmpp import JID, Iq, Message
+from slixmpp.test import SlixTest
+from slixmpp.plugins.xep_0313 import stanza
+from slixmpp.plugins.xep_0004.stanza import Form
+from slixmpp.plugins.xep_0297 import stanza as fstanza
+from slixmpp.plugins.xep_0059 import stanza as rstanza
+from slixmpp.xmlstream import register_stanza_plugin
+
+
+class TestMAM(SlixTest):
+
+ def setUp(self):
+ register_stanza_plugin(stanza.MAM, Form)
+ register_stanza_plugin(Iq, stanza.MAM)
+ register_stanza_plugin(Iq, stanza.Preferences)
+ register_stanza_plugin(Message, stanza.Result)
+ register_stanza_plugin(Iq, stanza.Fin)
+ register_stanza_plugin(
+ stanza.Result,
+ fstanza.Forwarded
+ )
+ register_stanza_plugin(stanza.MAM, rstanza.Set)
+ register_stanza_plugin(stanza.Fin, rstanza.Set)
+
+ def testMAMQuery(self):
+ """Test that we can build a simple MAM query."""
+ iq = Iq()
+ iq['type'] = 'set'
+ iq['mam']['queryid'] = 'f27'
+
+ self.check(iq, """
+ <iq type='set'>
+ <query xmlns='urn:xmpp:mam:2' queryid='f27'/>
+ </iq>
+ """)
+
+ def testMAMQueryOptions(self):
+ """Test that we can build a mam query with all options."""
+ iq = Iq()
+ iq['type'] = 'set'
+ iq['mam']['with'] = JID('juliet@capulet.lit')
+ iq['mam']['start'] = '2010-06-07T00:00:00Z'
+ iq['mam']['end'] = '2010-07-07T13:23:54Z'
+ iq['mam']['after_id'] = 'id1'
+ iq['mam']['before_id'] = 'id2'
+ iq['mam']['ids'] = ['a', 'b', 'c']
+
+ self.check(iq, """
+ <iq type='set'>
+ <query xmlns='urn:xmpp:mam:2'>
+ <x xmlns='jabber:x:data' type='submit'>
+ <field var='FORM_TYPE' type='hidden'>
+ <value>urn:xmpp:mam:2</value>
+ </field>
+ <field var='with'>
+ <value>juliet@capulet.lit</value>
+ </field>
+ <field var='start'>
+ <value>2010-06-07T00:00:00Z</value>
+ </field>
+ <field var='end'>
+ <value>2010-07-07T13:23:54Z</value>
+ </field>
+ <field var='after-id'>
+ <value>id1</value>
+ </field>
+ <field var='before-id'>
+ <value>id2</value>
+ </field>
+ <field var='ids'>
+ <value>a</value>
+ <value>b</value>
+ <value>c</value>
+ </field>
+ </x>
+ </query>
+ </iq>
+ """, use_values=False)
+
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestMAM)