From c80028920581189a8e997c9e8b599020f9ca6646 Mon Sep 17 00:00:00 2001 From: Chad Nelson Date: Fri, 25 Aug 2023 14:10:49 -0700 Subject: [PATCH] chore: Fix dags tests to work with explicit import paths --- .github/workflows/dags_test.yml | 6 +++--- dags/requirements.txt | 1 + dags/tests.py => dags_tests.py | 6 +++++- 3 files changed, 9 insertions(+), 4 deletions(-) rename dags/tests.py => dags_tests.py (82%) diff --git a/.github/workflows/dags_test.yml b/.github/workflows/dags_test.yml index 18c97c31a..24ec841b2 100644 --- a/.github/workflows/dags_test.yml +++ b/.github/workflows/dags_test.yml @@ -18,6 +18,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r dags/requirements.txt + pip install apache-airflow boto3 pip check - name: Lint dags with ruff run: | @@ -25,6 +26,5 @@ jobs: ruff check --format=github ./dags - name: Test with Pytest run: | - pip install pytest apache-airflow - cd dags || exit - pytest tests.py -v + pip install pytest + pytest dags_tests.py -v diff --git a/dags/requirements.txt b/dags/requirements.txt index fdb13d566..479feaf1b 100644 --- a/dags/requirements.txt +++ b/dags/requirements.txt @@ -1,3 +1,4 @@ +--constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.5.1/constraints-3.10.txt" requests sickle python-dotenv \ No newline at end of file diff --git a/dags/tests.py b/dags_tests.py similarity index 82% rename from dags/tests.py rename to dags_tests.py index 92140d60c..162f96535 100644 --- a/dags/tests.py +++ b/dags_tests.py @@ -1,9 +1,12 @@ +import sys + from unittest import TestCase from airflow.models import DagBag +sys.path.append('.') -DAGS_FOLDER = "." +DAGS_FOLDER = "./dags/" class HarvestDagsTest(TestCase): @@ -12,3 +15,4 @@ def dag_bag(self): def test_no_import_errors(self): assert not self.dag_bag().import_errors +