]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Unit tests: Don't raise ResourceFailure directly
authorZane Bitter <zbitter@redhat.com>
Fri, 2 Aug 2013 16:58:00 +0000 (18:58 +0200)
committerZane Bitter <zbitter@redhat.com>
Fri, 2 Aug 2013 16:58:00 +0000 (18:58 +0200)
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

heat/tests/test_autoscaling.py
heat/tests/test_parser.py

index 73caffa93916bdddb3177f1f91e89b30f3935a83..b0ff2d0f2e698eaddbd2620f374fda8d32039eff 100644 (file)
@@ -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)
index 3c0e9acdb07571e7b0148267ce22d4a6a68abd1e..4a903942c42d00b8b635300703c3e2b999cc4dae 100644 (file)
@@ -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)