From 4b02f667538f69d4bd76153291cd0b3b86d09cc4 Mon Sep 17 00:00:00 2001 From: Ross Brattain Date: Sun, 16 Jul 2017 20:31:38 -0700 Subject: 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 --- tests/unit/orchestrator/test_heat.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests/unit') 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) -- cgit 1.2.3-korg