Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ct 1629/052 column quoting tests conversion #6652

Merged
merged 5 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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()