aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-07-16 20:31:38 -0700
committerRoss Brattain <ross.b.brattain@intel.com>2017-07-17 03:35:51 +0000
commit4b02f667538f69d4bd76153291cd0b3b86d09cc4 (patch)
tree092909be8db11afdd8b5cb09e4326622291ecb6b /tests/unit
parentab820837ee980bbd356158ccfc343dee3053409a (diff)
test_delete_all_calls_delete: fix delete mock
we need to mock HeatStack.delete() before we instantiate otherwise we can't reach the instantiated objects delete() method we need to patch the class so we patch all instances Change-Id: I36f9476dcfb83e2d583c5a9f72dc27fce57258eb Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/orchestrator/test_heat.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/unit/orchestrator/test_heat.py b/tests/unit/orchestrator/test_heat.py
index 19d91c6e8..c127dd0c9 100644
--- a/tests/unit/orchestrator/test_heat.py
+++ b/tests/unit/orchestrator/test_heat.py
@@ -345,8 +345,10 @@ class HeatStackTestCase(unittest.TestCase):
@mock.patch('yardstick.orchestrator.heat.op_utils')
def test_delete_all_calls_delete(self, mock_op):
- stack = heat.HeatStack('test')
- stack.uuid = 1
- with mock.patch.object(stack, "delete") as delete_mock:
+ # we must patch the object before we create an instance
+ # so we can override delete() in all the instances
+ with mock.patch.object(heat.HeatStack, "delete") as delete_mock:
+ stack = heat.HeatStack('test')
+ stack.uuid = 1
stack.delete_all()
- self.assertGreater(delete_mock.call_count, 0)
+ self.assertGreater(delete_mock.call_count, 0)