Exemple #1
0
    def test_success(self):
        taskflow = TaskFlowInstance()
        taskflow.id = 1
        taskflow.engine_ver = 2
        taskflow.has_node = MagicMock(return_value=True)
        dispatcher = MagicMock()
        dispatch_return = {"result": True, "data": {"data": "data"}}
        dispatcher.dispatch = MagicMock(return_value=dispatch_return)
        dispatcher_init = MagicMock(return_value=dispatcher)

        node_id = "node_id"
        username = "******"
        inputs = "inputs"

        with patch(TASKFLOW_MODEL_NODE_CMD_DISPATCHER, dispatcher_init):
            detail = taskflow.spec_nodes_timer_reset(node_id=node_id,
                                                     username=username,
                                                     inputs=inputs)

        dispatcher_init.assert_called_once_with(engine_ver=taskflow.engine_ver,
                                                node_id=node_id,
                                                taskflow_id=1)
        dispatcher.dispatch.assert_has_calls([
            call(command="forced_fail", operator=username),
            call(command="retry", operator=username, inputs="inputs")
        ])
        self.assertEqual(detail, dispatch_return)
Exemple #2
0
    def test_node_does_not_exist(self):
        taskflow = TaskFlowInstance()
        taskflow.id = 1
        taskflow.has_node = MagicMock(return_value=False)

        detail = taskflow.spec_nodes_timer_reset(node_id="node_id",
                                                 username="******",
                                                 inputs="inputs")
        self.assertFalse(detail["result"])
        self.assertEqual(detail["code"], err_code.REQUEST_PARAM_INVALID.code)