Exemplo n.º 1
0
def test_task_command(args, tmp_nbs, monkeypatch):
    args = ['task', '--entry-point', 'pipeline.yaml', 'load'] + args
    monkeypatch.setattr(sys, 'argv', args)

    mock = Mock()
    monkeypatch.setattr(task.telemetry, "log_api", mock)
    task.main(catch_exception=False)

    assert mock.call_count == 1
Exemplo n.º 2
0
def test_task_command_does_not_force_dag_render(tmp_nbs, monkeypatch_session):
    """
    Make sure the force flag is only used in task.render and not dag.render
    because we don't want to override the status of other tasks
    """
    args = ['task', 'load', '--force']
    monkeypatch_session.setattr(sys, 'argv', args)

    class CustomParserWrapper(CustomParser):
        def load_from_entry_point_arg(self):
            dag, args = super().load_from_entry_point_arg()
            dag_mock = MagicMock(wraps=dag)
            type(self).dag_mock = dag_mock
            return dag_mock, args

    monkeypatch_session.setattr(task, 'CustomParser', CustomParserWrapper)

    task.main(catch_exception=False)

    CustomParserWrapper.dag_mock.render.assert_called_once_with()
Exemplo n.º 3
0
def test_task_command_does_not_force_dag_render(tmp_nbs, monkeypatch):
    """
    Make sure the force flag is only used in task.render and not dag.render
    because we don't want to override the status of other tasks
    """
    args = ['task', 'load', '--force']
    monkeypatch.setattr(sys, 'argv', args)

    class CustomCommandWrapper:
        def __call__(self, parser):
            dag, args = _custom_command(parser)
            self.dag_mock = MagicMock(wraps=dag)
            return self.dag_mock, args

    wrapper = CustomCommandWrapper()

    monkeypatch.setattr(task, '_custom_command', wrapper)

    task.main(catch_exception=False)

    wrapper.dag_mock.render.assert_called_once_with()
Exemplo n.º 4
0
def test_task_command(args, tmp_nbs, monkeypatch):
    args = ['task', '--entry-point', 'pipeline.yaml', 'load'] + args
    monkeypatch.setattr(sys, 'argv', args)
    task.main(catch_exception=False)