Esempio n. 1
0
    def test_success(self):
        taskflow = TaskFlowInstance()
        taskflow.pk = 1
        old_pipeline = PipelineInstance()
        taskflow.pipeline_instance = old_pipeline
        taskflow.pipeline_instance.clone = MagicMock(
            return_value=PipelineInstance())
        username = "******"

        with patch(TASKINSTANCE_SAVE, MagicMock()):
            task = taskflow.clone(username)

            self.assertIsNone(task.id)
            self.assertFalse(task.is_deleted)
            taskflow.save.assert_called_once()
            old_pipeline.clone.assert_called_once_with(username)
Esempio n. 2
0
    def test_success(self):
        taskflow = TaskFlowInstance()
        taskflow.id = 1
        taskflow.engine_ver = 2
        taskflow.has_node = MagicMock(return_value=True)
        taskflow.project_id = 3
        taskflow.pipeline_instance = PipelineInstance()
        dispatcher = MagicMock()
        get_node_data_return = {"code": 0, "data": {"data": "data"}, "message": "", "result": True}
        dispatcher.get_node_data = MagicMock(return_value=get_node_data_return)
        dispatcher_init = MagicMock(return_value=dispatcher)

        node_id = "node_id"
        username = "******"
        component_code = "component_code"
        subprocess_stack = ["1"]
        loop = 1

        with patch(TASKFLOW_MODEL_NODE_CMD_DISPATCHER, dispatcher_init):
            data = taskflow.get_node_data(
                node_id=node_id,
                username=username,
                component_code=component_code,
                subprocess_stack=subprocess_stack,
                loop=loop,
            )

        dispatcher_init.assert_called_once_with(engine_ver=taskflow.engine_ver, node_id=node_id, taskflow_id=1)
        dispatcher.get_node_data.assert_called_once_with(
            username=username,
            component_code=component_code,
            loop=loop,
            pipeline_instance=taskflow.pipeline_instance,
            subprocess_stack=subprocess_stack,
            project_id=taskflow.project_id,
        )
        self.assertEqual(data, get_node_data_return)