2010-08-06 00:23:07 +00:00
|
|
|
from . sleektest import *
|
2010-07-30 03:55:13 +00:00
|
|
|
|
|
|
|
class TestErrorStanzas(SleekTest):
|
2010-08-06 00:23:07 +00:00
|
|
|
|
2010-07-30 03:55:13 +00:00
|
|
|
def testSetup(self):
|
|
|
|
"""Test setting initial values in error stanza."""
|
|
|
|
msg = self.Message()
|
|
|
|
msg.enable('error')
|
2010-10-07 13:22:27 +00:00
|
|
|
self.check_message(msg, """
|
2010-07-30 03:55:13 +00:00
|
|
|
<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."""
|
2010-08-06 00:23:07 +00:00
|
|
|
msg = self.Message()
|
2010-07-30 03:55:13 +00:00
|
|
|
msg['error']['condition'] = 'item-not-found'
|
|
|
|
|
2010-10-07 13:22:27 +00:00
|
|
|
self.check_message(msg, """
|
2010-07-30 03:55:13 +00:00
|
|
|
<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']
|
|
|
|
|
2010-10-07 13:22:27 +00:00
|
|
|
self.check_message(msg, """
|
2010-07-30 03:55:13 +00:00
|
|
|
<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'
|
2010-08-06 00:23:07 +00:00
|
|
|
|
2010-07-30 03:55:13 +00:00
|
|
|
del msg['error']['condition']
|
|
|
|
|
2010-10-07 13:22:27 +00:00
|
|
|
self.check_message(msg, """
|
2010-07-30 03:55:13 +00:00
|
|
|
<message type="error">
|
|
|
|
<error type="cancel">
|
|
|
|
<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Error!</text>
|
|
|
|
</error>
|
|
|
|
</message>
|
|
|
|
""")
|
|
|
|
|
|
|
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestErrorStanzas)
|