summaryrefslogtreecommitdiff
path: root/tests/test_errorstanzas.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-07-29 23:55:13 -0400
committerLance Stout <lancestout@gmail.com>2010-07-29 23:55:13 -0400
commit1da3e5b35eb59909d4d6903b1c0190a7aad98a30 (patch)
treeb409a959ed5eaa03aa3c78b21f36f3ca87800356 /tests/test_errorstanzas.py
parenta96a046e27289d733eabe0cb1b902e679da5d4ca (diff)
downloadslixmpp-1da3e5b35eb59909d4d6903b1c0190a7aad98a30.tar.gz
slixmpp-1da3e5b35eb59909d4d6903b1c0190a7aad98a30.tar.bz2
slixmpp-1da3e5b35eb59909d4d6903b1c0190a7aad98a30.tar.xz
slixmpp-1da3e5b35eb59909d4d6903b1c0190a7aad98a30.zip
Added unit tests for error stanzas. Corrected error in deleting conditions.
Diffstat (limited to 'tests/test_errorstanzas.py')
-rw-r--r--tests/test_errorstanzas.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/test_errorstanzas.py b/tests/test_errorstanzas.py
new file mode 100644
index 00000000..788d6c12
--- /dev/null
+++ b/tests/test_errorstanzas.py
@@ -0,0 +1,56 @@
+from sleektest import *
+
+class TestErrorStanzas(SleekTest):
+
+ def testSetup(self):
+ """Test setting initial values in error stanza."""
+ msg = self.Message()
+ msg.enable('error')
+ self.checkMessage(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.checkMessage(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.checkMessage(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.checkMessage(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)