Skip to content

Commit

Permalink
tests for model quoting
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk committed Oct 24, 2024
1 parent 227dcd9 commit 991b265
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions tests/functional/relation_quoting/test_relation_quoting.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"""


class TestSourceQuotingLegacy:
class TestSourceQuotingGlobalConfigs:
@pytest.fixture(scope="class")
def project_config_update(self):
# Postgres quoting configs are True by default -- turn them all to False to show they are not respected during source rendering
return {
"quoting": {
"database": False,
"schema": False,
"database": False,
"identifier": False,
},
}

Expand All @@ -36,3 +36,29 @@ def test_sources_ignore_global_quoting_configs(self, project):

generated_sql = read_file("target", "compiled", "test", "models", "model.sql")
assert generated_sql == 'select * from "source_database"."source_schema"."customers"'


class TestModelQuoting:
@pytest.fixture(scope="class")
def project_config_update(self):
# Postgres quoting configs are True by default -- turn them all to False to show they are respected during model rendering
return {
"quoting": {
"database": False,
"schema": False,
"identifier": False,
},
}

@pytest.fixture(scope="class")
def models(self):
return {
"model.sql": "select 1 as id",
"model_downstream.sql": "select * from {{ ref('model') }}",
}

def test_models_respect_global_quoting_configs(self, project):
run_dbt(["compile"])

generated_sql = read_file("target", "compiled", "test", "models", "model_downstream.sql")
assert generated_sql == f"select * from dbt.{project.test_schema}.model"

0 comments on commit 991b265

Please sign in to comment.