-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ct 1629/052 column quoting tests conversion (#6652)
* Test converted and reformatted for pytest. * Ax old versions of 052 test * Nix the 'os' import and black format * Change names of models to be more PEP like * cleanup code Co-authored-by: Mila Page <[email protected]>
- Loading branch information
1 parent
c2c4757
commit 3f96fad
Showing
5 changed files
with
100 additions
and
106 deletions.
There are no files selected for viewing
12 changes: 0 additions & 12 deletions
12
test/integration/052_column_quoting_tests/models-unquoted/model.sql
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
test/integration/052_column_quoting_tests/models/model.sql
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
78 changes: 0 additions & 78 deletions
78
test/integration/052_column_quoting_tests/test_column_quotes.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import pytest | ||
|
||
from dbt.tests.util import run_dbt | ||
|
||
_MODELS__COLUMN_QUOTING_DEFAULT = """ | ||
{% set col_a = '"col_A"' %} | ||
{% set col_b = '"col_B"' %} | ||
{{ | ||
config( | ||
materialized = 'incremental', | ||
unique_key = col_a, | ||
) | ||
}} | ||
select | ||
{{ col_a }}, | ||
{{ col_b }} | ||
from {{ref('seed')}} | ||
""" | ||
|
||
_MODELS__COLUMN_QUOTING_NO_QUOTING = """ | ||
{% set col_a = '"col_a"' %} | ||
{% set col_b = '"col_b"' %} | ||
{{ | ||
config( | ||
materialized = 'incremental', | ||
unique_key = col_a, | ||
) | ||
}} | ||
select | ||
{{ col_a }}, | ||
{{ col_b }} | ||
from {{ref('seed')}} | ||
""" | ||
|
||
_SEEDS_BASIC_SEED = """col_A,col_B | ||
1,2 | ||
3,4 | ||
5,6 | ||
""" | ||
|
||
|
||
class BaseColumnQuotingTest: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return {"model.sql": _MODELS__COLUMN_QUOTING_DEFAULT} | ||
|
||
@pytest.fixture(scope="class") | ||
def seeds(self): | ||
return {"seed.csv": _SEEDS_BASIC_SEED} | ||
|
||
@pytest.fixture(scope="function") | ||
def run_column_quotes(self, project): | ||
def fixt(): | ||
results = run_dbt(["seed"]) | ||
assert len(results) == 1 | ||
results = run_dbt(["run"]) | ||
assert len(results) == 1 | ||
results = run_dbt(["run"]) | ||
assert len(results) == 1 | ||
|
||
return fixt | ||
|
||
|
||
class TestColumnQuotingDefault(BaseColumnQuotingTest): | ||
def test_column_quotes(self, run_column_quotes): | ||
run_column_quotes() | ||
|
||
|
||
class TestColumnQuotingEnabled(BaseColumnQuotingTest): | ||
@pytest.fixture(scope="class") | ||
def project_config_update(self): | ||
return { | ||
"seeds": { | ||
"quote_columns": True, | ||
}, | ||
} | ||
|
||
def test_column_quotes(self, run_column_quotes): | ||
run_column_quotes() | ||
|
||
|
||
class TestColumnQuotingDisabled(BaseColumnQuotingTest): | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return {"model.sql": _MODELS__COLUMN_QUOTING_NO_QUOTING} | ||
|
||
@pytest.fixture(scope="class") | ||
def project_config_update(self): | ||
return { | ||
"seeds": { | ||
"quote_columns": False, | ||
}, | ||
} | ||
|
||
def test_column_quotes(self, run_column_quotes): | ||
run_column_quotes() |