Skip to content

Commit

Permalink
skips airflow tests if not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolfix committed Dec 13, 2024
1 parent 7f137f1 commit 7c31993
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ lint-security:
poetry run bandit -r dlt/ -n 3 -l

test:
(set -a && . tests/.env && poetry run pytest tests)
poetry run pytest tests

test-load-local:
DESTINATION__POSTGRES__CREDENTIALS=postgresql://loader:loader@localhost:5432/dlt_data DESTINATION__DUCKDB__CREDENTIALS=duckdb:///_storage/test_quack.duckdb poetry run pytest tests -k '(postgres or duckdb)'
Expand Down
4 changes: 4 additions & 0 deletions tests/helpers/airflow_tests/test_airflow_provider.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import pytest

pytest.importorskip("apache-airflow")

from airflow import DAG
from airflow.decorators import task, dag
from airflow.operators.python import PythonOperator
Expand Down
2 changes: 2 additions & 0 deletions tests/helpers/airflow_tests/test_airflow_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import pytest
from unittest import mock
from typing import Iterator, List

pytest.importorskip("apache-airflow")
from airflow import DAG
from airflow.decorators import dag
from airflow.operators.python import PythonOperator, get_current_context
Expand Down
3 changes: 3 additions & 0 deletions tests/helpers/airflow_tests/test_join_airflow_scheduler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import pytest
import datetime
from pendulum.tz import UTC

pytest.importorskip("apache-airflow")
from airflow import DAG
from airflow.decorators import dag, task
from airflow.models import DagRun
Expand Down
8 changes: 5 additions & 3 deletions tests/helpers/airflow_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
import os
import argparse
import pytest
from airflow.cli.commands.db_command import resetdb
from airflow.configuration import conf
from airflow.models.variable import Variable

from dlt.common.configuration.container import Container
from dlt.common.configuration.specs import PluggableRunContext
Expand All @@ -19,6 +16,8 @@

@pytest.fixture(scope="function", autouse=True)
def initialize_airflow_db():
from airflow.models.variable import Variable

setup_airflow()
# backup context providers
providers = Container()[PluggableRunContext].providers
Expand All @@ -35,6 +34,9 @@ def initialize_airflow_db():


def setup_airflow() -> None:
from airflow.cli.commands.db_command import resetdb
from airflow.configuration import conf

# Disable loading examples
try:
conf.add_section("core")
Expand Down

0 comments on commit 7c31993

Please sign in to comment.