Cleanup req_format in test_api_v2_resource

Since XML support has been removed test cases in test_api_v2_resource
no longer need to specify req_format.

Change-Id: Ic6572abc3121535e19d21e9a34d70bb42b9782de
Related-Bug: #1380787
This commit is contained in:
Elena Ezhova 2014-12-15 15:44:34 +03:00
parent b4a0fa3c34
commit d481cdd3d9
1 changed files with 8 additions and 20 deletions

View File

@ -125,7 +125,7 @@ class RequestTestCase(base.BaseTestCase):
class ResourceTestCase(base.BaseTestCase): class ResourceTestCase(base.BaseTestCase):
@staticmethod @staticmethod
def _get_deserializer(req_format): def _get_deserializer():
return wsgi.JSONDeserializer() return wsgi.JSONDeserializer()
def test_unmapped_neutron_error_with_json(self): def test_unmapped_neutron_error_with_json(self):
@ -219,15 +219,13 @@ class ResourceTestCase(base.BaseTestCase):
str(wsgi.JSONDeserializer().deserialize(res.body))) str(wsgi.JSONDeserializer().deserialize(res.body)))
@staticmethod @staticmethod
def _make_request_with_side_effect(side_effect, req_format=None): def _make_request_with_side_effect(side_effect):
controller = mock.MagicMock() controller = mock.MagicMock()
controller.test.side_effect = side_effect controller.test.side_effect = side_effect
resource = webtest.TestApp(wsgi_resource.Resource(controller)) resource = webtest.TestApp(wsgi_resource.Resource(controller))
routing_args = {'action': 'test'} routing_args = {'action': 'test'}
if req_format:
routing_args.update({'format': req_format})
environ = {'wsgiorg.routing_args': (None, routing_args)} environ = {'wsgiorg.routing_args': (None, routing_args)}
res = resource.get('', extra_environ=environ, expect_errors=True) res = resource.get('', extra_environ=environ, expect_errors=True)
return res return res
@ -244,25 +242,20 @@ class ResourceTestCase(base.BaseTestCase):
self.assertEqual('', res.json['NeutronError']['detail']) self.assertEqual('', res.json['NeutronError']['detail'])
self.assertEqual(exc.HTTPGatewayTimeout.code, res.status_int) self.assertEqual(exc.HTTPGatewayTimeout.code, res.status_int)
def _test_unhandled_error(self, req_format='json'): def test_unhandled_error(self):
expected_res = {'body': {'NeutronError': expected_res = {'body': {'NeutronError':
{'detail': '', {'detail': '',
'message': _( 'message': _(
'Request Failed: internal server ' 'Request Failed: internal server '
'error while processing your request.'), 'error while processing your request.'),
'type': 'HTTPInternalServerError'}}} 'type': 'HTTPInternalServerError'}}}
res = self._make_request_with_side_effect(side_effect=Exception(), res = self._make_request_with_side_effect(side_effect=Exception())
req_format=req_format)
self.assertEqual(exc.HTTPInternalServerError.code, self.assertEqual(exc.HTTPInternalServerError.code,
res.status_int) res.status_int)
self.assertEqual(expected_res, self.assertEqual(expected_res,
self._get_deserializer( self._get_deserializer().deserialize(res.body))
req_format).deserialize(res.body))
def test_unhandled_error_with_json(self): def test_not_implemented_error(self):
self._test_unhandled_error()
def _test_not_implemented_error(self, req_format='json'):
expected_res = {'body': {'NeutronError': expected_res = {'body': {'NeutronError':
{'detail': '', {'detail': '',
'message': _( 'message': _(
@ -271,15 +264,10 @@ class ResourceTestCase(base.BaseTestCase):
'operation.'), 'operation.'),
'type': 'HTTPNotImplemented'}}} 'type': 'HTTPNotImplemented'}}}
res = self._make_request_with_side_effect(exc.HTTPNotImplemented(), res = self._make_request_with_side_effect(exc.HTTPNotImplemented())
req_format=req_format)
self.assertEqual(exc.HTTPNotImplemented.code, res.status_int) self.assertEqual(exc.HTTPNotImplemented.code, res.status_int)
self.assertEqual(expected_res, self.assertEqual(expected_res,
self._get_deserializer( self._get_deserializer().deserialize(res.body))
req_format).deserialize(res.body))
def test_not_implemented_error_with_json(self):
self._test_not_implemented_error()
def test_status_200(self): def test_status_200(self):
controller = mock.MagicMock() controller = mock.MagicMock()