From: Zane Bitter Date: Fri, 2 Aug 2013 16:58:00 +0000 (+0200) Subject: Unit tests: Don't raise ResourceFailure directly X-Git-Tag: 2014.1~280^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=1aabe666f55501e8867d4aaf4118d151e57c1658;p=openstack-build%2Fheat-build.git Unit tests: Don't raise ResourceFailure directly It's meant to be a wrapper around other exceptions that's invoked by top-level resource operations; don't use it as an all-purpose exception. Change-Id: I1e0376a4a00fc3f1114b9bc76bbb1d5d0d98b166 --- diff --git a/heat/tests/test_autoscaling.py b/heat/tests/test_autoscaling.py index 73caffa9..b0ff2d0f 100644 --- a/heat/tests/test_autoscaling.py +++ b/heat/tests/test_autoscaling.py @@ -441,8 +441,7 @@ class AutoScalingTest(HeatTestCase): self.m.StubOutWithMock(instance.Instance, 'handle_create') self.m.StubOutWithMock(instance.Instance, 'check_create_complete') - exc = exception.ResourceFailure(Exception()) - instance.Instance.handle_create().AndRaise(exc) + instance.Instance.handle_create().AndRaise(Exception) self.m.ReplayAll() rsrc = asc.AutoScalingGroup('WebServerGroup', @@ -690,8 +689,7 @@ class AutoScalingTest(HeatTestCase): # Scale up one 1 instance with resource failure self.m.StubOutWithMock(instance.Instance, 'handle_create') - exc = exception.ResourceFailure(Exception()) - instance.Instance.handle_create().AndRaise(exc) + instance.Instance.handle_create().AndRaise(Exception) self.m.StubOutWithMock(instance.Instance, 'destroy') instance.Instance.destroy() self._stub_lb_reload(1, unset=False, nochange=True) diff --git a/heat/tests/test_parser.py b/heat/tests/test_parser.py index 3c0e9acd..4a903942 100644 --- a/heat/tests/test_parser.py +++ b/heat/tests/test_parser.py @@ -715,7 +715,7 @@ class StackTest(HeatTestCase): def test_suspend_fail(self): tmpl = {'Resources': {'AResource': {'Type': 'GenericResourceType'}}} self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_suspend') - exc = exception.ResourceFailure(Exception('foo')) + exc = Exception('foo') generic_rsrc.GenericResource.handle_suspend().AndRaise(exc) self.m.ReplayAll() @@ -739,8 +739,7 @@ class StackTest(HeatTestCase): def test_resume_fail(self): tmpl = {'Resources': {'AResource': {'Type': 'GenericResourceType'}}} self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_resume') - exc = exception.ResourceFailure(Exception('foo')) - generic_rsrc.GenericResource.handle_resume().AndRaise(exc) + generic_rsrc.GenericResource.handle_resume().AndRaise(Exception('foo')) self.m.ReplayAll() self.stack = parser.Stack(self.ctx, 'resume_test_fail', @@ -1038,9 +1037,8 @@ class StackTest(HeatTestCase): # key/property in update_allowed_keys/update_allowed_properties # make the update fail deleting the existing resource - self.m.StubOutWithMock(resource.Resource, 'destroy') - exc = exception.ResourceFailure(Exception()) - resource.Resource.destroy().AndRaise(exc) + self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_delete') + generic_rsrc.GenericResource.handle_delete().AndRaise(Exception) self.m.ReplayAll() self.stack.update(updated_stack) @@ -1238,9 +1236,8 @@ class StackTest(HeatTestCase): template.Template(tmpl2)) # patch in a dummy delete making the destroy fail - self.m.StubOutWithMock(resource.Resource, 'delete') - exc = exception.ResourceFailure(Exception()) - resource.Resource.delete().AndRaise(exc) + self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_delete') + generic_rsrc.GenericResource.handle_delete().AndRaise(Exception) self.m.ReplayAll() self.stack.update(updated_stack)