test: mock uvicorn.run in streamable-http start test (CORS app path)
build-image / test (push) Successful in 22s
build-image / build (push) Successful in 26s

This commit is contained in:
2026-07-06 22:20:36 -04:00
parent 5f2c55c865
commit f080e0847f
+8 -2
View File
@@ -61,10 +61,16 @@ def test_start_server_stdio():
m.run.assert_called_once_with()
def test_start_server_streamable_http():
def test_start_server_streamable_http(monkeypatch):
m = _mock_mcp()
calls = {}
monkeypatch.setattr("uvicorn.run", lambda app, **kw: calls.update(app=app, kw=kw))
server_setup.start_server(m, TransportAliases.STREAMABLE_HTTP)
m.run.assert_called_once_with(transport="streamable-http")
# builds the app, adds CORS middleware, and serves it via uvicorn
m.streamable_http_app.assert_called_once_with()
m.streamable_http_app.return_value.add_middleware.assert_called_once()
assert calls["app"] is m.streamable_http_app.return_value
assert calls["kw"]["host"] == "0.0.0.0" and calls["kw"]["port"] == 8080
def test_start_server_sse_uses_mount_path(monkeypatch):