diff options
author | Link Mauve <linkmauve@linkmauve.fr> | 2020-11-27 19:54:13 +0100 |
---|---|---|
committer | Link Mauve <linkmauve@linkmauve.fr> | 2020-11-27 19:54:13 +0100 |
commit | c86a6ad299a9b84e33ff8a1977d77fc1f23337ef (patch) | |
tree | ea292f0dd3178d08ebf836a153b7d4f6b8157711 /tests | |
parent | 9b5ab741c83b33a466664f360247488d1484f9a2 (diff) | |
parent | 7e4b6647428e962109e9b6c7aea248bb21c222e2 (diff) | |
download | slixmpp-c86a6ad299a9b84e33ff8a1977d77fc1f23337ef.tar.gz slixmpp-c86a6ad299a9b84e33ff8a1977d77fc1f23337ef.tar.bz2 slixmpp-c86a6ad299a9b84e33ff8a1977d77fc1f23337ef.tar.xz slixmpp-c86a6ad299a9b84e33ff8a1977d77fc1f23337ef.zip |
Merge branch 'xep-0444-and-not-protoxep' into 'master'
Promote protoxep_reactions to XEP-0444
See merge request poezio/slixmpp!64
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_stanza_xep_0444.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/test_stanza_xep_0444.py b/tests/test_stanza_xep_0444.py new file mode 100644 index 00000000..b4d5739b --- /dev/null +++ b/tests/test_stanza_xep_0444.py @@ -0,0 +1,69 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2020 Mathieu Pasquet + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +import unittest +from slixmpp import Message +from slixmpp.test import SlixTest +from slixmpp.plugins.xep_0444 import XEP_0444 +import slixmpp.plugins.xep_0444.stanza as stanza +from slixmpp.xmlstream import register_stanza_plugin + + +class TestReactions(SlixTest): + + def setUp(self): + register_stanza_plugin(Message, stanza.Reactions) + register_stanza_plugin(stanza.Reactions, stanza.Reaction) + + def testCreateReactions(self): + """Testing creating Reactions.""" + + xmlstring = """ + <message> + <reactions xmlns="urn:xmpp:reactions:0" id="abcd"> + <reaction>😃</reaction> + <reaction>🤗</reaction> + </reactions> + </message> + """ + + msg = self.Message() + msg['reactions']['id'] = 'abcd' + msg['reactions']['values'] = ['😃', '🤗'] + + self.check(msg, xmlstring, use_values=False) + + self.assertEqual({'😃', '🤗'}, msg['reactions']['values']) + + + def testCreateReactionsUnrestricted(self): + """Testing creating Reactions with the extra all_chars arg.""" + + xmlstring = """ + <message> + <reactions xmlns="urn:xmpp:reactions:0" id="abcd"> + <reaction>😃</reaction> + <reaction>🤗</reaction> + <reaction>toto</reaction> + </reactions> + </message> + """ + + msg = self.Message() + msg['reactions']['id'] = 'abcd' + msg['reactions'].set_values(['😃', '🤗', 'toto'], all_chars=True) + + self.check(msg, xmlstring, use_values=False) + + self.assertEqual({'😃', '🤗'}, msg['reactions']['values']) + self.assertEqual({'😃', '🤗', 'toto'}, msg['reactions'].get_values(all_chars=True)) + with self.assertRaises(ValueError): + msg['reactions'].set_values(['😃', '🤗', 'toto'], all_chars=False) + + +suite = unittest.TestLoader().loadTestsFromTestCase(TestReactions) |