Skip to content

Commit

Permalink
add functional tests for deprecate_package_materialization_builtin_ov…
Browse files Browse the repository at this point in the history
…erride
  • Loading branch information
MichelleArk committed Apr 22, 2024
1 parent 02e93d2 commit 3552c2a
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions tests/functional/materializations/test_custom_materialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,56 @@ def test_adapter_dependency(self, project, override_view_adapter_dep, set_up_dep
assert deprecations.active_deprecations == {"package-materialization-override"}


class TestOverrideAdapterDependencyDeprecated:
# make sure that if there's a dependency with an adapter-specific
# materialization, we honor that materialization
@pytest.fixture(scope="class")
def packages(self):
return {"packages": [{"local": "override-view-adapter-dep"}]}

@pytest.fixture(scope="class")
def project_config_update(self):
return {
"flags": {
"deprecate_package_materialization_builtin_override": True,
},
}

def test_adapter_dependency_deprecate_overrides(
self, project, override_view_adapter_dep, set_up_deprecations
):
run_dbt(["deps"])
# this should pass because the override is buggy and unused
run_dbt(["run"])

# no deprecation warning -- flag used correctly
assert deprecations.active_deprecations == set()


class TestOverrideAdapterDependencyLegacy:
# make sure that if there's a dependency with an adapter-specific
# materialization, we honor that materialization
@pytest.fixture(scope="class")
def packages(self):
return {"packages": [{"local": "override-view-adapter-dep"}]}

@pytest.fixture(scope="class")
def project_config_update(self):
return {
"flags": {
"deprecate_package_materialization_builtin_override": False,
},
}

def test_adapter_dependency(self, project, override_view_adapter_dep, set_up_deprecations):
run_dbt(["deps"])
# this should error because the override is buggy
run_dbt(["run"], expect_pass=False)

# overriding a built-in materialization scoped to adapter from package is deprecated
assert deprecations.active_deprecations == {"package-materialization-override"}


class TestOverrideDefaultDependency:
@pytest.fixture(scope="class")
def packages(self):
Expand All @@ -58,6 +108,52 @@ def test_default_dependency(self, project, override_view_default_dep, set_up_dep
assert deprecations.active_deprecations == {"package-materialization-override"}


class TestOverrideDefaultDependencyDeprecated:
@pytest.fixture(scope="class")
def packages(self):
return {"packages": [{"local": "override-view-default-dep"}]}

@pytest.fixture(scope="class")
def project_config_update(self):
return {
"flags": {
"deprecate_package_materialization_builtin_override": True,
},
}

def test_default_dependency_deprecated(
self, project, override_view_default_dep, set_up_deprecations
):
run_dbt(["deps"])
# this should pass because the override is buggy and unused
run_dbt(["run"])

# overriding a built-in materialization from package is deprecated
assert deprecations.active_deprecations == set()


class TestOverrideDefaultDependencyLegacy:
@pytest.fixture(scope="class")
def packages(self):
return {"packages": [{"local": "override-view-default-dep"}]}

@pytest.fixture(scope="class")
def project_config_update(self):
return {
"flags": {
"deprecate_package_materialization_builtin_override": False,
},
}

def test_default_dependency(self, project, override_view_default_dep, set_up_deprecations):
run_dbt(["deps"])
# this should error because the override is buggy
run_dbt(["run"], expect_pass=False)

# overriding a built-in materialization from package is deprecated
assert deprecations.active_deprecations == {"package-materialization-override"}


root_view_override_macro = """
{% materialization view, default %}
{{ return(view_default_override.materialization_view_default()) }}
Expand Down

0 comments on commit 3552c2a

Please sign in to comment.