Skip to content

Commit

Permalink
Parametrize cases
Browse files Browse the repository at this point in the history
  • Loading branch information
VersusFacit committed Dec 9, 2024
1 parent 091c3bb commit 4d78bf5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 10 additions & 1 deletion tests/functional/relation_tests/dynamic_table_tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""


AUTO_DYNAMIC_TABLE = """
EXPLICIT_AUTO_DYNAMIC_TABLE = """
{{ config(
materialized='dynamic_table',
snowflake_warehouse='DBT_TESTING',
Expand All @@ -27,6 +27,15 @@
select * from {{ ref('my_seed') }}
"""

IMPLICIT_AUTO_DYNAMIC_TABLE = """
{{ config(
materialized='dynamic_table',
snowflake_warehouse='DBT_TESTING',
target_lag='2 minutes',
) }}
select * from {{ ref('my_seed') }}
"""


DYNAMIC_TABLE_DOWNSTREAM = """
{{ config(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,20 @@ def seeds(self):
@pytest.fixture(scope="class", autouse=True)
def models(self):
yield {
f"{self.DT_NAME}.sql": models.AUTO_DYNAMIC_TABLE,
f"explicit_{self.DT_NAME}.sql": models.EXPLICIT_AUTO_DYNAMIC_TABLE,
f"implicit_{self.DT_NAME}.sql": models.IMPLICIT_AUTO_DYNAMIC_TABLE,
}

def test_auto_config_doesnt_rebuild(self, project):
model_qualified_name = f"{project.database}.{project.test_schema}.{self.DT_NAME}"
@pytest.mark.parametrize("test_dt", [f"explicit_{DT_NAME}", f"implicit_{DT_NAME}"])
def test_auto_config_doesnt_rebuild(self, project, test_dt):
model_qualified_name = f"{project.database}.{project.test_schema}.{test_dt}"

run_dbt(["seed"])
_, logs = run_dbt_and_capture(["--debug", "run", "--select", f"{self.DT_NAME}.sql"])
_, logs = run_dbt_and_capture(["--debug", "run", "--select", f"{test_dt}.sql"])
assert_message_in_logs(f"create dynamic table {model_qualified_name}", logs)
assert_message_in_logs("refresh_mode = AUTO", logs)

_, logs = run_dbt_and_capture(["--debug", "run", "--select", f"{self.DT_NAME}.sql"])
_, logs = run_dbt_and_capture(["--debug", "run", "--select", f"{test_dt}.sql"])
assert_message_in_logs(f"create dynamic table {model_qualified_name}", logs, False)
assert_message_in_logs("refresh_mode = AUTO", logs, False)
assert_message_in_logs(
Expand Down

0 comments on commit 4d78bf5

Please sign in to comment.