Skip to content

Commit

Permalink
Refactor test_archive_not_allowed to functional test
Browse files Browse the repository at this point in the history
We do already have tests that ensure "extra" keys aren't allowed in
the dbt_project.yaml. This test is different because it's checking that
a specific key, `archive`, isn't allowed. We do this because at one point
in time `archive` _was_ an allowed key. Specifically, we stopped allowing
`archive` in dbt-core 0.15.0 via commit [f26948d](f26948d).
Given that it's been 5 years and a major version, we could probably remove
this test, but let's keep it around unless we start supporting `archive` again.
  • Loading branch information
QMalcolm committed May 30, 2024
1 parent 9b2fe6b commit 3e82809
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
28 changes: 28 additions & 0 deletions tests/functional/basic/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,31 @@ def test_version_specifier_checks_before_yaml_validation(self, project) -> None:
assert result.exception is not None
assert isinstance(result.exception, DbtProjectError)
assert "This version of dbt is not supported"


class TestArchiveNotAllowed:
"""At one point in time we supported an 'archive' key in projects, but no longer"""

def test_archive_not_allowed(self, project):
runner = dbtRunner()

config_update = {
"archive": {
"source_schema": "a",
"target_schema": "b",
"tables": [
{
"source_table": "seed",
"target_table": "archive_actual",
"updated_at": "updated_at",
"unique_key": """id || '-' || first_name""",
},
],
}
}
update_config_file(config_update, "dbt_project.yml")

result = runner.invoke(["parse"])
assert result.exception is not None
assert isinstance(result.exception, ProjectContractError)
assert "Additional properties are not allowed" in str(result.exception)
18 changes: 0 additions & 18 deletions tests/unit/config/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,6 @@ def from_parts(self, exc=None):
else:
return err

def test_archive_not_allowed(self):
self.default_project_data["archive"] = [
{
"source_schema": "a",
"target_schema": "b",
"tables": [
{
"source_table": "seed",
"target_table": "archive_actual",
"updated_at": "updated_at",
"unique_key": """id || '-' || first_name""",
},
],
}
]
with self.assertRaises(dbt.exceptions.ProjectContractError):
self.get_project()

def test__warn_for_unused_resource_config_paths_empty(self):
project = self.from_parts()
dbt.flags.WARN_ERROR = True
Expand Down

0 comments on commit 3e82809

Please sign in to comment.