Example #1
0
 def test_info(self):
     e = ContextException("not hot enough", temperature=42)
     self.assertEqual(e.info(), {"code": 0, "message": str(e)})
Example #2
0
 def test_response(self):
     e = ContextException("not hot enough", temperature=42)
     self.assertEqual(e.response(), {"status": e.info()})
Example #3
0
 def test_str(self):
     e = ContextException("not hot enough", temperature=42)
     self.assertEqual(str(e), "%s: %s" % (e.message, e.context))
Example #4
0
 def test_context_reason_and_kwargs(self):
     e = ContextException("not hot enough", temperature=42)
     self.assertEqual(e.context,
                      dict(reason="not hot enough", temperature=42))
Example #5
0
 def test_context_explicit_reason(self):
     e = ContextException(reason="not hot enough")
     self.assertEqual(e.context, dict(reason="not hot enough"))
Example #6
0
 def test_context_single_argument(self):
     e = ContextException("not hot enough")
     self.assertEqual(e.context, dict(reason="not hot enough"))
Example #7
0
 def test_context_no_arguments(self):
     e = ContextException()
     self.assertEqual(e.context, {})