Skip to content

Commit 515265a

Browse files
committed
test: Add unit testing support for dbt-core version 0.21.0
1 parent 203d38c commit 515265a

File tree

8 files changed

+321
-311
lines changed

8 files changed

+321
-311
lines changed

poetry.lock

Lines changed: 303 additions & 296 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ classifiers = [
1414
[tool.poetry.dependencies]
1515
python = "^3.7"
1616
apache-airflow = ">=1.10.12, < 3.0.0"
17-
dbt-core = ">=0.19, < 0.21"
17+
dbt-core = ">=0.19, < 0.22"
1818
# Flask is required by Airflow, but the dependency hasn't been updated to fix an issue
1919
# with Flask-OpenID is breaking our build.
2020
# See details: https://github.com/pallets-eco/flask-openid/pull/60
2121
Flask-OpenID = ">=1.3.0"
2222

2323
apache-airflow-providers-amazon = { version = "^2.1.0", optional = true }
24-
dbt-postgres = { version = ">=0.19, < 0.21", optional = true }
25-
dbt-redshift = { version = ">=0.19, < 0.21", optional = true }
26-
dbt-snowflake = { version = ">=0.19, < 0.21", optional = true }
27-
dbt-bigquery = { version = ">=0.19, < 0.21", optional = true }
24+
dbt-postgres = "0.21"
25+
dbt-redshift = { version = ">=0.19, < 0.22", optional = true }
26+
dbt-snowflake = { version = ">=0.19, < 0.22", optional = true }
27+
dbt-bigquery = { version = ">=0.19, < 0.22", optional = true }
2828

2929
# Documentation extras
3030
Sphinx = { version = "4.2.0", optional = true }
@@ -40,7 +40,6 @@ pytest = "^6.2.4"
4040
pre-commit = "^2.12.1"
4141
pytest-postgresql = "^3.1.1"
4242
psycopg2-binary = "^2.8.6"
43-
dbt-postgres = "^0.20"
4443
isort = "^5.9.2"
4544
moto = "^2.2.2"
4645

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pytest_postgresql.janitor import DatabaseJanitor
77

88
DBT_VERSION = parse(DBT_VERSION)
9-
IS_DBT_VERSION_0_20 = DBT_VERSION.minor == 20 and DBT_VERSION.major == 0
9+
IS_DBT_VERSION_LESS_THAN_0_20 = DBT_VERSION.minor < 20 and DBT_VERSION.major == 0
1010

1111
PROFILES = """
1212
default:
@@ -29,7 +29,7 @@
2929
version: 1.0.0
3030
"""
3131

32-
if IS_DBT_VERSION_0_20:
32+
if not IS_DBT_VERSION_LESS_THAN_0_20:
3333
PROJECT += """
3434
dispatch:
3535
- macro_namespace: dbt_utils

tests/test_dbt_compile.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
from airflow_dbt_python.operators.dbt import DbtCompileOperator
88

99
DBT_VERSION = parse(DBT_VERSION)
10-
IS_DBT_VERSION_0_20 = DBT_VERSION.minor == 20 and DBT_VERSION.major == 0
10+
IS_DBT_VERSION_LESS_THAN_0_20 = DBT_VERSION.minor < 20 and DBT_VERSION.major == 0
1111

1212

1313
def test_dbt_compile_mocked_all_args():
14+
"""Test mocked dbt compile call with all arguments."""
1415
op = DbtCompileOperator(
1516
task_id="dbt_task",
1617
project_dir="/path/to/project/",
@@ -111,7 +112,7 @@ def test_dbt_compile_non_existent_model(profiles_file, dbt_project_file, model_f
111112
NOW() AS field2
112113
"""
113114

114-
if IS_DBT_VERSION_0_20:
115+
if not IS_DBT_VERSION_LESS_THAN_0_20:
115116
cte = "cte"
116117
else:
117118
cte = "CTE"

tests/test_dbt_debug.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
from airflow_dbt_python.operators.dbt import DbtDebugOperator
77

88
DBT_VERSION = parse(DBT_VERSION)
9-
IS_DBT_VERSION_0_20 = DBT_VERSION.minor == 20 and DBT_VERSION.major == 0
9+
IS_DBT_VERSION_LESS_THAN_0_20 = DBT_VERSION.minor < 20 and DBT_VERSION.major == 0
1010

1111

1212
def test_dbt_debug_mocked_all_args():
13+
"""Test mocked dbt debug call with all arguments."""
1314
op = DbtDebugOperator(
1415
task_id="dbt_task",
1516
project_dir="/path/to/project/",
@@ -70,7 +71,7 @@ def test_dbt_debug_config_dir(profiles_file, dbt_project_file):
7071
)
7172
output = op.execute({})
7273

73-
if IS_DBT_VERSION_0_20:
74+
if not IS_DBT_VERSION_LESS_THAN_0_20:
7475
assert output is True
7576
else:
7677
assert output is None
@@ -85,7 +86,7 @@ def test_dbt_debug(profiles_file, dbt_project_file):
8586
)
8687
output = op.execute({})
8788

88-
if IS_DBT_VERSION_0_20:
89+
if not IS_DBT_VERSION_LESS_THAN_0_20:
8990
assert output is True
9091
else:
9192
assert output is None

tests/test_dbt_deps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def dbt_modules_dir(dbt_project_file):
6060

6161
PACKAGES = """
6262
packages:
63-
- package: fishtown-analytics/dbt_utils
64-
version: 0.7.0
63+
- package: dbt-labs/dbt_utils
64+
version: 0.7.3
6565
"""
6666

6767

tests/test_dbt_parse.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
def test_dbt_parse_mocked_all_args():
8+
"""Test mocked dbt parse call with all arguments."""
89
op = DbtParseOperator(
910
task_id="dbt_task",
1011
project_dir="/path/to/project/",

tests/test_dbt_run.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919

2020
def test_dbt_run_mocked_all_args():
21+
"""Test mocked dbt run call with all arguments."""
2122
op = DbtRunOperator(
2223
task_id="dbt_task",
2324
project_dir="/path/to/project/",

0 commit comments

Comments
 (0)