Skip to content

Commit

Permalink
test: fill 100% cov
Browse files Browse the repository at this point in the history
  • Loading branch information
datnguye committed Sep 7, 2023
1 parent 26c8e19 commit 0cc2cbd
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/unit/adapters/algos/test_test_relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class ManifestNode:
depends_on: ManifestNodeDependsOn = field(default_factory=ManifestNodeDependsOn)


@dataclass
class ManifestExposureNode:
depends_on: ManifestNodeDependsOn


@dataclass
class ManifestNodeColumn:
name: str
Expand Down Expand Up @@ -184,6 +189,17 @@ class DummyManifestTable:
}


@dataclass
class DummyManifestWithExposure:
exposures = {
"exposure.dbt_resto.dummy": ManifestExposureNode(
depends_on=ManifestNodeDependsOn(
nodes=["model.dbt_resto.table1", "model.dbt_resto.table2"]
),
)
}


@dataclass
class CatalogNode:
columns: dict
Expand Down Expand Up @@ -355,3 +371,22 @@ def test_get_relationships(self, manifest, algorithm, expected):
)
def test_get_relationship_type(self, meta, type):
assert algo.get_relationship_type(meta=meta) == type

@pytest.mark.parametrize(
"manifest, expected",
[
(
DummyManifestWithExposure(),
[
dict(table_name="model.dbt_resto.table1", exposure_name="dummy"),
dict(table_name="model.dbt_resto.table2", exposure_name="dummy"),
],
),
(
DummyManifestTable(),
[],
),
],
)
def test_get_node_exposures(self, manifest, expected):
assert expected == base_algo.get_node_exposures(manifest=manifest)
54 changes: 54 additions & 0 deletions tests/unit/adapters/targets/dbml/test_dbml_test_relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,60 @@ class TestDbmlTestRelationship:
//Refs (based on the DBT Relationship Tests)
""",
),
(
[
Table(
name="model.dbt_resto.table1",
database="--database--",
schema="--schema--",
columns=[Column(name="name1", data_type="name1-type")],
raw_sql="--irrelevant--",
exposures=["dummy1"]
)
],
[],
["exposure:dummy1", "exposure:"],
[],
["model"],
"""//Tables (based on the selection criteria)
//--configured at schema: --database--.--schema--
Table "model.dbt_resto.table1" {
"name1" "name1-type"
}
//Refs (based on the DBT Relationship Tests)
""",
),
(
[
Table(
name="model.dbt_resto.table1",
database="--database--",
schema="--schema--",
columns=[Column(name="name1", data_type="name1-type")],
raw_sql="--irrelevant--",
exposures=["dummy1"]
),
Table(
name="model.dbt_resto.table23",
database="--database--",
schema="--schema--",
columns=[Column(name="name23", data_type="name23-type")],
raw_sql="--irrelevant--",
exposures=["dummy2", "dummy3"]
)
],
[],
["exposure:dummy2"],
[],
["model"],
"""//Tables (based on the selection criteria)
//--configured at schema: --database--.--schema--
Table "model.dbt_resto.table23" {
"name23" "name23-type"
}
//Refs (based on the DBT Relationship Tests)
""",
),
],
)
def test_parse(
Expand Down

0 comments on commit 0cc2cbd

Please sign in to comment.