diff options
author | Jenkins <jenkins@review.openstack.org> | 2011-12-07 04:11:26 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2011-12-07 04:11:26 +0000 |
commit | 45e31ab90d22cbb84a33c051ee43f273b7a4c38b (patch) | |
tree | 795b68a3597f72521f99b857d4ea2004b26e19de | |
parent | 3e3e378f8350ecd6f4cad7b6bfeee47a88e98e33 (diff) | |
parent | dca73f7c8c6f65e449a4b7500b679fb51418a138 (diff) | |
download | nova-45e31ab90d22cbb84a33c051ee43f273b7a4c38b.tar.gz nova-45e31ab90d22cbb84a33c051ee43f273b7a4c38b.tar.xz nova-45e31ab90d22cbb84a33c051ee43f273b7a4c38b.zip |
Merge "Change cloudServersFault to computeFault"
-rw-r--r-- | nova/api/openstack/wsgi.py | 2 | ||||
-rw-r--r-- | nova/tests/api/openstack/v2/test_api.py | 41 |
2 files changed, 19 insertions, 24 deletions
diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 7e4875066..1ffca9ecc 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -637,7 +637,7 @@ class Fault(webob.exc.HTTPException): """Generate a WSGI response based on the exception passed to ctor.""" # Replace the body with fault details. code = self.wrapped_exc.status_int - fault_name = self._fault_names.get(code, "cloudServersFault") + fault_name = self._fault_names.get(code, "computeFault") fault_data = { fault_name: { 'code': code, diff --git a/nova/tests/api/openstack/v2/test_api.py b/nova/tests/api/openstack/v2/test_api.py index 318c03a88..d09bb0cfa 100644 --- a/nova/tests/api/openstack/v2/test_api.py +++ b/nova/tests/api/openstack/v2/test_api.py @@ -76,51 +76,46 @@ class APITest(test.TestCase): body = etree.XML(res.body) - def test_exceptions_are_converted_to_faults(self): - - @webob.dec.wsgify - def succeed(req): - return 'Succeeded' - + def test_exceptions_are_converted_to_faults_webob_exc(self): @webob.dec.wsgify def raise_webob_exc(req): raise webob.exc.HTTPNotFound(explanation='Raised a webob.exc') - @webob.dec.wsgify - def fail(req): - raise Exception("Threw an exception") + #api.application = raise_webob_exc + api = self._wsgi_app(raise_webob_exc) + resp = Request.blank('/').get_response(api) + self.assertEqual(resp.status_int, 404, resp.body) + def test_exceptions_are_converted_to_faults_api_fault(self): @webob.dec.wsgify def raise_api_fault(req): exc = webob.exc.HTTPNotFound(explanation='Raised a webob.exc') return wsgi.Fault(exc) - #api.application = succeed - api = self._wsgi_app(succeed) - resp = Request.blank('/').get_response(api) - self.assertFalse('cloudServersFault' in resp.body, resp.body) - self.assertEqual(resp.status_int, 200, resp.body) - - #api.application = raise_webob_exc - api = self._wsgi_app(raise_webob_exc) - resp = Request.blank('/').get_response(api) - self.assertFalse('cloudServersFault' in resp.body, resp.body) - self.assertEqual(resp.status_int, 404, resp.body) - #api.application = raise_api_fault api = self._wsgi_app(raise_api_fault) resp = Request.blank('/').get_response(api) self.assertTrue('itemNotFound' in resp.body, resp.body) self.assertEqual(resp.status_int, 404, resp.body) + def test_exceptions_are_converted_to_faults_exception(self): + @webob.dec.wsgify + def fail(req): + raise Exception("Threw an exception") + #api.application = fail api = self._wsgi_app(fail) resp = Request.blank('/').get_response(api) - self.assertTrue('{"cloudServersFault' in resp.body, resp.body) + self.assertTrue('{"computeFault' in resp.body, resp.body) self.assertEqual(resp.status_int, 500, resp.body) + def test_exceptions_are_converted_to_faults_exception_xml(self): + @webob.dec.wsgify + def fail(req): + raise Exception("Threw an exception") + #api.application = fail api = self._wsgi_app(fail) resp = Request.blank('/.xml').get_response(api) - self.assertTrue('<cloudServersFault' in resp.body, resp.body) + self.assertTrue('<computeFault' in resp.body, resp.body) self.assertEqual(resp.status_int, 500, resp.body) |