Skip to content

Commit

Permalink
Munge project_dict["tests"] to "data_tests" after loading
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank committed Dec 18, 2024
1 parent c41a38c commit 1bbd39a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
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 @@ def load_raw_project(project_root: str) -> Dict[str, Any]:
)

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

if not isinstance(project_dict, dict):
raise DbtProjectError(f"{DBT_PROJECT_FILE_NAME} does not parse to a dictionary")
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/context/context_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_config_dict(self, resource_type: NodeType) -> Dict[str, Any]:
elif resource_type == NodeType.Source:
model_configs = unrendered.get("sources")
elif resource_type == NodeType.Test:
model_configs = unrendered.get("data_tests") or unrendered.get("tests")
model_configs = unrendered.get("data_tests")
elif resource_type == NodeType.Metric:
model_configs = unrendered.get("metrics")
elif resource_type == NodeType.SemanticModel:
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/defer_state/test_unrendered_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from dbt.tests.util import run_dbt


dbt_project_update = """
models:
my_dbt_project:
Expand All @@ -25,7 +24,8 @@
- unique
"""

class TestGenericTestUnrenderedConfig():

class TestGenericTestUnrenderedConfig:
@pytest.fixture(scope="class")
def project_config_update(self):
return dbt_project_update
Expand All @@ -41,6 +41,6 @@ def test_unrendered_config(self, project):
manifest = run_dbt(["parse"])
assert manifest
print(f"--- nodes: {manifest.nodes.keys()}")
test_node_id = 'test.test.unique_foo_id.fa8c520a2e'
test_node_id = "test.test.unique_foo_id.fa8c520a2e"
test_node = manifest.nodes[test_node_id]
assert test_node.unrendered_config == {"store_failures": True}

0 comments on commit 1bbd39a

Please sign in to comment.