mirror of
https://github.com/dbt-labs/dbt-core
synced 2025-12-17 19:31:34 +00:00
adding clean_up methods to basic and unique_id tests (#9195)
* init attempt of adding clean_up methods to basic and unique_id tests
* swapping cleanup method drop of test_schema to unique_schema to test breakage on docs_generate test
* moving the clean_up method down into class BaseDocsGenerate
* remove drop relation for unique_schema
* manually define alternate_schema for clean_up as not being seen as part of project_config
* add changelog
* remove unneeded changelog
* uncomment line that generates new manifest and delete manifest our changes created
* make sure the manifest test is deleted and readd older version of manifest.json to appease test
* manually revert file to previous commit
* Revert "manually revert file to previous commit"
This reverts commit a755419e8b.
This commit is contained in:
@@ -90,6 +90,17 @@ class BaseAdapterMethod:
|
||||
"name": "adapter_methods",
|
||||
}
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_up(self, project):
|
||||
yield
|
||||
with project.adapter.connection_named("__test"):
|
||||
relation = project.adapter.Relation.create(
|
||||
database=project.database, schema=project.test_schema
|
||||
)
|
||||
project.adapter.drop_schema(relation)
|
||||
|
||||
pass
|
||||
|
||||
# snowflake need all tables in CAP name
|
||||
@pytest.fixture(scope="class")
|
||||
def equal_tables(self):
|
||||
|
||||
@@ -37,6 +37,17 @@ class BaseSimpleMaterializations:
|
||||
"name": "base",
|
||||
}
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_up(self, project):
|
||||
yield
|
||||
with project.adapter.connection_named("__test"):
|
||||
relation = project.adapter.Relation.create(
|
||||
database=project.database, schema=project.test_schema
|
||||
)
|
||||
project.adapter.drop_schema(relation)
|
||||
|
||||
pass
|
||||
|
||||
def test_base(self, project):
|
||||
|
||||
# seed command
|
||||
|
||||
@@ -428,6 +428,18 @@ class BaseDocsGenerate(BaseGenerateProject):
|
||||
model_stats=no_stats(),
|
||||
)
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_up(self, project):
|
||||
yield
|
||||
with project.adapter.connection_named("__test"):
|
||||
alternate_schema = f"{project.test_schema}_test"
|
||||
relation = project.adapter.Relation.create(
|
||||
database=project.database, schema=alternate_schema
|
||||
)
|
||||
project.adapter.drop_schema(relation)
|
||||
|
||||
pass
|
||||
|
||||
# Test "--no-compile" flag works and produces no manifest.json
|
||||
def test_run_and_generate_no_compile(self, project, expected_catalog):
|
||||
start_time = run_and_generate(project, ["--no-compile"])
|
||||
|
||||
@@ -33,6 +33,17 @@ class BaseGenericTests:
|
||||
"schema_table.yml": generic_test_table_yml,
|
||||
}
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_up(self, project):
|
||||
yield
|
||||
with project.adapter.connection_named("__test"):
|
||||
relation = project.adapter.Relation.create(
|
||||
database=project.database, schema=project.test_schema
|
||||
)
|
||||
project.adapter.drop_schema(relation)
|
||||
|
||||
pass
|
||||
|
||||
def test_generic_tests(self, project):
|
||||
# seed command
|
||||
results = run_dbt(["seed"])
|
||||
|
||||
@@ -23,6 +23,17 @@ class BaseIncremental:
|
||||
def seeds(self):
|
||||
return {"base.csv": seeds_base_csv, "added.csv": seeds_added_csv}
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_up(self, project):
|
||||
yield
|
||||
with project.adapter.connection_named("__test"):
|
||||
relation = project.adapter.Relation.create(
|
||||
database=project.database, schema=project.test_schema
|
||||
)
|
||||
project.adapter.drop_schema(relation)
|
||||
|
||||
pass
|
||||
|
||||
def test_incremental(self, project):
|
||||
# seed command
|
||||
results = run_dbt(["seed"])
|
||||
|
||||
@@ -18,6 +18,17 @@ class BaseSingularTests:
|
||||
def project_config_update(self):
|
||||
return {"name": "singular_tests"}
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_up(self, project):
|
||||
yield
|
||||
with project.adapter.connection_named("__test"):
|
||||
relation = project.adapter.Relation.create(
|
||||
database=project.database, schema=project.test_schema
|
||||
)
|
||||
project.adapter.drop_schema(relation)
|
||||
|
||||
pass
|
||||
|
||||
def test_singular_tests(self, project):
|
||||
# test command
|
||||
results = run_dbt(["test"], expect_pass=False)
|
||||
|
||||
@@ -39,6 +39,17 @@ class BaseSingularTestsEphemeral:
|
||||
"name": "singular_tests_ephemeral",
|
||||
}
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_up(self, project):
|
||||
yield
|
||||
with project.adapter.connection_named("__test"):
|
||||
relation = project.adapter.Relation.create(
|
||||
database=project.database, schema=project.test_schema
|
||||
)
|
||||
project.adapter.drop_schema(relation)
|
||||
|
||||
pass
|
||||
|
||||
def test_singular_tests_ephemeral(self, project):
|
||||
# check results from seed command
|
||||
results = run_dbt(["seed"])
|
||||
|
||||
@@ -35,6 +35,17 @@ class BaseSnapshotCheckCols:
|
||||
"cc_name_snapshot.sql": cc_name_snapshot_sql,
|
||||
}
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_up(self, project):
|
||||
yield
|
||||
with project.adapter.connection_named("__test"):
|
||||
relation = project.adapter.Relation.create(
|
||||
database=project.database, schema=project.test_schema
|
||||
)
|
||||
project.adapter.drop_schema(relation)
|
||||
|
||||
pass
|
||||
|
||||
def test_snapshot_check_cols(self, project):
|
||||
# seed command
|
||||
results = run_dbt(["seed"])
|
||||
|
||||
@@ -33,6 +33,17 @@ class BaseSnapshotTimestamp:
|
||||
def project_config_update(self):
|
||||
return {"name": "snapshot_strategy_timestamp"}
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_up(self, project):
|
||||
yield
|
||||
with project.adapter.connection_named("__test"):
|
||||
relation = project.adapter.Relation.create(
|
||||
database=project.database, schema=project.test_schema
|
||||
)
|
||||
project.adapter.drop_schema(relation)
|
||||
|
||||
pass
|
||||
|
||||
def test_snapshot_timestamp(self, project):
|
||||
# seed command
|
||||
results = run_dbt(["seed"])
|
||||
|
||||
@@ -344,6 +344,17 @@ class BaseIncrementalUniqueKey:
|
||||
"add_new_rows.sql": seeds__add_new_rows_sql,
|
||||
}
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def clean_up(self, project):
|
||||
yield
|
||||
with project.adapter.connection_named("__test"):
|
||||
relation = project.adapter.Relation.create(
|
||||
database=project.database, schema=project.test_schema
|
||||
)
|
||||
project.adapter.drop_schema(relation)
|
||||
|
||||
pass
|
||||
|
||||
def update_incremental_model(self, incremental_model):
|
||||
"""update incremental model after the seed table has been updated"""
|
||||
model_result_set = run_dbt(["run", "--select", incremental_model])
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -412,7 +412,7 @@ class TestPreviousVersionState:
|
||||
current_manifest_schema_version == self.CURRENT_EXPECTED_MANIFEST_VERSION
|
||||
), "Sounds like you've bumped the manifest version and need to update this test!"
|
||||
# If we need a newly generated manifest, uncomment the following line and commit the result
|
||||
self.generate_latest_manifest(project, current_manifest_schema_version)
|
||||
# self.generate_latest_manifest(project, current_manifest_schema_version)
|
||||
self.compare_previous_state(project, current_manifest_schema_version, True, 0)
|
||||
|
||||
def test_backwards_compatible_versions(self, project):
|
||||
|
||||
Reference in New Issue
Block a user