4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
"""Tests for shared MCP integration source param parsers."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from core.tool_framework.utils.mcp_params import first_list, first_string, string_list
|
|
|
|
|
|
def test_string_list_returns_empty_for_non_list() -> None:
|
|
assert string_list("not-a-list") == []
|
|
assert string_list(None) == []
|
|
assert string_list({}) == []
|
|
|
|
|
|
def test_string_list_strips_and_drops_blank_entries() -> None:
|
|
assert string_list([" alpha ", "", " ", "beta"]) == ["alpha", "beta"]
|
|
|
|
|
|
def test_string_list_coerces_non_string_items() -> None:
|
|
assert string_list([123, " ok "]) == ["123", "ok"]
|
|
|
|
|
|
def test_first_string_returns_first_non_empty_key_in_order() -> None:
|
|
source = {"url": "https://example.com", "posthog_url": "https://ignored.example.com"}
|
|
assert first_string(source, "posthog_url", "url") == "https://ignored.example.com"
|
|
assert first_string(source, "missing", "url") == "https://example.com"
|
|
|
|
|
|
def test_first_string_skips_whitespace_only_values() -> None:
|
|
source = {"url": " ", "mode": "stdio"}
|
|
assert first_string(source, "url", "mode") == "stdio"
|
|
|
|
|
|
def test_first_string_returns_none_when_no_match() -> None:
|
|
assert first_string({}, "url", "mode") is None
|
|
|
|
|
|
def test_first_string_coerces_values_to_string() -> None:
|
|
assert first_string({"port": 443}, "port") == "443"
|
|
|
|
|
|
def test_first_list_returns_first_non_empty_list_in_order() -> None:
|
|
source = {"args": [], "openclaw_args": ["mcp", "serve"]}
|
|
assert first_list(source, "args", "openclaw_args") == ["mcp", "serve"]
|
|
|
|
|
|
def test_first_list_skips_invalid_or_empty_lists() -> None:
|
|
source = {"args": "not-a-list", "openclaw_args": [" ", ""]}
|
|
assert first_list(source, "args", "openclaw_args") == []
|
|
|
|
|
|
def test_first_list_normalizes_entries() -> None:
|
|
source = {"args": [" mcp ", "serve"]}
|
|
assert first_list(source, "args") == ["mcp", "serve"]
|