diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2017-02-11 04:02:44 +0000 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2017-02-11 04:02:44 +0000 |
commit | 007c8362967d22850f7cce2cfdb3c83e6c69fbf2 (patch) | |
tree | 9667f67def635d8e2d76d12cb5f99eb8f3c5e6af /tests/test_stanza_xep_0300.py | |
parent | 3721bf9f6b19ceaae75454956571c33caf5f1e87 (diff) | |
download | slixmpp-007c8362967d22850f7cce2cfdb3c83e6c69fbf2.tar.gz slixmpp-007c8362967d22850f7cce2cfdb3c83e6c69fbf2.tar.bz2 slixmpp-007c8362967d22850f7cce2cfdb3c83e6c69fbf2.tar.xz slixmpp-007c8362967d22850f7cce2cfdb3c83e6c69fbf2.zip |
XEP-0300: Add rudimentary tests.
Diffstat (limited to 'tests/test_stanza_xep_0300.py')
-rw-r--r-- | tests/test_stanza_xep_0300.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/test_stanza_xep_0300.py b/tests/test_stanza_xep_0300.py new file mode 100644 index 00000000..5ffd8e3b --- /dev/null +++ b/tests/test_stanza_xep_0300.py @@ -0,0 +1,57 @@ +""" + Slixmpp: The Slick XMPP Library + Copyright (C) 2017 Emmanuel Gil Peyrot + This file is part of Slixmpp. + + See the file LICENSE for copying permission. +""" + +import unittest +from slixmpp import Iq +from slixmpp.test import SlixTest +from slixmpp.plugins.xep_0300 import Hash +from slixmpp.xmlstream import register_stanza_plugin + + +class TestHash(SlixTest): + + def setUp(self): + register_stanza_plugin(Iq, Hash) + + def testSimpleElement(self): + """Test that the element is created correctly.""" + iq = Iq() + iq['type'] = 'set' + iq['hash']['algo'] = 'sha-256' + iq['hash']['value'] = 'EQgS9n+h4fARf289cCQcGkKnsHcRqTwkd8xRbZBC+ds=' + + self.check(iq, """ + <iq type="set"> + <hash xmlns="urn:xmpp:hashes:2" algo="sha-256">EQgS9n+h4fARf289cCQcGkKnsHcRqTwkd8xRbZBC+ds=</hash> + </iq> + """) + + def testInvalidAlgo(self): + """Test that invalid algos raise an exception.""" + iq = Iq() + iq['type'] = 'set' + try: + iq['hash']['algo'] = 'coucou' + except ValueError: + pass + else: + raise self.failureException + + #def testDisabledAlgo(self): + # """Test that disabled algos aren’t used.""" + # iq = Iq() + # iq['type'] = 'set' + # try: + # iq['hash']['algo'] = 'sha-1' + # except ValueError: + # pass + # else: + # raise self.failureException + + +suite = unittest.TestLoader().loadTestsFromTestCase(TestHash) |