Update affected tests - live action and action execution timestamp may
now be a bit different, depending on how long it takes to persist each
corresponding object in the database.
Also fix tests to utilize correct dict type for the result.
@@ -54,7 +54,8 @@ MOCK_FAIL_EXECUTION_CREATE = False
@mock.patch.object(
LocalShellCommandRunner, 'run',
- mock.MagicMock(return_value=(action_constants.LIVEACTION_STATUS_FAILED, 'Non-empty', None)))
+ mock.MagicMock(return_value=(action_constants.LIVEACTION_STATUS_FAILED,
+ {'data': 'Non-empty'}, None)))
@mock.patch.object(
CUDPublisher, 'publish_create',
mock.MagicMock(side_effect=MockLiveActionPublisher.publish_create))
@@ -97,7 +98,10 @@ class TestActionExecutionHistoryWorker(ExecutionDbTestCase):
self.assertDictEqual(execution.runner, vars(RunnerTypeAPI.from_model(runner)))
liveaction = LiveAction.get_by_id(str(liveaction.id))
self.assertEqual(execution.start_timestamp, liveaction.start_timestamp)
- self.assertEqual(execution.end_timestamp, liveaction.end_timestamp)
+ # NOTE: Timestamp of liveaction and execution may be a bit different, depending on how long
+ # it takes to persist each object in the database
+ self.assertEqual(execution.end_timestamp.replace(microsecond=0),
+ liveaction.end_timestamp.replace(microsecond=0))
self.assertEqual(execution.result, liveaction.result)
self.assertEqual(execution.status, liveaction.status)
self.assertEqual(execution.context, liveaction.context)
@@ -124,7 +128,10 @@ class TestActionExecutionHistoryWorker(ExecutionDbTestCase):
self.assertDictEqual(execution.runner, vars(RunnerTypeAPI.from_model(runner)))
liveaction = LiveAction.get_by_id(str(liveaction.id))
self.assertEqual(execution.start_timestamp, liveaction.start_timestamp)
- self.assertEqual(execution.end_timestamp, liveaction.end_timestamp)
+ # NOTE: Timestamp of liveaction and execution may be a bit different, depending on how long
+ # it takes to persist each object in the database
+ self.assertEqual(execution.end_timestamp.replace(microsecond=0),
+ liveaction.end_timestamp.replace(microsecond=0))
self.assertEqual(execution.result, liveaction.result)
self.assertEqual(execution.status, liveaction.status)
self.assertEqual(execution.context, liveaction.context)
@@ -181,7 +188,10 @@ class TestActionExecutionHistoryWorker(ExecutionDbTestCase):
self.assertDictEqual(execution.runner, vars(RunnerTypeAPI.from_model(runner)))
liveaction = LiveAction.get_by_id(str(liveaction.id))
self.assertEqual(execution.start_timestamp, liveaction.start_timestamp)
- self.assertEqual(execution.end_timestamp, liveaction.end_timestamp)
+ # NOTE: Timestamp of liveaction and execution may be a bit different, depending on how long
+ # it takes to persist each object in the database
+ self.assertEqual(execution.end_timestamp.replace(microsecond=0),
+ liveaction.end_timestamp.replace(microsecond=0))
self.assertEqual(execution.result, liveaction.result)
self.assertEqual(execution.status, liveaction.status)
self.assertEqual(execution.context, liveaction.context)
