summaryrefslogtreecommitdiff
path: root/tests/test_errorstanzas.py
diff options
context:
space:
mode:
authorNathan Fritz <nathan@andyet.net>2010-08-19 16:09:47 -0700
committerNathan Fritz <nathan@andyet.net>2010-08-19 16:09:47 -0700
commitd150b35464742de7af9b3105bc7eeb55171b96ee (patch)
treef1dce9115efbe4c85d37bc27d6ae35f1e937a043 /tests/test_errorstanzas.py
parent21b7109c06695955632692814fed11b3717e0fc7 (diff)
parente4240dd593207a5912de996c42451b3946f113b2 (diff)
downloadslixmpp-d150b35464742de7af9b3105bc7eeb55171b96ee.tar.gz
slixmpp-d150b35464742de7af9b3105bc7eeb55171b96ee.tar.bz2
slixmpp-d150b35464742de7af9b3105bc7eeb55171b96ee.tar.xz
slixmpp-d150b35464742de7af9b3105bc7eeb55171b96ee.zip
fixed todo merge
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..d6fafc59
--- /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)