diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-07-13 23:32:51 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-07-13 23:32:51 +0000 |
| commit | 58c92d66e7220574038cedd3079d64649ced2106 (patch) | |
| tree | de6e7ba63faf9681e7d4c611c29422b27d6ab374 /nova/tests | |
| parent | f4a778f31f647b065b945311920148366d4ead53 (diff) | |
| parent | e9d21589d39355ffc126e360cc2ba7311e014edb (diff) | |
Merge "Expose over-quota exceptions via native API."
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/api/openstack/compute/test_api.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/nova/tests/api/openstack/compute/test_api.py b/nova/tests/api/openstack/compute/test_api.py index 434befdb9..a1dd01be3 100644 --- a/nova/tests/api/openstack/compute/test_api.py +++ b/nova/tests/api/openstack/compute/test_api.py @@ -23,6 +23,7 @@ import webob.exc from nova.api import openstack as openstack_api from nova.api.openstack import wsgi import nova.context +from nova import exception from nova.openstack.common import jsonutils from nova import test from nova.tests.api.openstack import fakes @@ -120,6 +121,29 @@ class APITest(test.TestCase): self.assertTrue('<computeFault' in resp.body, resp.body) self.assertEqual(resp.status_int, 500, resp.body) + def _do_test_exception_safety_reflected_in_faults(self, expose): + class ExceptionWithSafety(exception.NovaException): + safe = expose + + @webob.dec.wsgify + def fail(req): + raise ExceptionWithSafety('some explanation') + + api = self._wsgi_app(fail) + resp = webob.Request.blank('/').get_response(api) + self.assertTrue('{"computeFault' in resp.body, resp.body) + expected = ('ExceptionWithSafety: some explanation' if expose else + 'The server has either erred or is incapable ' + 'of performing the requested operation.') + self.assertTrue(expected in resp.body, resp.body) + self.assertEqual(resp.status_int, 500, resp.body) + + def test_safe_exceptions_are_described_in_faults(self): + self._do_test_exception_safety_reflected_in_faults(True) + + def test_unsafe_exceptions_are_not_described_in_faults(self): + self._do_test_exception_safety_reflected_in_faults(False) + def test_request_id_in_response(self): req = webob.Request.blank('/') req.method = 'GET' |
