From 8fc4a9cbeec561b5dd4756d335423a721bbc5ef0 Mon Sep 17 00:00:00 2001 From: zhufl Date: Fri, 28 Jun 2019 17:20:07 +0800 Subject: [PATCH] Fix invalid assert states "self.assertTrue(action.state, objects.action.State.SUCCEEDED)" and "self.assertTrue(action.state, objects.action.State.FAILED)" should use assertEqual. Co-Authored-By: Canwei Li Change-Id: I8e28d651938ca6ed8d12e8a6f5ecf775cf01a39c --- .../test_taskflow_action_container.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/watcher/tests/applier/workflow_engine/test_taskflow_action_container.py b/watcher/tests/applier/workflow_engine/test_taskflow_action_container.py index 8ebaa08be..1862d64d3 100644 --- a/watcher/tests/applier/workflow_engine/test_taskflow_action_container.py +++ b/watcher/tests/applier/workflow_engine/test_taskflow_action_container.py @@ -43,7 +43,7 @@ class TestTaskFlowActionContainer(base.DbTestCase): action_plan = obj_utils.create_test_action_plan( self.context, audit_id=self.audit.id, strategy_id=self.strategy.id, - state=objects.action.State.ONGOING) + state=objects.action_plan.State.ONGOING) action = obj_utils.create_test_action( self.context, action_plan_id=action_plan.id, @@ -55,7 +55,9 @@ class TestTaskFlowActionContainer(base.DbTestCase): engine=self.engine) action_container.execute() - self.assertTrue(action.state, objects.action.State.SUCCEEDED) + obj_action = objects.Action.get_by_uuid( + self.engine.context, action.uuid) + self.assertEqual(obj_action.state, objects.action.State.SUCCEEDED) @mock.patch.object(clients.OpenStackClients, 'nova', mock.Mock()) def test_execute_with_failed(self): @@ -65,7 +67,7 @@ class TestTaskFlowActionContainer(base.DbTestCase): action_plan = obj_utils.create_test_action_plan( self.context, audit_id=self.audit.id, strategy_id=self.strategy.id, - state=objects.action.State.ONGOING) + state=objects.action_plan.State.ONGOING) action = obj_utils.create_test_action( self.context, action_plan_id=action_plan.id, @@ -83,7 +85,9 @@ class TestTaskFlowActionContainer(base.DbTestCase): result = action_container.execute() self.assertFalse(result) - self.assertTrue(action.state, objects.action.State.FAILED) + obj_action = objects.Action.get_by_uuid( + self.engine.context, action.uuid) + self.assertEqual(obj_action.state, objects.action.State.FAILED) @mock.patch('eventlet.spawn') def test_execute_with_cancel_action_plan(self, mock_eventlet_spawn):