Exemple #1
0
 def test_httpexception_message(self):
     """Make sure the message from a HTTPException is preserved."""
     msg = "foo"
     resp = _exception_to_response(exc.HTTPBadRequest(msg), "cookie")
     self.assertEqual(json.loads(resp.body)['detail'], msg)
Exemple #2
0
 def test_exception_message(self):
     """Make sure the message from a non-HTTPException is elided."""
     msg = "Something went terribly wrong"
     resp = _exception_to_response(ValueError(msg), "cookie")
     self.assertNotEqual(json.loads(resp.body)['detail'], msg)
Exemple #3
0
 def test_no_traceback(self):
     """Make sure there is no traceback."""
     resp = _exception_to_response(Exception("foo"), "cookie")
     self.assertFalse('traceback' in json.loads(resp.body))
Exemple #4
0
 def test_has_cookie(self):
     """Make sure the cookie is included."""
     resp = _exception_to_response(Exception("foo"), "cookie")
     body = json.loads(resp.body)
     self.assertTrue('cookie' in body)
     self.assertEqual(body['cookie'], 'cookie')
Exemple #5
0
 def test_has_detail(self):
     """Make sure there's error detail."""
     resp = _exception_to_response(Exception("foo"), "cookie")
     body = json.loads(resp.body)
     self.assertTrue('detail' in body)
Exemple #6
0
 def test_status(self):
     """Make sure webob exception statuses are preserved."""
     not_found = exc.HTTPNotFound("Sorry")
     resp = _exception_to_response(not_found)
     self.assertEqual(not_found.status, resp.status)
Exemple #7
0
 def test_types(self):
     resp = _exception_to_response(Exception("foo"))
     self.assertTrue(isinstance(resp, Response))