def test_complete_an_action_instance_sets_dates_and_status(self): pipeline_instance = self._build_pipeline_instance(['1:1']) workflow_engine = InstanceWorkflowEngine(self._get_mocked_dal(), pipeline_instance) action_instance = workflow_engine.get_action_instance_by_id(1) workflow_engine.complete_an_action(action_instance.id, StatusConstants.CANCELED) self.assertEqual(StatusConstants.CANCELED, action_instance.status_id) self.assertEqual(StatusConstants.CANCELED, pipeline_instance.status_id) self.assertEqual(StatusConstants.CANCELED, pipeline_instance.stage_instances[0].status_id) self.assertEqual( StatusConstants.CANCELED, pipeline_instance.stage_instances[0]. workflow_instances[0].status_id)
def test_reset_action_instance(self): pipeline_instance = self._build_pipeline_instance(['1:1', '2:1-2,1'], True) workflow_engine = InstanceWorkflowEngine(self._get_mocked_dal(), pipeline_instance) action_instance = workflow_engine.get_action_instance_by_id(3) workflow_engine.reset_action(action_instance) self.assertEquals(None, pipeline_instance.end_date) self.assertEquals(None, pipeline_instance.stage_instances[1].end_date) self.assertEquals( None, pipeline_instance.stage_instances[1].workflow_instances[1]. end_date) self.assertEquals(None, action_instance.end_date) self.assertEquals(StatusConstants.READY, action_instance.status_id)
def test_complete_an_action_instance_starts_next(self): pipeline_instance = self._build_pipeline_instance(['1:2']) pipeline_instance.status_id = StatusConstants.INPROGRESS workflow_engine = InstanceWorkflowEngine(self._get_mocked_dal(), pipeline_instance) action_instance = workflow_engine.get_action_instance_by_id(2) workflow_engine.complete_an_action(1, StatusConstants.SUCCESS) self._print_pipeline_instance(pipeline_instance) self.assertEqual(StatusConstants.READY, action_instance.status_id) self.assertEqual(StatusConstants.INPROGRESS, pipeline_instance.status_id) self.assertEqual( StatusConstants.SUCCESS, pipeline_instance.stage_instances[0]. workflow_instances[0].action_instances[0].status_id) self.assertEqual( StatusConstants.READY, pipeline_instance.stage_instances[0]. workflow_instances[0].action_instances[1].status_id)