From 220e44a3ac905ef26363eb8db1503dcc8d4bc4c4 Mon Sep 17 00:00:00 2001 From: ricolin Date: Thu, 12 Nov 2015 21:58:16 +0800 Subject: [PATCH] Use EntityNotFound instead of StackNotFound. replace and remove StackNotFound Change-Id: I0bf4e35e4acf8bcfdd933c7fb862c63f7550f6c2 Partial-Bug: #1515603 --- heat/api/aws/exception.py | 2 +- heat/api/middleware/fault.py | 1 - heat/common/exception.py | 4 ---- heat/engine/service.py | 8 ++++--- heat/tests/api/cfn/test_api_cfn_v1.py | 16 ++++++------- heat/tests/api/openstack_v1/test_events.py | 8 +++---- heat/tests/api/openstack_v1/test_resources.py | 12 +++++----- heat/tests/api/openstack_v1/test_stacks.py | 24 +++++++++---------- .../tests/engine/service/test_stack_action.py | 4 ++-- .../tests/engine/service/test_stack_delete.py | 2 +- .../engine/service/test_stack_resources.py | 12 ++++++---- .../tests/engine/service/test_stack_update.py | 2 +- heat/tests/test_engine_service.py | 7 +++--- heat/tests/test_fault_middleware.py | 14 +++++------ 14 files changed, 58 insertions(+), 58 deletions(-) diff --git a/heat/api/aws/exception.py b/heat/api/aws/exception.py index 7c0ee3c1e3..fc4752f7f3 100644 --- a/heat/api/aws/exception.py +++ b/heat/api/aws/exception.py @@ -284,7 +284,7 @@ def map_remote_error(ex): 'AttributeError', 'ValueError', 'InvalidTenant', - 'StackNotFound', + 'EntityNotFound', 'ResourceActionNotSupported', 'ResourceNotFound', 'ResourceNotAvailable', diff --git a/heat/api/middleware/fault.py b/heat/api/middleware/fault.py index 68c331463e..5a39b3602a 100644 --- a/heat/api/middleware/fault.py +++ b/heat/api/middleware/fault.py @@ -57,7 +57,6 @@ class FaultWrapper(wsgi.Middleware): 'ActionInProgress': webob.exc.HTTPConflict, 'ValueError': webob.exc.HTTPBadRequest, 'EntityNotFound': webob.exc.HTTPNotFound, - 'StackNotFound': webob.exc.HTTPNotFound, 'NotFound': webob.exc.HTTPNotFound, 'ResourceActionNotSupported': webob.exc.HTTPBadRequest, 'ResourceNotFound': webob.exc.HTTPNotFound, diff --git a/heat/common/exception.py b/heat/common/exception.py index ef0b127984..572f7f3ee6 100644 --- a/heat/common/exception.py +++ b/heat/common/exception.py @@ -149,10 +149,6 @@ class InvalidTenant(HeatException): "from Tenant %(actual)s forbidden.") -class StackNotFound(HeatException): - msg_fmt = _("The Stack (%(stack_name)s) could not be found.") - - class StackExists(HeatException): msg_fmt = _("The Stack (%(stack_name)s) already exists.") diff --git a/heat/engine/service.py b/heat/engine/service.py index ed574fc765..f8ed38d806 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -439,7 +439,7 @@ class EngineService(service.Service): stack = parser.Stack.load(cnxt, stack=s) return dict(stack.identifier()) else: - raise exception.StackNotFound(stack_name=stack_name) + raise exception.EntityNotFound(entity='Stack', name=stack_name) def _get_stack(self, cnxt, stack_identity, show_deleted=False): identity = identifier.HeatIdentifier(**stack_identity) @@ -451,7 +451,8 @@ class EngineService(service.Service): eager_load=True) if s is None: - raise exception.StackNotFound(stack_name=identity.stack_name) + raise exception.EntityNotFound(entity='Stack', + name=identity.stack_name) if cnxt.tenant_id not in (identity.tenant, s.stack_user_project_id): # The DB API should not allow this, but sanity-check anyway.. @@ -459,7 +460,8 @@ class EngineService(service.Service): actual=cnxt.tenant_id) if identity.path or s.name != identity.stack_name: - raise exception.StackNotFound(stack_name=identity.stack_name) + raise exception.EntityNotFound(entity='Stack', + name=identity.stack_name) return s diff --git a/heat/tests/api/cfn/test_api_cfn_v1.py b/heat/tests/api/cfn/test_api_cfn_v1.py index c863c4f912..2ea0bc95e0 100644 --- a/heat/tests/api/cfn/test_api_cfn_v1.py +++ b/heat/tests/api/cfn/test_api_cfn_v1.py @@ -488,7 +488,7 @@ class CfnStackControllerTest(common.HeatTestCase): self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( dummy_req.context, ('identify_stack', {'stack_name': stack_name}) - ).AndRaise(heat_exception.StackNotFound(stack_name='test')) + ).AndRaise(heat_exception.EntityNotFound(entity='Stack', name='test')) self.m.ReplayAll() @@ -934,7 +934,7 @@ class CfnStackControllerTest(common.HeatTestCase): rpc_client.EngineClient.call( dummy_req.context, ('identify_stack', {'stack_name': stack_name}) - ).AndRaise(heat_exception.StackNotFound(stack_name='test')) + ).AndRaise(heat_exception.EntityNotFound(entity='Stack', name='test')) self.m.ReplayAll() @@ -1011,7 +1011,7 @@ class CfnStackControllerTest(common.HeatTestCase): rpc_client.EngineClient.call( dummy_req.context, ('identify_stack', {'stack_name': stack_name}) - ).AndRaise(heat_exception.StackNotFound(stack_name='test')) + ).AndRaise(heat_exception.EntityNotFound(entity='Stack', name='test')) self.m.ReplayAll() @@ -1159,7 +1159,7 @@ class CfnStackControllerTest(common.HeatTestCase): self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( dummy_req.context, ('identify_stack', {'stack_name': stack_name}) - ).AndRaise(heat_exception.StackNotFound(stack_name='test')) + ).AndRaise(heat_exception.EntityNotFound(entity='Stack', name='test')) self.m.ReplayAll() @@ -1267,7 +1267,7 @@ class CfnStackControllerTest(common.HeatTestCase): self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( dummy_req.context, ('identify_stack', {'stack_name': stack_name}) - ).AndRaise(heat_exception.StackNotFound(stack_name='test')) + ).AndRaise(heat_exception.EntityNotFound(entity='Stack', name='test')) self.m.ReplayAll() @@ -1354,7 +1354,7 @@ class CfnStackControllerTest(common.HeatTestCase): self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( dummy_req.context, ('identify_stack', {'stack_name': stack_name}) - ).AndRaise(heat_exception.StackNotFound(stack_name='test')) + ).AndRaise(heat_exception.EntityNotFound(entity='Stack', name='test')) self.m.ReplayAll() @@ -1469,7 +1469,7 @@ class CfnStackControllerTest(common.HeatTestCase): self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( dummy_req.context, ('identify_stack', {'stack_name': stack_name}) - ).AndRaise(heat_exception.StackNotFound(stack_name='test')) + ).AndRaise(heat_exception.EntityNotFound(entity='Stack', name='test')) self.m.ReplayAll() @@ -1650,7 +1650,7 @@ class CfnStackControllerTest(common.HeatTestCase): self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( dummy_req.context, ('identify_stack', {'stack_name': stack_name}) - ).AndRaise(heat_exception.StackNotFound(stack_name='test')) + ).AndRaise(heat_exception.EntityNotFound(entity='Stack', name='test')) self.m.ReplayAll() diff --git a/heat/tests/api/openstack_v1/test_events.py b/heat/tests/api/openstack_v1/test_events.py index e96eaf09aa..b9b151d3b3 100644 --- a/heat/tests/api/openstack_v1/test_events.py +++ b/heat/tests/api/openstack_v1/test_events.py @@ -291,7 +291,7 @@ class EventControllerTest(tools.ControllerTest, common.HeatTestCase): 'limit': None, 'sort_keys': None, 'marker': None, 'sort_dir': None, 'filters': None} - error = heat_exc.StackNotFound(stack_name='a') + error = heat_exc.EntityNotFound(entity='Stack', name='a') self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( req.context, @@ -307,7 +307,7 @@ class EventControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=stack_identity.stack_id) self.assertEqual(404, resp.json['code']) - self.assertEqual('StackNotFound', resp.json['error']['type']) + self.assertEqual('EntityNotFound', resp.json['error']['type']) self.m.VerifyAll() def test_index_err_denied_policy(self, mock_enforce): @@ -565,7 +565,7 @@ class EventControllerTest(tools.ControllerTest, common.HeatTestCase): 'limit': None, 'sort_keys': None, 'marker': None, 'sort_dir': None, 'filters': {'resource_name': res_name}} - error = heat_exc.StackNotFound(stack_name='a') + error = heat_exc.EntityNotFound(entity='Stack', name='a') self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( req.context, ('list_events', kwargs) @@ -582,7 +582,7 @@ class EventControllerTest(tools.ControllerTest, common.HeatTestCase): event_id=event_id) self.assertEqual(404, resp.json['code']) - self.assertEqual('StackNotFound', resp.json['error']['type']) + self.assertEqual('EntityNotFound', resp.json['error']['type']) self.m.VerifyAll() def test_show_err_denied_policy(self, mock_enforce): diff --git a/heat/tests/api/openstack_v1/test_resources.py b/heat/tests/api/openstack_v1/test_resources.py index 27e2da2569..82c69cade9 100644 --- a/heat/tests/api/openstack_v1/test_resources.py +++ b/heat/tests/api/openstack_v1/test_resources.py @@ -108,7 +108,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): req = self._get(stack_identity._tenant_path() + '/resources') - error = heat_exc.StackNotFound(stack_name='a') + error = heat_exc.EntityNotFound(entity='Stack', name='a') self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( req.context, @@ -127,7 +127,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=stack_identity.stack_id) self.assertEqual(404, resp.json['code']) - self.assertEqual('StackNotFound', resp.json['error']['type']) + self.assertEqual('EntityNotFound', resp.json['error']['type']) self.m.VerifyAll() def test_index_nested_depth(self, mock_enforce): @@ -391,7 +391,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): req = self._get(res_identity._tenant_path()) - error = heat_exc.StackNotFound(stack_name='a') + error = heat_exc.EntityNotFound(entity='Stack', name='a') self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( req.context, @@ -411,7 +411,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): resource_name=res_name) self.assertEqual(404, resp.json['code']) - self.assertEqual('StackNotFound', resp.json['error']['type']) + self.assertEqual('EntityNotFound', resp.json['error']['type']) self.m.VerifyAll() def test_show_with_single_attribute(self, mock_enforce): @@ -597,7 +597,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): req = self._get(res_identity._tenant_path() + '/metadata') - error = heat_exc.StackNotFound(stack_name='a') + error = heat_exc.EntityNotFound(entity='Stack', name='a') self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( req.context, @@ -617,7 +617,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase): resource_name=res_name) self.assertEqual(404, resp.json['code']) - self.assertEqual('StackNotFound', resp.json['error']['type']) + self.assertEqual('EntityNotFound', resp.json['error']['type']) self.m.VerifyAll() def test_metadata_show_nonexist_resource(self, mock_enforce): diff --git a/heat/tests/api/openstack_v1/test_stacks.py b/heat/tests/api/openstack_v1/test_stacks.py index c17eb94040..b58729c766 100644 --- a/heat/tests/api/openstack_v1/test_stacks.py +++ b/heat/tests/api/openstack_v1/test_stacks.py @@ -1284,7 +1284,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): req = self._get('/stacks/%(stack_name)s' % { 'stack_name': stack_name}) - error = heat_exc.StackNotFound(stack_name='a') + error = heat_exc.EntityNotFound(entity='Stack', name='a') self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( req.context, @@ -1298,7 +1298,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): stack_name=stack_name) self.assertEqual(404, resp.json['code']) - self.assertEqual('StackNotFound', resp.json['error']['type']) + self.assertEqual('EntityNotFound', resp.json['error']['type']) self.m.VerifyAll() def test_lookup_err_policy(self, mock_enforce): @@ -1346,7 +1346,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): req = self._get('/stacks/%(stack_name)s/resources' % { 'stack_name': stack_name}) - error = heat_exc.StackNotFound(stack_name='a') + error = heat_exc.EntityNotFound(entity='Stack', name='a') self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( req.context, @@ -1361,7 +1361,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): path='resources') self.assertEqual(404, resp.json['code']) - self.assertEqual('StackNotFound', resp.json['error']['type']) + self.assertEqual('EntityNotFound', resp.json['error']['type']) self.m.VerifyAll() def test_lookup_resource_err_denied_policy(self, mock_enforce): @@ -1454,7 +1454,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): req = self._get('/stacks/%(stack_name)s/%(stack_id)s' % identity) - error = heat_exc.StackNotFound(stack_name='a') + error = heat_exc.EntityNotFound(entity='Stack', name='a') self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( req.context, @@ -1469,7 +1469,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=identity.stack_id) self.assertEqual(404, resp.json['code']) - self.assertEqual('StackNotFound', resp.json['error']['type']) + self.assertEqual('EntityNotFound', resp.json['error']['type']) self.m.VerifyAll() def test_show_invalidtenant(self, mock_enforce): @@ -1546,7 +1546,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): identity = identifier.HeatIdentifier(self.tenant, 'wordpress', '6') req = self._get('/stacks/%(stack_name)s/%(stack_id)s' % identity) - error = heat_exc.StackNotFound(stack_name='a') + error = heat_exc.EntityNotFound(entity='Stack', name='a') self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( req.context, @@ -1562,7 +1562,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=identity.stack_id) self.assertEqual(404, resp.json['code']) - self.assertEqual('StackNotFound', resp.json['error']['type']) + self.assertEqual('EntityNotFound', resp.json['error']['type']) self.m.VerifyAll() def test_update(self, mock_enforce): @@ -1651,7 +1651,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): req = self._put('/stacks/%(stack_name)s/%(stack_id)s' % identity, json.dumps(body)) - error = heat_exc.StackNotFound(stack_name='a') + error = heat_exc.EntityNotFound(entity='Stack', name='a') self.m.StubOutWithMock(rpc_client.EngineClient, 'call') rpc_client.EngineClient.call( req.context, @@ -1675,7 +1675,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): body=body) self.assertEqual(404, resp.json['code']) - self.assertEqual('StackNotFound', resp.json['error']['type']) + self.assertEqual('EntityNotFound', resp.json['error']['type']) self.m.VerifyAll() def test_update_timeout_not_int(self, mock_enforce): @@ -2054,7 +2054,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): req = self._delete('/stacks/%(stack_name)s/%(stack_id)s' % identity) - error = heat_exc.StackNotFound(stack_name='a') + error = heat_exc.EntityNotFound(entity='Stack', name='a') self.m.StubOutWithMock(rpc_client.EngineClient, 'call') # Engine returns None when delete successful rpc_client.EngineClient.call( @@ -2070,7 +2070,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase): stack_id=identity.stack_id) self.assertEqual(404, resp.json['code']) - self.assertEqual('StackNotFound', resp.json['error']['type']) + self.assertEqual('EntityNotFound', resp.json['error']['type']) self.m.VerifyAll() def test_validate_template(self, mock_enforce): diff --git a/heat/tests/engine/service/test_stack_action.py b/heat/tests/engine/service/test_stack_action.py index a6f3291f98..579c956171 100644 --- a/heat/tests/engine/service/test_stack_action.py +++ b/heat/tests/engine/service/test_stack_action.py @@ -83,7 +83,7 @@ class StackServiceActionsTest(common.HeatTestCase): ex = self.assertRaises(dispatcher.ExpectedException, self.man.stack_suspend, self.ctx, stk.identifier()) - self.assertEqual(exception.StackNotFound, ex.exc_info[0]) + self.assertEqual(exception.EntityNotFound, ex.exc_info[0]) def test_stack_resume_nonexist(self): stack_name = 'service_resume_nonexist_test_stack' @@ -94,7 +94,7 @@ class StackServiceActionsTest(common.HeatTestCase): ex = self.assertRaises(dispatcher.ExpectedException, self.man.stack_resume, self.ctx, stk.identifier()) - self.assertEqual(exception.StackNotFound, ex.exc_info[0]) + self.assertEqual(exception.EntityNotFound, ex.exc_info[0]) def _mock_thread_start(self, stack_id, func, *args, **kwargs): func(*args, **kwargs) diff --git a/heat/tests/engine/service/test_stack_delete.py b/heat/tests/engine/service/test_stack_delete.py index 085e9f1d7c..6bafbbc1b2 100644 --- a/heat/tests/engine/service/test_stack_delete.py +++ b/heat/tests/engine/service/test_stack_delete.py @@ -52,7 +52,7 @@ class StackDeleteTest(common.HeatTestCase): ex = self.assertRaises(dispatcher.ExpectedException, self.man.delete_stack, self.ctx, stack.identifier()) - self.assertEqual(exception.StackNotFound, ex.exc_info[0]) + self.assertEqual(exception.EntityNotFound, ex.exc_info[0]) @mock.patch.object(parser.Stack, 'load') @mock.patch.object(stack_lock.StackLock, 'try_acquire') diff --git a/heat/tests/engine/service/test_stack_resources.py b/heat/tests/engine/service/test_stack_resources.py index b765e82248..f13822381b 100644 --- a/heat/tests/engine/service/test_stack_resources.py +++ b/heat/tests/engine/service/test_stack_resources.py @@ -97,12 +97,13 @@ class StackResourcesServiceTest(common.HeatTestCase): non_exist_identifier = identifier.HeatIdentifier( self.ctx.tenant_id, 'wibble', '18d06e2e-44d3-4bef-9fbf-52480d604b02') - mock_get.side_effect = exception.StackNotFound(stack_name='test') + mock_get.side_effect = exception.EntityNotFound( + entity='Stack', name='test') ex = self.assertRaises(dispatcher.ExpectedException, self.eng.describe_stack_resource, self.ctx, non_exist_identifier, 'WebServer') - self.assertEqual(exception.StackNotFound, ex.exc_info[0]) + self.assertEqual(exception.EntityNotFound, ex.exc_info[0]) mock_get.assert_called_once_with(self.ctx, non_exist_identifier) @mock.patch.object(stack.Stack, 'load') @@ -191,7 +192,7 @@ class StackResourcesServiceTest(common.HeatTestCase): ex = self.assertRaises(dispatcher.ExpectedException, self.eng.describe_stack_resources, self.ctx, non_exist_identifier, 'WebServer') - self.assertEqual(exception.StackNotFound, ex.exc_info[0]) + self.assertEqual(exception.EntityNotFound, ex.exc_info[0]) @tools.stack_context('find_phys_res_stack') def test_find_physical_resource(self): @@ -273,12 +274,13 @@ class StackResourcesServiceTest(common.HeatTestCase): non_exist_identifier = identifier.HeatIdentifier( self.ctx.tenant_id, 'wibble', '18d06e2e-44d3-4bef-9fbf-52480d604b02') - mock_get.side_effect = exception.StackNotFound(stack_name='test') + mock_get.side_effect = exception.EntityNotFound(entity='Stack', + name='test') ex = self.assertRaises(dispatcher.ExpectedException, self.eng.list_stack_resources, self.ctx, non_exist_identifier) - self.assertEqual(exception.StackNotFound, ex.exc_info[0]) + self.assertEqual(exception.EntityNotFound, ex.exc_info[0]) mock_get.assert_called_once_with(self.ctx, non_exist_identifier, show_deleted=True) diff --git a/heat/tests/engine/service/test_stack_update.py b/heat/tests/engine/service/test_stack_update.py index 376ad7b4e4..1a5fb970ef 100644 --- a/heat/tests/engine/service/test_stack_update.py +++ b/heat/tests/engine/service/test_stack_update.py @@ -554,7 +554,7 @@ class ServiceStackUpdateTest(common.HeatTestCase): self.man.update_stack, self.ctx, stk.identifier(), template, params, None, {}) - self.assertEqual(exception.StackNotFound, ex.exc_info[0]) + self.assertEqual(exception.EntityNotFound, ex.exc_info[0]) def test_stack_update_no_credentials(self): cfg.CONF.set_default('deferred_auth_method', 'password') diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index a48f85e9c1..9873b9e4fb 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -450,7 +450,7 @@ class StackServiceTest(common.HeatTestCase): def test_stack_identify_nonexist(self): ex = self.assertRaises(dispatcher.ExpectedException, self.eng.identify_stack, self.ctx, 'wibble') - self.assertEqual(exception.StackNotFound, ex.exc_info[0]) + self.assertEqual(exception.EntityNotFound, ex.exc_info[0]) @tools.stack_context('service_create_existing_test_stack', False) def test_stack_create_existing(self): @@ -853,7 +853,8 @@ class StackServiceTest(common.HeatTestCase): self.ctx.tenant_id, 'wibble', '18d06e2e-44d3-4bef-9fbf-52480d604b02') - stack_not_found_exc = exception.StackNotFound(stack_name='test') + stack_not_found_exc = exception.EntityNotFound( + entity='Stack', name='test') self.m.StubOutWithMock(service.EngineService, '_get_stack') service.EngineService._get_stack( self.ctx, non_exist_identifier, @@ -863,7 +864,7 @@ class StackServiceTest(common.HeatTestCase): ex = self.assertRaises(dispatcher.ExpectedException, self.eng.show_stack, self.ctx, non_exist_identifier) - self.assertEqual(exception.StackNotFound, ex.exc_info[0]) + self.assertEqual(exception.EntityNotFound, ex.exc_info[0]) self.m.VerifyAll() def test_stack_describe_bad_tenant(self): diff --git a/heat/tests/test_fault_middleware.py b/heat/tests/test_fault_middleware.py index 93aa185a24..01efb17e9e 100644 --- a/heat/tests/test_fault_middleware.py +++ b/heat/tests/test_fault_middleware.py @@ -26,7 +26,7 @@ from heat.common.i18n import _ from heat.tests import common -class StackNotFoundChild(heat_exc.StackNotFound): +class StackNotFoundChild(heat_exc.EntityNotFound): pass @@ -70,11 +70,11 @@ class FaultMiddlewareTest(common.HeatTestCase): def test_openstack_exception_with_kwargs(self): wrapper = fault.FaultWrapper(None) - msg = wrapper._error(heat_exc.StackNotFound(stack_name='a')) + msg = wrapper._error(heat_exc.EntityNotFound(entity='Stack', name='a')) expected = {'code': 404, 'error': {'message': 'The Stack (a) could not be found.', 'traceback': None, - 'type': 'StackNotFound'}, + 'type': 'EntityNotFound'}, 'explanation': 'The resource could not be found.', 'title': 'Not Found'} self.assertEqual(expected, msg) @@ -116,7 +116,7 @@ class FaultMiddlewareTest(common.HeatTestCase): def test_remote_exception(self): # We want tracebacks cfg.CONF.set_override('debug', True) - error = heat_exc.StackNotFound(stack_name='a') + error = heat_exc.EntityNotFound(entity='Stack', name='a') exc_info = (type(error), error, None) serialized = rpc_common.serialize_remote_exception(exc_info) remote_error = rpc_common.deserialize_remote_exception( @@ -128,7 +128,7 @@ class FaultMiddlewareTest(common.HeatTestCase): expected = {'code': 404, 'error': {'message': expected_message, 'traceback': expected_traceback, - 'type': 'StackNotFound'}, + 'type': 'EntityNotFound'}, 'explanation': 'The resource could not be found.', 'title': 'Not Found'} self.assertEqual(expected, msg) @@ -194,7 +194,7 @@ class FaultMiddlewareTest(common.HeatTestCase): def test_should_not_ignore_parent_classes(self): wrapper = fault.FaultWrapper(None) - msg = wrapper._error(StackNotFoundChild(stack_name='a')) + msg = wrapper._error(StackNotFoundChild(entity='Stack', name='a')) expected = {'code': 404, 'error': {'message': 'The Stack (a) could not be found.', 'traceback': None, @@ -224,7 +224,7 @@ class FaultMiddlewareTest(common.HeatTestCase): # We want tracebacks cfg.CONF.set_override('debug', True) - error = StackNotFoundChild(stack_name='a') + error = StackNotFoundChild(entity='Stack', name='a') exc_info = (type(error), error, None) serialized = rpc_common.serialize_remote_exception(exc_info) remote_error = rpc_common.deserialize_remote_exception(