diff options
author | Philipp Hörist <philipp@hoerist.com> | 2019-08-05 12:01:43 +0300 |
---|---|---|
committer | Philipp Hörist <philipp@hoerist.com> | 2019-08-05 12:01:43 +0300 |
commit | d33c50ad04e27afa2a34cc90f188d2ab930452c3 (patch) | |
tree | b9e5a00b803c3cd9b564a2b607974c8d4cae7ad7 /test | |
parent | d1e511bfae54fb1f67c6167876436ad7d87d5fef (diff) |
Add test for parsing errors
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/test_error_parsing.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/unit/test_error_parsing.py b/test/unit/test_error_parsing.py new file mode 100644 index 0000000..213bc25 --- /dev/null +++ b/test/unit/test_error_parsing.py @@ -0,0 +1,32 @@ +import unittest + +from nbxmpp.protocol import Iq +from nbxmpp.util import error_factory + + +class TestErrorParsing(unittest.TestCase): + + def test_error_parsing(self): + stanza = ''' + <iq from='upload.montague.tld' + id='step_03' + to='romeo@montague.tld/garden' + type='error'> + <error type='modify'> + <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' /> + <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>File too large. The maximum file size is 20000 bytes</text> + <text xml:lang='de' xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>File zu groß. Erlaubt sind 20000 bytes</text> + <file-too-large xmlns='urn:xmpp:http:upload:0'> + <max-file-size>20000</max-file-size> + </file-too-large> + </error> + </iq>''' + + error = error_factory(Iq(node=stanza)) + self.assertEqual(error.condition, 'not-acceptable') + self.assertEqual(error.app_condition, 'file-too-large') + self.assertEqual(error.get_text(), 'File too large. The maximum file size is 20000 bytes') + self.assertEqual(error.get_text('de'), 'File zu groß. Erlaubt sind 20000 bytes') + self.assertEqual(error.type, 'modify') + self.assertEqual(error.id, 'step_03') + self.assertEqual(error.jid, 'upload.montague.tld') |