From 6d0466e6bb5611ed86df598d05b80dc1c2cd9301 Mon Sep 17 00:00:00 2001 From: pankajastro Date: Mon, 2 Dec 2024 23:38:32 +0530 Subject: [PATCH] Add tests --- tests/fixtures/dag_md_docs.yml | 30 ++++++++++++++++++++++++++++++ tests/test_dagfactory.py | 10 ++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/fixtures/dag_md_docs.yml diff --git a/tests/fixtures/dag_md_docs.yml b/tests/fixtures/dag_md_docs.yml new file mode 100644 index 00000000..7842eec8 --- /dev/null +++ b/tests/fixtures/dag_md_docs.yml @@ -0,0 +1,30 @@ +default: + concurrency: 1 + dagrun_timeout_sec: 600 + default_args: + end_date: 2018-03-05 + owner: default_owner + retries: 1 + retry_delay_sec: 300 + start_date: 2018-03-01 + default_view: tree + max_active_runs: 1 + orientation: LR + schedule_interval: 0 1 * * * + +example_dag2: + schedule_interval: None + tasks: + task_1: + bash_command: echo 1 + operator: airflow.operators.bash_operator.BashOperator + task_2: + bash_command: echo 2 + dependencies: + - task_1 + operator: airflow.operators.bash_operator.BashOperator + task_3: + bash_command: echo 3 + dependencies: + - task_1 + operator: airflow.operators.bash_operator.BashOperator diff --git a/tests/test_dagfactory.py b/tests/test_dagfactory.py index 14e8f7cb..a664addb 100644 --- a/tests/test_dagfactory.py +++ b/tests/test_dagfactory.py @@ -443,3 +443,13 @@ def test_load_yaml_dags_default_suffix_succeed(caplog): dags_folder="tests/fixtures", ) assert "Loading DAGs from tests/fixtures" in caplog.messages + + +def test_yml_dag_rendering_in_docs(): + dag_path = os.path.join(here, "fixtures/dag_md_docs.yml") + td = dagfactory.DagFactory(dag_path) + td.generate_dags(globals()) + generated_doc_md = globals()["example_dag2"].doc_md + with open(dag_path, "r") as file: + expected_doc_md = "## YML DAG\n```yaml\n" + file.read() + "\n```" + assert generated_doc_md == expected_doc_md