Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): find_related_nodes_by_id shouldn't raise exception #104

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions dbterd/adapters/algos/test_relationship.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from typing import List, Tuple, Union

import click

from dbterd.adapters.algos import base
from dbterd.adapters.filter import is_selected_table
from dbterd.adapters.meta import Ref, Table
Expand Down Expand Up @@ -121,14 +119,15 @@ def find_related_nodes_by_id(
Returns:
List[str]: Manifest nodes' unique ID
"""
if type is not None:
raise click.BadParameter("Not supported manifest type")
found_nodes = [node_unique_id]
if type == "metadata":
return found_nodes # not supported yet, returned input only

rule = base.get_algo_rule(**kwargs)
test_nodes = base.get_test_nodes_by_rule_name(
manifest=manifest, rule_name=rule.get("name").lower()
)
found_nodes = [node_unique_id]

for test_node in test_nodes:
nodes = manifest.nodes[test_node].depends_on.nodes or []
if node_unique_id in nodes:
Expand Down
9 changes: 4 additions & 5 deletions tests/unit/adapters/algos/test_test_relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,11 +866,10 @@ def test_get_relationships_from_metadata_error(self, data, kwargs):
with pytest.raises(click.BadParameter):
base_algo.get_relationships_from_metadata(data=data, **kwargs)

def test_find_related_nodes_by_id_error(self):
with pytest.raises(click.BadParameter):
test_relationship.find_related_nodes_by_id(
manifest="irrelevant", type="metadata", node_unique_id="irrelevant"
)
def test_find_related_nodes_by_id_not_supported_type(self):
assert ["model.p.abc"] == test_relationship.find_related_nodes_by_id(
manifest="irrelevant", type="metadata", node_unique_id="model.p.abc"
)

def test_find_related_nodes_by_id(self):
assert sorted(["model.dbt_resto.table1", "model.dbt_resto.table2"]) == sorted(
Expand Down
Loading