Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pankajastro committed Dec 2, 2024
1 parent 996927b commit 6d0466e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/fixtures/dag_md_docs.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions tests/test_dagfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6d0466e

Please sign in to comment.