Ejemplo n.º 1
0
    def test_complex_reset_action_complete_stage_should_activate_proper_actions(
            self):
        pipeline_instance = self._build_pipeline_instance(
            ['1:1', '7:1-1-1-1,1,4,1-1-1-1'])

        workflow_engine = InstanceWorkflowEngine(self._get_mocked_dal(),
                                                 pipeline_instance)
        workflow_engine.reset_pipeline()
        first_stage = pipeline_instance.stage_instances[0]
        second_stage = pipeline_instance.stage_instances[1]
        workflow_engine.complete_an_action(1, StatusConstants.SUCCESS)

        self.assertEquals(StatusConstants.SUCCESS, first_stage.status_id)
        self.assertEquals(StatusConstants.SUCCESS,
                          first_stage.workflow_instances[0].status_id)
        self.assertEquals(
            StatusConstants.SUCCESS,
            first_stage.workflow_instances[0].action_instances[0].status_id)

        self.assertEquals(StatusConstants.INPROGRESS, second_stage.status_id)
        for workflow_instance in second_stage.workflow_instances:
            self.assertEquals(StatusConstants.INPROGRESS,
                              workflow_instance.status_id)
            for action_instance in workflow_instance.action_instances:
                if action_instance.order == 0:
                    self.assertEquals(StatusConstants.READY,
                                      action_instance.status_id)
                else:
                    self.assertEquals(StatusConstants.NEW,
                                      action_instance.status_id)
Ejemplo n.º 2
0
    def test_reset_pipeline_instance_status_set_to_inprogress(self):
        pipeline_instance = self._build_pipeline_instance(
            ['1:1', '7:1-1-1-1,1,4,1-1-1-1'])

        workflow_engine = InstanceWorkflowEngine(self._get_mocked_dal(),
                                                 pipeline_instance)
        workflow_engine.reset_pipeline()
        self.assertEqual(StatusConstants.INPROGRESS,
                         pipeline_instance.status_id)
Ejemplo n.º 3
0
    def test_reset_pipeline_instance_sets_appropriate_dates(self):
        pipeline_instance = self._build_pipeline_instance(['1:1', '1:1'])
        pipeline_instance.end_date = datetime.datetime.utcnow()

        workflow_engine = InstanceWorkflowEngine(self._get_mocked_dal(),
                                                 pipeline_instance)
        workflow_engine.reset_pipeline()
        self.assertTrue(pipeline_instance.start_date is not None,
                        "Start date was not set.")
        self.assertTrue(pipeline_instance.end_date is None,
                        'End date was not reset.')
Ejemplo n.º 4
0
    def reset_pipeline_instance(self, pipeline_instance_id):
        for session in get_db_session():
            pipeline_instance = session.query(PipelineInstance)\
                                              .options(
                                                  joinedload(PipelineInstance.stage_instances)
                                                  .joinedload(StageInstance.workflow_instances)
                                                  .joinedload(WorkflowInstance.action_instances)).filter(PipelineInstance.id == pipeline_instance_id).first()

            instance_workflow_engine = InstanceWorkflowEngine(
                self.status_dal, pipeline_instance)
            instance_workflow_engine.reset_pipeline()
            session.commit()
        return True
Ejemplo n.º 5
0
    def test_reset_pipeline_instance_first_action_instance_and_orders_are_set_to_inprogress(
            self):
        pipeline_instance = self._build_pipeline_instance(['2:1-2,1'])

        workflow_engine = InstanceWorkflowEngine(self._get_mocked_dal(),
                                                 pipeline_instance)
        workflow_engine.reset_pipeline()
        self.assertEqual(
            StatusConstants.READY, pipeline_instance.stage_instances[0].
            workflow_instances[0].action_instances[0].status_id)
        self.assertEqual(
            StatusConstants.READY, pipeline_instance.stage_instances[0].
            workflow_instances[1].action_instances[0].status_id)
        self.assertEqual(
            StatusConstants.READY, pipeline_instance.stage_instances[0].
            workflow_instances[1].action_instances[1].status_id)
        self.assertEqual(
            StatusConstants.NEW, pipeline_instance.stage_instances[0].
            workflow_instances[1].action_instances[2].status_id)
Ejemplo n.º 6
0
    def test_complex_reset_action_instance_first_stage_should_be_ready(self):
        pipeline_instance = self._build_pipeline_instance(
            ['1:1', '7:1-1-1-1,1,4,1-1-1-1'], True)

        workflow_engine = InstanceWorkflowEngine(self._get_mocked_dal(),
                                                 pipeline_instance)
        workflow_engine.reset_pipeline()
        first_stage = pipeline_instance.stage_instances[0]
        second_stage = pipeline_instance.stage_instances[1]

        self.assertEquals(StatusConstants.READY, first_stage.status_id)
        self.assertEquals(StatusConstants.INPROGRESS,
                          first_stage.workflow_instances[0].status_id)
        self.assertEquals(
            StatusConstants.READY,
            first_stage.workflow_instances[0].action_instances[0].status_id)

        self.assertEquals(StatusConstants.NEW, second_stage.status_id)
        for workflow_instance in second_stage.workflow_instances:
            self.assertEquals(StatusConstants.NEW, workflow_instance.status_id)
            for action_instance in workflow_instance.action_instances:
                self.assertEquals(StatusConstants.NEW,
                                  action_instance.status_id)