def dag(good_dag_path):
    path = good_dag_path("template-with-dicts")
    dags = airflow_declarative.from_path(path)

    assert len(dags) == 1

    dag = dags[0]

    return dag
def dag(good_dag_path):
    path = good_dag_path('callback-tasks')
    dags = airflow_declarative.from_path(path)

    assert len(dags) == 1

    dag = dags[0]

    return dag
Exemplo n.º 3
0
def dag(good_dag_path):
    path = good_dag_path("example_without_scheduling")
    dags = airflow_declarative.from_path(path)

    assert len(dags) == 1

    dag = dags[0]

    return dag
def dag(good_dag_path):
    path = good_dag_path('template-defaults')
    dags = airflow_declarative.from_path(path)

    assert len(dags) == 1

    dag = dags[0]

    return dag
def test_integer_callback_arg(good_dag_path):
    path = good_dag_path("integer_callback_arg")
    dags = airflow_declarative.from_path(path)

    assert len(dags) == 1

    yml_dag = dags[0]

    assert isinstance(yml_dag, DAG)

    myoperator = yml_dag.task_dict["myoperator"]
    param = myoperator._callback_args["param"]
    assert isinstance(param, int)
def test_example_bash_operator(good_dag_path):
    path = good_dag_path("example_bash_operator")
    dags = airflow_declarative.from_path(path)

    assert len(dags) == 1

    yml_dag = dags[0]

    assert isinstance(yml_dag, DAG)

    assert yml_dag.dagrun_timeout == datetime.timedelta(minutes=60)

    assert yml_dag.default_args["owner"] == "airflow"

    assert yml_dag.start_date == datetime.datetime(2017, 7, 27, 0, 0, 0)
    assert yml_dag.end_date == datetime.datetime(2018, 6, 27, 12, 0, 0)

    assert yml_dag.schedule_interval == datetime.timedelta(days=1)

    expected_tasks = {
        "runme_0",
        "runme_1",
        "runme_2",
        "also_run_this",
        "run_after_loop",
        "run_this_last",
    }
    assert set(yml_dag.task_ids) == expected_tasks

    run_after_loop = yml_dag.task_dict["run_after_loop"]
    assert isinstance(run_after_loop, BaseOperator)
    assert run_after_loop.bash_command == "echo 1"
    expected_upstreams = {"runme_0", "runme_1", "runme_2"}
    assert set(run_after_loop.upstream_task_ids) == expected_upstreams

    run_this_last = yml_dag.task_dict["run_this_last"]
    expected_upstreams = {"also_run_this", "run_after_loop"}
    assert set(run_this_last.upstream_task_ids) == expected_upstreams

    also_run_this = yml_dag.task_dict["also_run_this"]
    assert isinstance(run_after_loop, BaseOperator)
    expected_command = 'echo "run_id={{ run_id }} | dag_run={{ dag_run }}"'
    assert also_run_this.bash_command == expected_command
Exemplo n.º 7
0
def test_example_bash_operator(good_dag_path):
    path = good_dag_path('example_bash_operator')
    dags = airflow_declarative.from_path(path)

    assert len(dags) == 1

    yml_dag = dags[0]

    assert isinstance(yml_dag, DAG)

    assert yml_dag.dagrun_timeout == datetime.timedelta(minutes=60)

    assert yml_dag.default_args['owner'] == 'airflow'

    assert yml_dag.start_date == datetime.date(2017, 7, 27)

    assert yml_dag.schedule_interval == datetime.timedelta(days=1)

    expected_tasks = {
        'runme_0', 'runme_1', 'runme_2', 'also_run_this', 'run_after_loop',
        'run_this_last'
    }
    assert set(yml_dag.task_ids) == expected_tasks

    run_after_loop = yml_dag.task_dict['run_after_loop']
    assert isinstance(run_after_loop, BaseOperator)
    assert run_after_loop.bash_command == 'echo 1'
    expected_upstreams = {'runme_0', 'runme_1', 'runme_2'}
    assert set(run_after_loop.upstream_task_ids) == expected_upstreams

    run_this_last = yml_dag.task_dict['run_this_last']
    expected_upstreams = {'also_run_this', 'run_after_loop'}
    assert set(run_this_last.upstream_task_ids) == expected_upstreams

    also_run_this = yml_dag.task_dict['also_run_this']
    assert isinstance(run_after_loop, BaseOperator)
    expected_command = 'echo "run_id={{ run_id }} | dag_run={{ dag_run }}"'
    assert also_run_this.bash_command == expected_command
Exemplo n.º 8
0
def test_bad_dags(path, expected_exception):
    with pytest.raises(expected_exception):
        airflow_declarative.from_path(path)
def test_good_dags(path):
    dags = airflow_declarative.from_path(path)
    assert isinstance(dags, list)
    assert all(isinstance(dag, airflow.DAG) for dag in dags)