Skip to content

Commit

Permalink
Add functional test for dropped column
Browse files Browse the repository at this point in the history
  • Loading branch information
svdimchenko committed Sep 30, 2024
1 parent f312d8c commit e8f36e1
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions tests/functional/adapter/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
select 1 as id
"""

iceberg_model_sql = """
{{
config(
materialized="table",
table_type="iceberg",
post_hook="alter table model drop column to_drop"
)
}}
select 1 as id, 'to_drop' as to_drop
"""

override_macros_sql = """
{% macro get_catalog_relations(information_schema, relations) %}
{{ return(adapter.get_catalog_by_relations(information_schema, relations)) }}
Expand Down Expand Up @@ -44,7 +55,6 @@ def custom_verify_catalog_athena(project, expected_catalog, start_time):
assert node_key in found_node
# the value of found_node[node_key] is not exactly expected_node[node_key]


class TestDocsGenerate(BaseDocsGenerate):
"""
Override of BaseDocsGenerate to make it working with Athena
Expand Down Expand Up @@ -88,14 +98,37 @@ def models(self):
def macros(self):
return {"override_macros_sql.sql": override_macros_sql}

def test_generate_docs(
self,
project,
):
def test_generate_docs(self, project):
results = run_dbt(["run"])
assert len(results) == 1

docs_generate = run_dbt(["--warn-error", "docs", "generate"])
assert len(docs_generate._compile_results.results) == 1
assert docs_generate._compile_results.results[0].status == RunStatus.Success
assert docs_generate.errors is None


class TestDocsGenerateIcebergNonCurrentColumn:
@pytest.fixture(scope="class")
def models(self):
return {"model.sql": iceberg_model_sql}

@pytest.fixture(scope="class")
def macros(self):
return {"override_macros_sql.sql": override_macros_sql}

def test_generate_docs(self, project):
results = run_dbt(["run"])
assert len(results) == 1

docs_generate = run_dbt(["--warn-error", "docs", "generate"])
assert len(docs_generate._compile_results.results) == 1
assert docs_generate._compile_results.results[0].status == RunStatus.Success
assert docs_generate.errors is None

catalog_path = os.path.join(project.project_root, "target", "catalog.json")
assert os.path.exists(catalog_path)
catalog = get_artifact(catalog_path)
columns = catalog["nodes"]["model.test.model"]["columns"]
assert "to_drop" not in columns
assert "id" in columns

0 comments on commit e8f36e1

Please sign in to comment.