Пример #1
0
    def test_node_does_not_exist(self):
        taskflow = TaskFlowInstance()
        taskflow.id = 1
        taskflow.has_node = MagicMock(return_value=False)

        data = taskflow.get_node_data(node_id="node_id", username="******")
        self.assertFalse(data["result"])
        self.assertEqual(data["code"], err_code.REQUEST_PARAM_INVALID.code)
Пример #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)