From e639b1ac03fac43caec9842b21260c6949abe5a9 Mon Sep 17 00:00:00 2001 From: Tatiana Al-Chueyr Date: Thu, 17 Oct 2024 11:41:54 +0100 Subject: [PATCH] Fix Pytest fixture that changed DAG YAML file (#256) A Pytest fixture modified a DAG YAML file, which is not in .gitignore. The consequence is that if there were errors, the fixture was changed and developers would potentially commit an invalid fixture - that would be invalid in the CI. This PR leverages the previous change introduced in #236 to use envvars for templating YML filepaths.. --- tests/fixtures/dag_factory.yml | 4 ++-- tests/test_dagfactory.py | 12 ------------ 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/tests/fixtures/dag_factory.yml b/tests/fixtures/dag_factory.yml index a27a9f09..1662e21c 100644 --- a/tests/fixtures/dag_factory.yml +++ b/tests/fixtures/dag_factory.yml @@ -33,7 +33,7 @@ example_dag: - task_1 operator: airflow.operators.bash_operator.BashOperator example_dag2: - doc_md_file_path: {here}/fixtures/mydocfile.md + doc_md_file_path: $PWD/tests/fixtures/mydocfile.md schedule_interval: None tasks: task_1: @@ -53,7 +53,7 @@ example_dag3: doc_md_python_arguments: arg1: arg1 arg2: arg2 - doc_md_python_callable_file: {here}/fixtures/doc_md_builder.py + doc_md_python_callable_file: $PWD/tests/fixtures/doc_md_builder.py doc_md_python_callable_name: mydocmdbuilder tasks: task_1: diff --git a/tests/test_dagfactory.py b/tests/test_dagfactory.py index c195fa00..6c44f6c4 100644 --- a/tests/test_dagfactory.py +++ b/tests/test_dagfactory.py @@ -91,18 +91,6 @@ } -@pytest.fixture(autouse=True) -def build_path_for_doc_md(): - with open(TEST_DAG_FACTORY, "r") as f: - oldText = f.read() - newText = oldText.replace("{here}", here) - with open(TEST_DAG_FACTORY, "w") as f: - f.write(newText) - yield - with open(TEST_DAG_FACTORY, "w") as f: - f.write(oldText) - - def test_validate_config_filepath_valid(): dagfactory.DagFactory._validate_config_filepath(TEST_DAG_FACTORY)