Commit d33c50ad authored by Philipp Hörist's avatar Philipp Hörist

Add test for parsing errors

parent d1e511bf
Pipeline #3992 passed with stages
in 27 seconds
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'
<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'>
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(, 'step_03')
self.assertEqual(error.jid, 'upload.montague.tld')
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment