Skip to content

Commit d825660

Browse files
committed
fix: Correct argument names and simplify tests
1 parent edbe832 commit d825660

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

airflow_dbt_python/hooks/s3.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Provides an S3 hook exclusively for fetching dbt files."""
2+
from __future__ import annotations
23

34
from pathlib import Path
45
from typing import Optional

airflow_dbt_python/operators/dbt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def __init__(
115115
self.use_colors = use_colors
116116
self.no_use_colors = no_use_colors
117117
self.no_version_check = no_version_check
118-
self.defer = defer
118+
self.dbt_defer = defer
119119
self.no_defer = no_defer
120120
self.single_threaded = single_threaded
121121
self.record_timing_info = record_timing_info

tests/hooks/s3/test_dbt_s3_hook.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Unit test module for DbtS3Hook."""
22
import io
3-
import os
3+
from pathlib import Path
44
from zipfile import ZipFile
55

66
import pytest
@@ -167,25 +167,34 @@ def test_get_dbt_project_no_trailing_slash(s3_bucket, tmpdir, dbt_project_file):
167167
assert result == "col1,col2\n1,2"
168168

169169

170-
def test_get_dbt_project_from_zip_file(s3_bucket, tmpdir, dbt_project_file):
171-
"""Test pulling dbt project from ZipFile in S3 path."""
172-
with open(dbt_project_file) as pf:
173-
project_content = pf.read()
174-
175-
with open("data/a_seed.csv", "w+") as f:
170+
@pytest.fixture
171+
def test_files():
172+
f1 = Path("data/a_seed.csv")
173+
with open(f1, "w+") as f:
176174
f.write("col1,col2\n1,2")
177175

178-
with open("models/a_model.sql", "w+") as f:
176+
f2 = Path("models/a_model.sql")
177+
with open(f2, "w+") as f:
179178
f.write("SELECT 1")
180-
with open("models/another_model.sql", "w+") as f:
179+
f3 = Path("models/another_model.sql")
180+
with open(f3, "w+") as f:
181181
f.write("SELECT 2")
182+
yield [f1, f2, f3]
183+
f1.unlink()
184+
f2.unlink()
185+
f3.unlink()
186+
187+
188+
def test_get_dbt_project_from_zip_file(s3_bucket, tmpdir, dbt_project_file, test_files):
189+
"""Test pulling dbt project from ZipFile in S3 path."""
190+
with open(dbt_project_file) as pf:
191+
project_content = pf.read()
182192

183193
zip_buffer = io.BytesIO()
184194
with ZipFile(zip_buffer, "a") as zf:
185195
zf.write(dbt_project_file, "dbt_project.yml")
186-
zf.write("data/a_seed.csv")
187-
zf.write("models/a_model.sql")
188-
zf.write("models/another_model.sql")
196+
for f in test_files:
197+
zf.write(f)
189198

190199
hook = DbtS3Hook()
191200
bucket = hook.get_bucket(s3_bucket)

0 commit comments

Comments
 (0)