mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-22 01:24:52 +02:00
[haik]: rename _sanitize_server_name to sanitize_mcp_server_name (mcp_config canonical, agent_manager, prompt_context, main, tests, toolLabels comment), add no-underscore-names linter check banning leading-underscore Python names in backend, extract _models.py from classes.py for shared pydantic BaseModel field detection used by both classes and vulture checks, add vulture-ignore inline comment suppression and automatic pydantic field-name whitelisting to vulture.py, remove leaked payload arg from client.py sync, update README with new check docs and inline-ignore usage
This commit is contained in:
@@ -581,9 +581,9 @@ def test_mcp_brand_covers_curated_servers():
|
||||
"google-workspace", "microsoft-365", "slack", "discord",
|
||||
"notion", "airtable", "hubspot", "reddit", "youtube",
|
||||
}
|
||||
from backend.apps.tools_lib.tools_lib import _sanitize_server_name
|
||||
from backend.apps.tools_lib.mcp_config import sanitize_mcp_server_name
|
||||
for slug in curated:
|
||||
assert _sanitize_server_name(slug) == slug, (
|
||||
assert sanitize_mcp_server_name(slug) == slug, (
|
||||
f"curated slug {slug!r} is not in sanitized form"
|
||||
)
|
||||
|
||||
@@ -599,30 +599,30 @@ def test_curated_server_aliases_in_main():
|
||||
|
||||
|
||||
def test_sanitize_server_name_idempotent():
|
||||
"""_sanitize_server_name must be idempotent (sanitize twice = sanitize once)."""
|
||||
from backend.apps.tools_lib.tools_lib import _sanitize_server_name
|
||||
"""sanitize_mcp_server_name must be idempotent (sanitize twice = sanitize once)."""
|
||||
from backend.apps.tools_lib.mcp_config import sanitize_mcp_server_name
|
||||
test_inputs = [
|
||||
"Google Workspace", "Microsoft 365", "Slack", "Discord",
|
||||
"Notion", "Airtable", "HubSpot", "Reddit", "YouTube",
|
||||
"GitHub", "GitLab", "Jira",
|
||||
]
|
||||
for raw in test_inputs:
|
||||
once = _sanitize_server_name(raw)
|
||||
twice = _sanitize_server_name(once)
|
||||
once = sanitize_mcp_server_name(raw)
|
||||
twice = sanitize_mcp_server_name(once)
|
||||
assert once == twice, f"{raw}: sanitize not idempotent ({once} != {twice})"
|
||||
|
||||
|
||||
def test_sanitize_server_name_lowercase():
|
||||
from backend.apps.tools_lib.tools_lib import _sanitize_server_name
|
||||
assert _sanitize_server_name("Gmail") == "gmail"
|
||||
assert _sanitize_server_name("UPPERCASE") == "uppercase"
|
||||
from backend.apps.tools_lib.mcp_config import sanitize_mcp_server_name
|
||||
assert sanitize_mcp_server_name("Gmail") == "gmail"
|
||||
assert sanitize_mcp_server_name("UPPERCASE") == "uppercase"
|
||||
|
||||
|
||||
def test_sanitize_server_name_strips_special_chars():
|
||||
from backend.apps.tools_lib.tools_lib import _sanitize_server_name
|
||||
assert _sanitize_server_name("Foo Bar!") == "foo-bar"
|
||||
assert _sanitize_server_name("@x/y") == "x-y"
|
||||
assert _sanitize_server_name("a__b") == "a-b"
|
||||
from backend.apps.tools_lib.mcp_config import sanitize_mcp_server_name
|
||||
assert sanitize_mcp_server_name("Foo Bar!") == "foo-bar"
|
||||
assert sanitize_mcp_server_name("@x/y") == "x-y"
|
||||
assert sanitize_mcp_server_name("a__b") == "a-b"
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
@@ -635,10 +635,10 @@ def test_mcp_activate_handler_unknown_server():
|
||||
# We test the response shape independently of the FastAPI plumbing.
|
||||
# The handler is a closure inside main.py:mcp_meta_handler, so we
|
||||
# instead exercise the contract: invalid name surfaces alternatives.
|
||||
from backend.apps.tools_lib.tools_lib import _sanitize_server_name
|
||||
from backend.apps.tools_lib.mcp_config import sanitize_mcp_server_name
|
||||
valid = {"gmail", "slack", "google-workspace"}
|
||||
requested = "Gmail" # raw, needs sanitize
|
||||
sanitized = _sanitize_server_name(requested)
|
||||
sanitized = sanitize_mcp_server_name(requested)
|
||||
if sanitized in valid:
|
||||
status = "would_activate"
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user