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

Fix for dbt_project.yml "tests" config resulting in incorrect state:modified #11166

Merged
merged 7 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20241218-112640.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix unrendered_config for tests from dbt_project.yml
time: 2024-12-18T11:26:40.270022-05:00
custom:
Author: gshank
Issue: "11146"
2 changes: 2 additions & 0 deletions core/dbt/config/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@
)

project_dict = _load_yaml(project_yaml_filepath)
if "tests" in project_dict:
project_dict["data_tests"] = project_dict.pop("tests")

Check warning on line 199 in core/dbt/config/project.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/config/project.py#L199

Added line #L199 was not covered by tests

if not isinstance(project_dict, dict):
raise DbtProjectError(f"{DBT_PROJECT_FILE_NAME} does not parse to a dictionary")
Expand Down
46 changes: 46 additions & 0 deletions tests/functional/defer_state/test_unrendered_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import pytest

from dbt.tests.util import run_dbt

dbt_project_update = """
models:
my_dbt_project:
+materialized: table

tests:
+store_failures: true
"""

foo_sql = """
select 1 as id
"""

schema_yml = """
models:
- name: foo
columns:
- name: id
tests:
- unique
"""


class TestGenericTestUnrenderedConfig:
@pytest.fixture(scope="class")
def project_config_update(self):
return dbt_project_update

@pytest.fixture(scope="class")
def models(self):
return {
"foo.sql": foo_sql,
"schema.yml": schema_yml,
}

def test_unrendered_config(self, project):
manifest = run_dbt(["parse"])
assert manifest
print(f"--- nodes: {manifest.nodes.keys()}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove print

test_node_id = "test.test.unique_foo_id.fa8c520a2e"
test_node = manifest.nodes[test_node_id]
assert test_node.unrendered_config == {"store_failures": True}
Loading