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

wrote test function for _is_node_field_valid() #224

Merged
merged 1 commit into from
Jul 26, 2023
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
2 changes: 1 addition & 1 deletion src/cript/nodes/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def _is_node_field_valid(node_type_list: list) -> bool:
"""

# TODO consider having exception handling for the dict
if isinstance(node_type_list, list) and len(node_type_list) == 1 and isinstance(node_type_list[0], str):
if isinstance(node_type_list, list) and len(node_type_list) == 1 and isinstance(node_type_list[0], str) and node_type_list[0]:
return True
else:
return False
Expand Down
18 changes: 18 additions & 0 deletions tests/nodes/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from cript.nodes.util import _is_node_field_valid


def test_is_node_field_valid() -> None:
"""
test the `_is_node_field_valid()` function to be sure it does the node type check correctly

checks both in places it should be valid and invalid
"""
assert _is_node_field_valid(node_type_list=["Project"]) is True

assert _is_node_field_valid(node_type_list=["Project", "Material"]) is False

assert _is_node_field_valid(node_type_list=[""]) is False

assert _is_node_field_valid(node_type_list="Project") is False

assert _is_node_field_valid(node_type_list=[]) is False
Loading