Пример #1
0
 def test_fault_call(self, mock_request):
     # Ensure proper EC2 response on faults.
     message = 'test message'
     ex = webob.exc.HTTPNotFound(explanation=message)
     fault = faults.Fault(ex)
     req = wsgi.Request.blank('/test')
     req.GET['AWSAccessKeyId'] = "test_user_id:test_project_id"
     fault(req)
     mock_request.assert_called_with(mock.ANY,
                                     'HTTPNotFound',
                                     message=message,
                                     status=ex.status_int)
Пример #2
0
 def __call__(self, req):
     try:
         return req.get_response(self.application)
     except Exception:
         LOG.exception("FaultWrapper catches error")
         return faults.Fault(webob.exc.HTTPInternalServerError())
Пример #3
0
 def test_fault_exception_status_int(self):
     # Ensure the status_int is set correctly on faults.
     fault = faults.Fault(webob.exc.HTTPNotFound(explanation='test'))
     self.assertEqual(fault.wrapped_exc.status_int, 404)
Пример #4
0
 def test_fault_exception(self):
     # Ensure the status_int is set correctly on faults.
     fault = faults.Fault(webob.exc.HTTPBadRequest(explanation='test'))
     self.assertIsInstance(fault.wrapped_exc, webob.exc.HTTPBadRequest)