test: cover mcp config rpc server path

This commit is contained in:
lda
2026-06-04 23:42:40 +07:00 Verified
parent 0cbed1cfdd
commit 0ab609aa1c
+34
View File
@@ -183,3 +183,37 @@ def test_rpc_server_cli_rejects_mcp_config_with_store_root(tmp_path) -> None:
assert result.exit_code != 0
assert "--mcp-config cannot be combined with --store-root" in result.output
def test_rpc_server_cli_mcp_config_builds_registry_capable_server(monkeypatch, tmp_path) -> None:
config_path = tmp_path / "wf_mcp.config.json"
config_path.write_text(
json.dumps(
{
"store_root": str(tmp_path / "store"),
"connections": [],
}
),
encoding="utf-8",
)
captured: dict[str, object] = {}
def fake_create_rpc_app(server, *, rpc_path="/rpc"):
captured["source_registry_admin"] = server.source_registry_admin
captured["rpc_path"] = rpc_path
return object()
def fake_uvicorn_run(app_obj, *, host, port, access_log):
captured["host"] = host
captured["port"] = port
monkeypatch.setattr("wf_transport_rpc_http.cli.create_rpc_app", fake_create_rpc_app)
monkeypatch.setattr("wf_transport_rpc_http.cli.uvicorn.run", fake_uvicorn_run)
result = CliRunner().invoke(app, ["--mcp-config", str(config_path)])
assert result.exit_code == 0, result.output
assert captured["source_registry_admin"] is not None
assert captured["rpc_path"] == "/rpc"
assert captured["host"] == "127.0.0.1"
assert captured["port"] == 8765