This commit is contained in:
lda
2026-05-20 23:29:53 +07:00 Verified
parent bc8dc138c7
commit ecfb64691e
36 changed files with 1191 additions and 1368 deletions
+7 -9
View File
@@ -84,15 +84,13 @@ class FakeManager:
metadata: dict[str, Any] | None = None,
enabled: bool = True,
) -> dict[str, Any]:
self.added.append(
{
"connection_id": connection_id,
"server": server,
"account": account,
"metadata": metadata,
"enabled": enabled,
}
)
self.added.append({
"connection_id": connection_id,
"server": server,
"account": account,
"metadata": metadata,
"enabled": enabled,
})
return {"action": "add_connection", "ok": True}
def update_connection(
+10 -12
View File
@@ -32,18 +32,16 @@ def test_load_broker_config_resolves_relative_store_root() -> None:
tmp_path.mkdir(parents=True, exist_ok=True)
config_path = tmp_path / "wf_mcp.config.json"
config_path.write_text(
json.dumps(
{
"store_root": ".broker-store",
"connections": [
{
"id": "demo.personal",
"server": "demo",
"account": "personal",
}
],
}
),
json.dumps({
"store_root": ".broker-store",
"connections": [
{
"id": "demo.personal",
"server": "demo",
"account": "personal",
}
],
}),
encoding="utf-8",
)
+64 -72
View File
@@ -14,27 +14,29 @@ from .test_support import local_temp_root
def _write_config(path: Path) -> None:
path.write_text(
json.dumps(
{
"store_root": ".wf_mcp_store",
"connections": [
{
"id": "demo.personal",
"server": "demo",
"account": "personal",
}
],
}
),
json.dumps({
"store_root": ".wf_mcp_store",
"connections": [
{
"id": "demo.personal",
"server": "demo",
"account": "personal",
}
],
}),
encoding="utf-8",
)
def test_build_parser_accepts_serve_transport() -> None:
parser = build_parser()
args = parser.parse_args(
["--config", "wf_mcp.config.json", "serve", "--transport", "streamable_http"]
)
args = parser.parse_args([
"--config",
"wf_mcp.config.json",
"serve",
"--transport",
"streamable_http",
])
assert args.command == "serve"
assert args.transport == "streamable_http"
@@ -45,17 +47,15 @@ def test_build_parser_accepts_serve_transport() -> None:
def test_build_parser_accepts_proxy_compatibility_flags() -> None:
parser = build_parser()
args = parser.parse_args(
[
"--config",
"wf_mcp.config.json",
"serve",
"--resources-as-tools",
"--prompts-as-tools",
"--search-tools",
"--safe-tool-names",
]
)
args = parser.parse_args([
"--config",
"wf_mcp.config.json",
"serve",
"--resources-as-tools",
"--prompts-as-tools",
"--search-tools",
"--safe-tool-names",
])
assert args.command == "serve"
assert args.resources_as_tools is True
@@ -68,27 +68,23 @@ def test_build_parser_rejects_legacy_mode_flag() -> None:
parser = build_parser()
with pytest.raises(SystemExit):
parser.parse_args(
[
"--config",
"wf_mcp.config.json",
"serve",
"--mode",
"unified",
]
)
parser.parse_args([
"--config",
"wf_mcp.config.json",
"serve",
"--mode",
"unified",
])
def test_build_parser_accepts_no_admin_tools_flag() -> None:
parser = build_parser()
args = parser.parse_args(
[
"--config",
"wf_mcp.config.json",
"serve",
"--no-admin-tools",
]
)
args = parser.parse_args([
"--config",
"wf_mcp.config.json",
"serve",
"--no-admin-tools",
])
assert args.command == "serve"
assert args.admin_tools is False
@@ -158,23 +154,21 @@ def test_load_broker_config_normalizes_typed_stdio_metadata() -> None:
tmp_path.mkdir(parents=True, exist_ok=True)
config_path = tmp_path / "wf_mcp.config.json"
config_path.write_text(
json.dumps(
{
"store_root": ".wf_mcp_store",
"connections": [
{
"id": "demo.personal",
"server": "demo",
"account": "personal",
"metadata": {
"command": "python",
"args": ["server.py"],
"env": {"TOKEN": "secret"},
},
}
],
}
),
json.dumps({
"store_root": ".wf_mcp_store",
"connections": [
{
"id": "demo.personal",
"server": "demo",
"account": "personal",
"metadata": {
"command": "python",
"args": ["server.py"],
"env": {"TOKEN": "secret"},
},
}
],
}),
encoding="utf-8",
)
@@ -194,18 +188,16 @@ def test_load_broker_config_rejects_bad_metadata_shape() -> None:
tmp_path.mkdir(parents=True, exist_ok=True)
config_path = tmp_path / "wf_mcp.config.json"
config_path.write_text(
json.dumps(
{
"connections": [
{
"id": "demo.personal",
"server": "demo",
"account": "personal",
"metadata": {"transport": "stdio", "args": "server.py"},
}
],
}
),
json.dumps({
"connections": [
{
"id": "demo.personal",
"server": "demo",
"account": "personal",
"metadata": {"transport": "stdio", "args": "server.py"},
}
],
}),
encoding="utf-8",
)
+23 -31
View File
@@ -389,19 +389,17 @@ def test_proxy_admin_tools_mutate_config_file() -> None:
tmp_path.mkdir(parents=True, exist_ok=True)
config_path = tmp_path / "wf_mcp.config.json"
config_path.write_text(
json.dumps(
{
"store_root": ".wf_mcp_store",
"connections": [
{
"id": "fixture.personal",
"server": "fixture",
"account": "personal",
"enabled": False,
}
],
}
),
json.dumps({
"store_root": ".wf_mcp_store",
"connections": [
{
"id": "fixture.personal",
"server": "fixture",
"account": "personal",
"enabled": False,
}
],
}),
encoding="utf-8",
)
config = load_broker_config(config_path)
@@ -486,12 +484,10 @@ def test_proxy_admin_reload_remounts_connections() -> None:
tmp_path.mkdir(parents=True, exist_ok=True)
config_path = tmp_path / "wf_mcp.config.json"
config_path.write_text(
json.dumps(
{
"store_root": ".wf_mcp_store",
"connections": [],
}
),
json.dumps({
"store_root": ".wf_mcp_store",
"connections": [],
}),
encoding="utf-8",
)
config = load_broker_config(config_path)
@@ -548,12 +544,10 @@ def test_proxy_admin_reload_sends_list_changed_notifications() -> None:
tmp_path.mkdir(parents=True, exist_ok=True)
config_path = tmp_path / "wf_mcp.config.json"
config_path.write_text(
json.dumps(
{
"store_root": ".wf_mcp_store",
"connections": [],
}
),
json.dumps({
"store_root": ".wf_mcp_store",
"connections": [],
}),
encoding="utf-8",
)
config = load_broker_config(config_path)
@@ -582,12 +576,10 @@ def test_proxy_config_mutation_does_not_notify_before_reload() -> None:
tmp_path.mkdir(parents=True, exist_ok=True)
config_path = tmp_path / "wf_mcp.config.json"
config_path.write_text(
json.dumps(
{
"store_root": ".wf_mcp_store",
"connections": [],
}
),
json.dumps({
"store_root": ".wf_mcp_store",
"connections": [],
}),
encoding="utf-8",
)
config = load_broker_config(config_path)
+6 -8
View File
@@ -65,11 +65,9 @@ def test_rewrites_resource_links_inside_call_tool_result() -> None:
def _resource_link(uri: str) -> mcp_types.ResourceLink:
"""Build ResourceLink through validation because Pydantic accepts URI strings."""
return mcp_types.ResourceLink.model_validate(
{
"type": "resource_link",
"name": "dynamic-text",
"uri": uri,
"mimeType": "text/plain",
}
)
return mcp_types.ResourceLink.model_validate({
"type": "resource_link",
"name": "dynamic-text",
"uri": uri,
"mimeType": "text/plain",
})
+16 -18
View File
@@ -526,24 +526,22 @@ def test_server_reload_syncs_service_connection_source_enabled_state() -> None:
tmp_path.mkdir(parents=True, exist_ok=True)
config_path = tmp_path / "wf_mcp.config.json"
config_path.write_text(
json.dumps(
{
"store_root": ".wf_mcp_store",
"connections": [
{
"id": "fixture.personal",
"server": "fixture",
"account": "personal",
"enabled": False,
"metadata": {
"transport": "stdio",
"command": sys.executable,
"args": [fixture_server_path()],
},
}
],
}
),
json.dumps({
"store_root": ".wf_mcp_store",
"connections": [
{
"id": "fixture.personal",
"server": "fixture",
"account": "personal",
"enabled": False,
"metadata": {
"transport": "stdio",
"command": sys.executable,
"args": [fixture_server_path()],
},
}
],
}),
encoding="utf-8",
)
config = load_broker_config(config_path)