diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-02-25 06:59:15 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-02-25 06:59:15 +0000 |
commit | c32fe003e72b5261efc84ae96bcf42ab51b2213a (patch) | |
tree | e8d5de6645c3427f62205f489389dc2f59781619 | |
parent | 55c37dd1946100f90f90be3488fd3f8d89fa444e (diff) | |
parent | 6c54ded334ab212cd064a55b3c029cc86a18ef74 (diff) | |
download | keystone-c32fe003e72b5261efc84ae96bcf42ab51b2213a.tar.gz |
Merge "Refactor tests move assertValidErrorResponse"
-rw-r--r-- | keystone/tests/rest.py | 11 | ||||
-rw-r--r-- | keystone/tests/test_catalog.py | 3 |
2 files changed, 11 insertions, 3 deletions
diff --git a/keystone/tests/rest.py b/keystone/tests/rest.py index caedcee0d..83948bcb5 100644 --- a/keystone/tests/rest.py +++ b/keystone/tests/rest.py @@ -130,6 +130,17 @@ class RestfulTestCase(tests.TestCase): """Ensures that response headers appear as expected.""" self.assertIn('X-Auth-Token', response.headers.get('Vary')) + def assertValidErrorResponse(self, response, expected_status=400): + """Verify that the error response is valid. + + Subclasses can override this function based on the expected response. + + """ + self.assertEqual(response.status_code, expected_status) + error = response.result['error'] + self.assertEqual(error['code'], response.status_code) + self.assertIsNotNone(error.get('title')) + def _to_content_type(self, body, headers, content_type=None): """Attempt to encode JSON and XML automatically.""" content_type = content_type or self.content_type diff --git a/keystone/tests/test_catalog.py b/keystone/tests/test_catalog.py index 559d95616..348aca225 100644 --- a/keystone/tests/test_catalog.py +++ b/keystone/tests/test_catalog.py @@ -57,9 +57,6 @@ class V2CatalogTestCase(rest.RestfulTestCase): """Applicable only to JSON.""" return r.result['access']['token']['id'] - def assertValidErrorResponse(self, response): - self.assertEqual(response.status_code, 400) - def _endpoint_create(self, expected_status=200, service_id=SERVICE_FIXTURE, publicurl='http://localhost:8080', internalurl='http://localhost:8080', |