-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: python api adding (cont) * chore: test api * chore: add tests * chore: cq * docs: update readme [skip ci]
- Loading branch information
Showing
10 changed files
with
169 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from dbterd.api import DbtErd | ||
|
||
erd = DbtErd().get_erd() | ||
print("erd (dbml):", erd) | ||
erd = DbtErd(target="mermaid").get_erd() | ||
print("erd (mermaid):", erd) | ||
|
||
print("===============") | ||
print("===============") | ||
fact_number_erd = DbtErd(target="mermaid").get_model_erd( | ||
node_unique_id="model.dbt_resto.fact_number" | ||
) | ||
print("erd of fact_number (mermaid):", fact_number_erd) | ||
|
||
print("===============") | ||
print("===============") | ||
dim_prize_erd = DbtErd(target="mermaid").get_model_erd( | ||
node_unique_id="model.dbt_resto.dim_prize" | ||
) | ||
print("erd of dim_date (mermaid):", dim_prize_erd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from pathlib import Path | ||
from unittest import mock | ||
|
||
from dbterd import default | ||
from dbterd.api import DbtErd | ||
|
||
|
||
class TestDbtErd: | ||
@mock.patch("dbterd.adapters.base.Executor.run") | ||
def test_get_erd(self, mock_executor_run): | ||
mock_executor_run.return_value = "expected-result" | ||
assert DbtErd().get_erd() == "expected-result" | ||
|
||
@mock.patch("dbterd.adapters.base.Executor.run") | ||
def test_get_model_erd(self, mock_executor_run): | ||
mock_executor_run.return_value = "expected-result" | ||
assert DbtErd().get_model_erd(node_unique_id="any") == "expected-result" | ||
|
||
def test_init_default(self): | ||
actual = DbtErd() | ||
actual_dict = dict(vars(actual)) | ||
del actual_dict["executor"] | ||
assert actual_dict == dict( | ||
params=dict( | ||
api=True, | ||
select=[], | ||
exclude=[], | ||
resource_type=default.default_resource_types(), | ||
algo=default.default_algo(), | ||
entity_name_format=default.default_entity_name_format(), | ||
omit_columns=False, | ||
artifacts_dir=Path.cwd(), | ||
target=default.default_target(), | ||
) | ||
) | ||
assert actual.executor.ctx.command.name == "run" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters