Exemplo n.º 1
0
    def test_return_value(self, test_name):
        canvas = return_value_task.s(test_name)

        workflow = Workflow()
        workflow.add_celery_canvas(canvas)
        workflow.apply_async().wait()

        task_id = list(workflow.nodes.keys())[0]
        logs_result = read_logs.delay()
        results = self.parse_logs(logs_result.get())[test_name]

        assert task_id == results[0]
Exemplo n.º 2
0
    def test_schedule_node_exec_uses_task_options(self):
        wf = Workflow()
        task_cls = mock.Mock()
        signature = mock.Mock()
        node = mock.Mock()
        node.id = 'task_node'
        task_cls.subtask.return_value = signature
        signature.id = 'dummy'
        Workflow.set_workflow_processor_task(task_cls)

        options = {'option': True}
        wf.apply_async(options=options)
        wf.schedule_node_exec(node)

        signature.apply_async.assert_called_with()
        node.signature.apply_async.assert_called_with(**options)
Exemplo n.º 3
0
    def get_canvas_order(self, canvas):
        workflow = Workflow()
        workflow.add_celery_canvas(canvas)
        result = workflow.apply_async()
        result.wait()

        logs_result = read_logs.delay()
        return self.parse_logs(logs_result.get())
Exemplo n.º 4
0
    def test_apply_async(self):
        wf = Workflow()
        task_cls = mock.Mock()
        signature = mock.Mock()
        task_cls.subtask.return_value = signature
        signature.id = 'dummy'
        Workflow.set_workflow_processor_task(task_cls)

        wf.apply_async()
        assert wf.id == 'dummy'

        # trickery, task_cls.subtask was called before ID was assigned
        # to workflow, while now wf.to_dict has id field set
        # just set it back to None
        wf.id = None
        task_cls.subtask.assert_called_with(kwargs=dict(
            workflow_dict=wf.to_dict()))
        signature.apply_async.assert_called()