summaryrefslogtreecommitdiff
path: root/tests/test_stanza_error.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-10-07 10:58:13 -0400
committerLance Stout <lancestout@gmail.com>2010-10-07 10:58:13 -0400
commit0fffbb82000a1a6c3c23d62fedcbd8e8141f8994 (patch)
tree114c3767ccc13de3d0388b43cd357b90334f469a /tests/test_stanza_error.py
parent21c32c6e1cfd9b18e4c8320e0796e1d7e4b3f74c (diff)
downloadslixmpp-0fffbb82000a1a6c3c23d62fedcbd8e8141f8994.tar.gz
slixmpp-0fffbb82000a1a6c3c23d62fedcbd8e8141f8994.tar.bz2
slixmpp-0fffbb82000a1a6c3c23d62fedcbd8e8141f8994.tar.xz
slixmpp-0fffbb82000a1a6c3c23d62fedcbd8e8141f8994.zip
Unit test reorganization.
Moved SleekTest to sleekxmpp.test. Organized test suites by their focus. - Suites focused on testing stanza objects are named test_stanza_X.py - Suites focused on testing stream behavior are name test_stream_X.py
Diffstat (limited to 'tests/test_stanza_error.py')
-rw-r--r--tests/test_stanza_error.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/test_stanza_error.py b/tests/test_stanza_error.py
new file mode 100644
index 00000000..f76ac62d
--- /dev/null
+++ b/tests/test_stanza_error.py
@@ -0,0 +1,57 @@
+from sleekxmpp.test import *
+
+
+class TestErrorStanzas(SleekTest):
+
+ def testSetup(self):
+ """Test setting initial values in error stanza."""
+ msg = self.Message()
+ msg.enable('error')
+ self.check_message(msg, """
+ <message type="error">
+ <error type="cancel">
+ <feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
+ </error>
+ </message>
+ """)
+
+ def testCondition(self):
+ """Test modifying the error condition."""
+ msg = self.Message()
+ msg['error']['condition'] = 'item-not-found'
+
+ self.check_message(msg, """
+ <message type="error">
+ <error type="cancel">
+ <item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
+ </error>
+ </message>
+ """)
+
+ self.failUnless(msg['error']['condition'] == 'item-not-found', "Error condition doesn't match.")
+
+ del msg['error']['condition']
+
+ self.check_message(msg, """
+ <message type="error">
+ <error type="cancel" />
+ </message>
+ """)
+
+ def testDelCondition(self):
+ """Test that deleting error conditions doesn't remove extra elements."""
+ msg = self.Message()
+ msg['error']['text'] = 'Error!'
+ msg['error']['condition'] = 'internal-server-error'
+
+ del msg['error']['condition']
+
+ self.check_message(msg, """
+ <message type="error">
+ <error type="cancel">
+ <text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Error!</text>
+ </error>
+ </message>
+ """)
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestErrorStanzas)