Skip to content

Commit

Permalink
write test demonstrating the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Oct 31, 2023
1 parent f929bea commit 607d104
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/functional/adapter/catalog_tests/files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
MY_SEED = """
id,value,record_valid_date
1,100,2023-01-01 00:00:00
2,200,2023-01-02 00:00:00
3,300,2023-01-02 00:00:00
""".strip()


MY_TABLE = """
{{ config(
materialized='table',
) }}
select *
from {{ ref('my_seed') }}
"""


MY_VIEW = """
{{ config(
materialized='view',
) }}
select *
from {{ ref('my_seed') }}
"""


MY_MATERIALIZED_VIEW = """
{{ config(
materialized='materialized_view',
) }}
select *
from {{ ref('my_seed') }}
"""
44 changes: 44 additions & 0 deletions tests/functional/adapter/catalog_tests/test_relation_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from dbt.contracts.results import CatalogArtifact
from dbt.tests.util import run_dbt
import pytest

from tests.functional.adapter.catalog_tests import files


class TestCatalogRelationTypes:
@pytest.fixture(scope="class", autouse=True)
def seeds(self):
return {"my_seed.csv": files.MY_SEED}

@pytest.fixture(scope="class", autouse=True)
def models(self):
yield {
"my_table.sql": files.MY_TABLE,
"my_view.sql": files.MY_VIEW,
"my_materialized_view.sql": files.MY_MATERIALIZED_VIEW,
}

@pytest.fixture(scope="class", autouse=True)
def docs(self, project):
run_dbt(["seed"])
run_dbt(["run"])
yield run_dbt(["docs", "generate"])

@pytest.mark.parametrize(
"node_name,relation_type",
[
("seed.test.my_seed", "BASE TABLE"),
("model.test.my_table", "BASE TABLE"),
("model.test.my_view", "VIEW"),
("model.test.my_materialized_view", "MATERIALIZED VIEW"),
],
)
def test_relation_types_populate_correctly(
self, docs: CatalogArtifact, node_name: str, relation_type: str
):
"""
This test addresses: https://github.com/dbt-labs/dbt-redshift/issues/652
"""
assert node_name in docs.nodes
node = docs.nodes[node_name]
assert node.metadata.type == relation_type

0 comments on commit 607d104

Please sign in to comment.