Skip to content
Open
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
6 changes: 4 additions & 2 deletions chatbot-core/api/tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@ def is_valid_plugin(plugin_name: str) -> bool:
def tokenize(item: str) -> str:
item = item.replace('-', '')
return item.replace(' ', '').lower()
list_plugin_names_path = os.path.join(os.path.abspath(__file__),
"..", "..", "data", "raw", "plugin_names.json")
tools_dir = os.path.dirname(os.path.abspath(__file__))
list_plugin_names_path = os.path.normpath(
os.path.join(tools_dir, "..", "..", "data", "raw", "plugin_names.json")
)
with open(list_plugin_names_path, "r", encoding="utf-8") as f:
list_plugin_names = json.load(f)

Expand Down
13 changes: 13 additions & 0 deletions chatbot-core/tests/unit/tools/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Unit tests for api.tools.utils."""

from api.tools.utils import is_valid_plugin


def test_is_valid_plugin_returns_true_for_known_plugin():
"""Regression: plugin-name lookup should use the correct catalog path."""
assert is_valid_plugin("git") is True


def test_is_valid_plugin_returns_false_for_unknown_plugin():
"""Unknown plugins should not match catalog entries."""
assert is_valid_plugin("plugin-that-does-not-exist-12345") is False
Loading