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, """
""")
def testCondition(self):
"""Test modifying the error condition."""
msg = self.Message()
msg['error']['condition'] = 'item-not-found'
self.checkMessage(msg, """
""")
self.failUnless(msg['error']['condition'] == 'item-not-found', "Error condition doesn't match.")
del msg['error']['condition']
self.checkMessage(msg, """
""")
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, """
Error!
""")
suite = unittest.TestLoader().loadTestsFromTestCase(TestErrorStanzas)