Skip to content

Commit

Permalink
Remove deprecation warning to change "tests:" config to "data_tests:" (
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank authored Sep 6, 2024
1 parent c28cb92 commit b35ad46
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 40 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240905-180248.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: 'Remove deprecation for tests: to data_tests: change'
time: 2024-09-05T18:02:48.086421-04:00
custom:
Author: gshank
Issue: "10564"
13 changes: 0 additions & 13 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from mashumaro.types import SerializableType

from dbt import deprecations
from dbt.adapters.base import ConstraintSupport
from dbt.adapters.factory import get_adapter_constraint_support
from dbt.artifacts.resources import Analysis as AnalysisResource
Expand Down Expand Up @@ -1148,12 +1147,6 @@ def validate_data_tests(self, is_root_project: bool):
"Invalid test config: cannot have both 'tests' and 'data_tests' defined"
)
if self.tests:
if is_root_project:
deprecations.warn(
"project-test-config",
deprecated_path="tests",
exp_path="data_tests",
)
self.data_tests.extend(self.tests)
self.tests.clear()

Expand All @@ -1164,12 +1157,6 @@ def validate_data_tests(self, is_root_project: bool):
"Invalid test config: cannot have both 'tests' and 'data_tests' defined"
)
if column.tests:
if is_root_project:
deprecations.warn(
"project-test-config",
deprecated_path="tests",
exp_path="data_tests",
)
column.data_tests.extend(column.tests)
column.tests.clear()

Expand Down
5 changes: 0 additions & 5 deletions core/dbt/contracts/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from mashumaro.types import SerializableType
from typing_extensions import Annotated

from dbt import deprecations
from dbt.adapters.contracts.connection import QueryComment
from dbt.contracts.util import Identifier, list_str
from dbt_common.contracts.util import Mergeable
Expand Down Expand Up @@ -312,10 +311,6 @@ def validate(cls, data):
raise ValidationError(
"Invalid project config: cannot have both 'tests' and 'data_tests' defined"
)
if "tests" in data:
deprecations.warn(
"project-test-config", deprecated_path="tests", exp_path="data_tests"
)


@dataclass
Expand Down
6 changes: 0 additions & 6 deletions core/dbt/deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ class CollectFreshnessReturnSignature(DBTDeprecation):
_event = "CollectFreshnessReturnSignature"


class TestsConfigDeprecation(DBTDeprecation):
_name = "project-test-config"
_event = "TestsConfigDeprecation"


class ProjectFlagsMovedDeprecation(DBTDeprecation):
_name = "project-flags-moved"
_event = "ProjectFlagsMovedDeprecation"
Expand Down Expand Up @@ -167,7 +162,6 @@ def show_callback():
ConfigLogPathDeprecation(),
ConfigTargetPathDeprecation(),
CollectFreshnessReturnSignature(),
TestsConfigDeprecation(),
ProjectFlagsMovedDeprecation(),
PackageMaterializationOverrideDeprecation(),
ResourceNamesWithSpacesDeprecation(),
Expand Down
3 changes: 3 additions & 0 deletions core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ def message(self) -> str:
return line_wrap_message(warning_tag(f"Deprecated functionality\n\n{description}"))


# Note: this deprecation has been removed, but we are leaving
# the event class here, because users may have specified it in
# warn_error_options.
class TestsConfigDeprecation(WarnLevel):
def code(self) -> str:
return "D012"
Expand Down
7 changes: 0 additions & 7 deletions core/dbt/parser/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from dataclasses import dataclass, field
from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, Type, TypeVar

from dbt import deprecations
from dbt.artifacts.resources import RefArgs
from dbt.artifacts.resources.v1.model import TimeSpine
from dbt.clients.jinja_static import statically_parse_ref_or_source
Expand Down Expand Up @@ -568,12 +567,6 @@ def validate_and_rename(data, is_root_project: bool) -> None:
raise ValidationError(
"Invalid test config: cannot have both 'tests' and 'data_tests' defined"
)
if is_root_project:
deprecations.warn(
"project-test-config",
deprecated_path="tests",
exp_path="data_tests",
)
data["data_tests"] = data.pop("tests")

# model-level tests
Expand Down
14 changes: 5 additions & 9 deletions tests/functional/deprecations/test_config_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_project_tests_config(self, project):
deprecations.reset_deprecations()
assert deprecations.active_deprecations == set()
run_dbt(["parse"])
expected = {"project-test-config"}
expected = set()
assert expected == deprecations.active_deprecations

def test_project_tests_config_fail(self, project):
Expand All @@ -41,7 +41,7 @@ def test_project_tests_config_fail(self, project):
with pytest.raises(CompilationError) as exc:
run_dbt(["--warn-error", "--no-partial-parse", "parse"])
exc_str = " ".join(str(exc.value).split()) # flatten all whitespace
expected_msg = "The `tests` config has been renamed to `data_tests`"
expected_msg = "Configuration paths exist in your dbt_project.yml file which do not apply to any resources. There are 1 unused configuration paths: - data_tests"
assert expected_msg in exc_str


Expand All @@ -62,17 +62,13 @@ def test_generic_tests_config(self, project):
deprecations.reset_deprecations()
assert deprecations.active_deprecations == set()
run_dbt(["parse"])
expected = {"project-test-config"}
expected = set()
assert expected == deprecations.active_deprecations

def test_generic_tests_fail(self, project):
deprecations.reset_deprecations()
assert deprecations.active_deprecations == set()
with pytest.raises(CompilationError) as exc:
run_dbt(["--warn-error", "--no-partial-parse", "parse"])
exc_str = " ".join(str(exc.value).split()) # flatten all whitespace
expected_msg = "The `tests` config has been renamed to `data_tests`"
assert expected_msg in exc_str
run_dbt(["--warn-error", "--no-partial-parse", "parse"])

def test_generic_data_test_parsing(self, project):
results = run_dbt(["list", "--resource-type", "test"])
Expand All @@ -98,7 +94,7 @@ def test_source_tests_config(self, project):
deprecations.reset_deprecations()
assert deprecations.active_deprecations == set()
run_dbt(["parse"])
expected = {"project-test-config"}
expected = set()
assert expected == deprecations.active_deprecations

def test_generic_data_tests(self, project):
Expand Down

0 comments on commit b35ad46

Please sign in to comment.