Skip to content

Commit

Permalink
Ct 1629/052 column quoting tests conversion (#6652)
Browse files Browse the repository at this point in the history
* 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
VersusFacit and VersusFacit authored Jan 26, 2023
1 parent c2c4757 commit 3f96fad
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 106 deletions.

This file was deleted.

12 changes: 0 additions & 12 deletions test/integration/052_column_quoting_tests/models/model.sql

This file was deleted.

4 changes: 0 additions & 4 deletions test/integration/052_column_quoting_tests/seeds/seed.csv

This file was deleted.

78 changes: 0 additions & 78 deletions test/integration/052_column_quoting_tests/test_column_quotes.py

This file was deleted.

100 changes: 100 additions & 0 deletions tests/functional/column_quoting/test_column_quotes.py
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()

0 comments on commit 3f96fad

Please sign in to comment.