From 1bbd39a76e9abfee78dbb35f8ccdd0c8fbec559f Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Wed, 18 Dec 2024 11:24:51 -0500 Subject: [PATCH] Munge project_dict["tests"] to "data_tests" after loading --- core/dbt/config/project.py | 2 ++ core/dbt/context/context_config.py | 2 +- tests/functional/defer_state/test_unrendered_config.py | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/dbt/config/project.py b/core/dbt/config/project.py index cbad5a38434..bd8eca095f8 100644 --- a/core/dbt/config/project.py +++ b/core/dbt/config/project.py @@ -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") diff --git a/core/dbt/context/context_config.py b/core/dbt/context/context_config.py index 20642eff1e2..b1aace475c7 100644 --- a/core/dbt/context/context_config.py +++ b/core/dbt/context/context_config.py @@ -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: diff --git a/tests/functional/defer_state/test_unrendered_config.py b/tests/functional/defer_state/test_unrendered_config.py index e9eee462167..57db0ae743a 100644 --- a/tests/functional/defer_state/test_unrendered_config.py +++ b/tests/functional/defer_state/test_unrendered_config.py @@ -2,7 +2,6 @@ from dbt.tests.util import run_dbt - dbt_project_update = """ models: my_dbt_project: @@ -25,7 +24,8 @@ - unique """ -class TestGenericTestUnrenderedConfig(): + +class TestGenericTestUnrenderedConfig: @pytest.fixture(scope="class") def project_config_update(self): return dbt_project_update @@ -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}