Skip to content

Commit

Permalink
Add test cases for mermaid
Browse files Browse the repository at this point in the history
  • Loading branch information
syou6162 committed Feb 8, 2024
1 parent 3c64a87 commit 7f01392
Showing 1 changed file with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class TestMermaidTestRelationship:
@pytest.mark.parametrize(
"tables, relationships, select, exclude, resource_type, expected",
"tables, relationships, select, exclude, resource_type, omit_columns, expected",
[
(
[
Expand All @@ -25,6 +25,7 @@ class TestMermaidTestRelationship:
[],
[],
["model"],
False,
"""erDiagram
"MODEL.DBT_RESTO.TABLE1" {
name1-type name1
Expand Down Expand Up @@ -73,6 +74,7 @@ class TestMermaidTestRelationship:
[],
[],
["model", "source"],
False,
"""erDiagram
"MODEL.DBT_RESTO.TABLE1" {
name1-type name1
Expand Down Expand Up @@ -118,6 +120,7 @@ class TestMermaidTestRelationship:
["schema:--schema--"],
[],
["model", "source"],
False,
"""erDiagram
"MODEL.DBT_RESTO.TABLE1" {
name1-type name1
Expand All @@ -139,6 +142,7 @@ class TestMermaidTestRelationship:
[],
["model.dbt_resto.table1"],
["model"],
False,
"""erDiagram
""",
),
Expand All @@ -165,6 +169,7 @@ class TestMermaidTestRelationship:
["model.dbt_resto"],
["model.dbt_resto.table2"],
["model"],
False,
"""erDiagram
"MODEL.DBT_RESTO.TABLE1" {
name1-type name1
Expand All @@ -186,6 +191,7 @@ class TestMermaidTestRelationship:
["schema:", "wildcard:", ""],
[],
["model"],
False,
"""erDiagram
"MODEL.DBT_RESTO.TABLE1" {
name1-type name1
Expand Down Expand Up @@ -215,16 +221,45 @@ class TestMermaidTestRelationship:
["schema:--schema--,wildcard:*dbt_resto.table*"],
["wildcard:*table2"],
["model"],
False,
"""erDiagram
"MODEL.DBT_RESTO.TABLE1" {
name1-type name1
}
""",
),
(
[
Table(
name="model.dbt_resto.table1",
node_name="model.dbt_resto.table1",
database="--database--",
schema="--schema--",
columns=[Column(name="name1", data_type="name1-type")],
raw_sql="--irrelevant--",
)
],
[],
[],
[],
["model"],
True,
"""erDiagram
"MODEL.DBT_RESTO.TABLE1" {
}
""",
),
],
)
def test_parse(
self, tables, relationships, select, exclude, resource_type, expected
self,
tables,
relationships,
select,
exclude,
resource_type,
omit_columns,
expected,
):
with mock.patch(
"dbterd.adapters.algos.base.get_tables",
Expand All @@ -239,6 +274,7 @@ def test_parse(
catalog="--catalog--",
select=select,
exclude=exclude,
omit_columns=omit_columns,
resource_type=resource_type,
)
print("mermaid ", mermaid.replace(" ", "").replace("\n", ""))
Expand Down

0 comments on commit 7f01392

Please sign in to comment.