diff options
author | Brant Knudson <bknudson@us.ibm.com> | 2013-12-08 11:56:55 -0600 |
---|---|---|
committer | Brant Knudson <bknudson@us.ibm.com> | 2014-02-04 11:12:37 -0600 |
commit | 6c54ded334ab212cd064a55b3c029cc86a18ef74 (patch) | |
tree | 75bf2059efdd2be36e7ae7e4432f58d0e06fd8ba | |
parent | 29a0ab6c3658c54c8b5ae4bccba5219573112c53 (diff) | |
download | keystone-6c54ded334ab212cd064a55b3c029cc86a18ef74.tar.gz |
Refactor tests move assertValidErrorResponse
assertValidErrorResponse wasn't used in the test_catalog module
anymore; it's used in the rest module.
Change-Id: I0442e1e07b6c5693ebed29a57dbe8e070b367c44
-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 42010ca19..84eb95edb 100644 --- a/keystone/tests/rest.py +++ b/keystone/tests/rest.py @@ -132,6 +132,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 5579b1732..744c9aa0d 100644 --- a/keystone/tests/test_catalog.py +++ b/keystone/tests/test_catalog.py @@ -59,9 +59,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', |