build: complete upgrade to fastapi 0.141, mcp sdk v2, fastmcp 4 and httpx2
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import httpx
|
||||
import httpx2
|
||||
|
||||
from wf_mcp.broker.server import build_workflow_server_from_config
|
||||
from wf_mcp.models import AuthRecord, BrokerConfig
|
||||
@@ -17,9 +17,9 @@ async def test_rpc_lists_auth_records(tmp_path) -> None:
|
||||
)
|
||||
)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(url="http://test/rpc", http_client=http_client)
|
||||
@@ -44,9 +44,9 @@ async def test_rpc_inspects_auth_record(tmp_path) -> None:
|
||||
)
|
||||
)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(url="http://test/rpc", http_client=http_client)
|
||||
@@ -62,9 +62,9 @@ async def test_rpc_saves_auth_record_without_returning_payload(tmp_path) -> None
|
||||
config = BrokerConfig(store_root=store.root, connections=[])
|
||||
server = build_workflow_server_from_config(config)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(url="http://test/rpc", http_client=http_client)
|
||||
@@ -92,9 +92,9 @@ async def test_rpc_deletes_auth_record(tmp_path) -> None:
|
||||
config = BrokerConfig(store_root=store.root, connections=[])
|
||||
server = build_workflow_server_from_config(config)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(url="http://test/rpc", http_client=http_client)
|
||||
|
||||
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
import json
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
import httpx2
|
||||
import pytest
|
||||
from pydantic import TypeAdapter
|
||||
|
||||
@@ -33,9 +33,10 @@ from wf_transport_rpc_http.client.sources import RpcSourceAdminClientMixin
|
||||
|
||||
|
||||
async def test_rpc_client_preserves_structured_jsonrpc_error() -> None:
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
|
||||
def handler(request: httpx2.Request) -> httpx2.Response:
|
||||
request_id = json.loads(request.content)["id"]
|
||||
return httpx.Response(
|
||||
return httpx2.Response(
|
||||
200,
|
||||
json={
|
||||
"jsonrpc": "2.0",
|
||||
@@ -48,7 +49,7 @@ async def test_rpc_client_preserves_structured_jsonrpc_error() -> None:
|
||||
},
|
||||
)
|
||||
|
||||
http_client = httpx.AsyncClient(transport=httpx.MockTransport(handler))
|
||||
http_client = httpx2.AsyncClient(transport=httpx2.MockTransport(handler))
|
||||
async with http_client:
|
||||
client = RpcWorkflowApiClient(url="http://test/rpc", http_client=http_client)
|
||||
with pytest.raises(RpcProtocolError) as raised:
|
||||
@@ -72,7 +73,8 @@ async def test_rpc_client_rejects_malformed_response_envelope(
|
||||
jsonrpc: str | None,
|
||||
response_id: str,
|
||||
) -> None:
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
|
||||
def handler(request: httpx2.Request) -> httpx2.Response:
|
||||
request_id = json.loads(request.content)["id"]
|
||||
payload: dict[str, object] = {
|
||||
"id": request_id if response_id == "echo" else response_id,
|
||||
@@ -80,9 +82,11 @@ async def test_rpc_client_rejects_malformed_response_envelope(
|
||||
}
|
||||
if jsonrpc is not None:
|
||||
payload["jsonrpc"] = jsonrpc
|
||||
return httpx.Response(200, json=payload)
|
||||
return httpx2.Response(200, json=payload)
|
||||
|
||||
async with httpx.AsyncClient(transport=httpx.MockTransport(handler)) as http_client:
|
||||
async with httpx2.AsyncClient(
|
||||
transport=httpx2.MockTransport(handler)
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(url="http://test/rpc", http_client=http_client)
|
||||
with pytest.raises(RuntimeError, match="JSON-RPC response"):
|
||||
await client.list_capabilities()
|
||||
@@ -139,8 +143,8 @@ def _constant_plan() -> RawWorkflowPlan:
|
||||
async def test_rpc_workflow_client_lists_and_inspects_capabilities(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store")
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport,
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
@@ -169,8 +173,8 @@ async def test_rpc_workflow_client_lists_and_inspects_capabilities(tmp_path) ->
|
||||
async def test_rpc_workflow_client_lists_and_inspects_sources(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store")
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport,
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
@@ -195,8 +199,8 @@ async def test_rpc_workflow_client_reads_admin_state(tmp_path) -> None:
|
||||
payload={"ok": True},
|
||||
)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport,
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
@@ -235,8 +239,8 @@ async def test_rpc_workflow_client_runs_and_reads_trace(tmp_path) -> None:
|
||||
}
|
||||
)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport,
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
@@ -269,8 +273,8 @@ async def test_rpc_workflow_client_runs_and_reads_trace(tmp_path) -> None:
|
||||
async def test_rpc_workflow_client_raises_for_rpc_error(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store")
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport,
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
@@ -301,8 +305,8 @@ async def test_rpc_workflow_client_lists_and_inspects_artifacts(tmp_path) -> Non
|
||||
source_bindings={},
|
||||
)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(
|
||||
@@ -336,8 +340,8 @@ async def test_rpc_workflow_client_lists_inspects_validates_and_deletes_deployme
|
||||
}
|
||||
)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(
|
||||
@@ -363,8 +367,8 @@ async def test_rpc_workflow_client_lists_inspects_validates_and_deletes_deployme
|
||||
async def test_rpc_workflow_client_draft_workspace_lifecycle(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store", drafts=True)
|
||||
app = create_rpc_app(server, drafts=True)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(
|
||||
@@ -559,8 +563,8 @@ async def test_rpc_client_sends_exact_replace_document_payload() -> None:
|
||||
async def test_rpc_client_builds_capability_free_draft_lifecycle(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store", drafts=True)
|
||||
app = create_rpc_app(server, drafts=True)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport,
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
@@ -623,8 +627,8 @@ def test_rpc_client_satisfies_draft_surface_static_shape() -> None:
|
||||
async def test_rpc_workflow_client_deletes_draft_workspace(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store", drafts=True)
|
||||
app = create_rpc_app(server, drafts=True)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(
|
||||
@@ -656,8 +660,8 @@ async def test_rpc_workflow_client_deletes_artifact(tmp_path) -> None:
|
||||
)
|
||||
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(
|
||||
@@ -694,8 +698,8 @@ async def test_rpc_client_lists_runs(tmp_path) -> None:
|
||||
)
|
||||
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport,
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
@@ -715,8 +719,8 @@ async def test_rpc_client_lists_runs(tmp_path) -> None:
|
||||
async def test_rpc_client_creates_artifact_from_plan(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store")
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport,
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
@@ -745,8 +749,8 @@ async def test_rpc_client_creates_artifact_from_plan(tmp_path) -> None:
|
||||
async def test_rpc_client_validates_artifact_plan_without_persisting(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store")
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(
|
||||
@@ -770,8 +774,8 @@ async def test_rpc_client_validates_artifact_plan_without_persisting(tmp_path) -
|
||||
async def test_rpc_client_set_workflow_output_map(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store", drafts=True)
|
||||
app = create_rpc_app(server, drafts=True)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(
|
||||
@@ -805,8 +809,8 @@ async def test_rpc_client_set_workflow_output_map(tmp_path) -> None:
|
||||
async def test_rpc_client_draft_workspace_focused_edit_methods(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store", drafts=True)
|
||||
app = create_rpc_app(server, drafts=True)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(
|
||||
@@ -1067,8 +1071,8 @@ async def test_rpc_client_draft_remove_methods(tmp_path) -> None:
|
||||
async def test_rpc_client_draft_workspace_add_step_from_capability(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store", drafts=True)
|
||||
app = create_rpc_app(server, drafts=True)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(
|
||||
|
||||
@@ -5,7 +5,7 @@ from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any, cast
|
||||
|
||||
import httpx
|
||||
import httpx2
|
||||
import pytest
|
||||
from mcp.client.session import ClientSession
|
||||
from mcp.types import (
|
||||
@@ -105,7 +105,7 @@ def _interrupt_plan() -> RawWorkflowPlan:
|
||||
)
|
||||
|
||||
|
||||
async def _rpc(client: httpx.AsyncClient, method: str, params: dict) -> dict:
|
||||
async def _rpc(client: httpx2.AsyncClient, method: str, params: dict) -> dict:
|
||||
response = await client.post(
|
||||
"/rpc",
|
||||
json={"jsonrpc": "2.0", "id": "test", "method": method, "params": params},
|
||||
@@ -131,8 +131,8 @@ class _CountingMcpClient:
|
||||
name="counter",
|
||||
title="Counter",
|
||||
description="Increment a session-local counter.",
|
||||
inputSchema={"type": "object", "properties": {}},
|
||||
outputSchema={
|
||||
input_schema={"type": "object", "properties": {}},
|
||||
output_schema={
|
||||
"type": "object",
|
||||
"properties": {"count": {"type": "integer"}},
|
||||
},
|
||||
@@ -151,7 +151,7 @@ class _CountingMcpClient:
|
||||
self.count += 1
|
||||
return CallToolResult(
|
||||
content=[TextContent(type="text", text=str(self.count))],
|
||||
structuredContent={"count": self.count},
|
||||
structured_content={"count": self.count},
|
||||
)
|
||||
|
||||
async def list_resources(self) -> ListResourcesResult:
|
||||
@@ -233,9 +233,9 @@ async def test_mcp_backed_rpc_lists_and_mutates_source_registry(tmp_path) -> Non
|
||||
)
|
||||
server = build_workflow_server_from_config(config)
|
||||
app = create_rpc_app(server, drafts=True)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(
|
||||
@@ -256,9 +256,9 @@ async def test_mcp_backed_rpc_capability_list_filters_by_source(tmp_path) -> Non
|
||||
config = BrokerConfig(store_root=tmp_path / "store", connections=[])
|
||||
server = build_workflow_server_from_config(config)
|
||||
app = create_rpc_app(server, drafts=True)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(
|
||||
@@ -286,9 +286,9 @@ async def test_mcp_backed_rpc_reports_connections_and_events(tmp_path) -> None:
|
||||
)
|
||||
server = build_workflow_server_from_config(config)
|
||||
app = create_rpc_app(server, drafts=True)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
connections = await _rpc(http_client, "workflow.admin.connections.list", {})
|
||||
@@ -301,8 +301,8 @@ async def test_mcp_backed_rpc_applies_source_registry_changes(tmp_path) -> None:
|
||||
server = build_workflow_server_from_config(config)
|
||||
app = create_rpc_app(server, drafts=True)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
transport=httpx.ASGITransport(app=app),
|
||||
async with httpx2.AsyncClient(
|
||||
transport=httpx2.ASGITransport(app=app),
|
||||
base_url="http://test",
|
||||
) as client:
|
||||
await _rpc(
|
||||
@@ -369,9 +369,9 @@ async def test_mcp_backed_rpc_can_be_built_from_neutral_workflow_config(
|
||||
)
|
||||
server = build_workflow_server_from_workflow_config(workflow_config)
|
||||
app = create_rpc_app(server, drafts=True)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
connections = await _rpc(http_client, "workflow.admin.connections.list", {})
|
||||
@@ -407,8 +407,8 @@ async def test_mcp_backed_rpc_resumes_interrupted_run_after_server_rebuild(
|
||||
"bindings": [],
|
||||
}
|
||||
)
|
||||
async with httpx.AsyncClient(
|
||||
transport=httpx.ASGITransport(app=create_rpc_app(first_server, drafts=True)),
|
||||
async with httpx2.AsyncClient(
|
||||
transport=httpx2.ASGITransport(app=create_rpc_app(first_server, drafts=True)),
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
first_client = RpcWorkflowApiClient(
|
||||
@@ -432,8 +432,8 @@ async def test_mcp_backed_rpc_resumes_interrupted_run_after_server_rebuild(
|
||||
assert interrupt["resume_schema"]["required"] == ["approved"]
|
||||
|
||||
rebuilt_server = build_workflow_server_from_workflow_config(workflow_config)
|
||||
async with httpx.AsyncClient(
|
||||
transport=httpx.ASGITransport(app=create_rpc_app(rebuilt_server, drafts=True)),
|
||||
async with httpx2.AsyncClient(
|
||||
transport=httpx2.ASGITransport(app=create_rpc_app(rebuilt_server, drafts=True)),
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
rebuilt_client = RpcWorkflowApiClient(
|
||||
@@ -462,8 +462,8 @@ async def test_mcp_backed_rpc_workflow_reuses_runtime_session_across_runs(
|
||||
assert len(factory.clients) == 1
|
||||
assert factory.created_connections[0].id == "fixture.default"
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
transport=httpx.ASGITransport(app=create_rpc_app(server, drafts=True)),
|
||||
async with httpx2.AsyncClient(
|
||||
transport=httpx2.ASGITransport(app=create_rpc_app(server, drafts=True)),
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(url="http://test/rpc", http_client=http_client)
|
||||
@@ -596,8 +596,8 @@ async def test_mcp_backed_rpc_workflow_reuses_runtime_session_direct_setup(
|
||||
}
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
transport=httpx.ASGITransport(app=create_rpc_app(server, drafts=True)),
|
||||
async with httpx2.AsyncClient(
|
||||
transport=httpx2.ASGITransport(app=create_rpc_app(server, drafts=True)),
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(url="http://test/rpc", http_client=http_client)
|
||||
@@ -695,8 +695,8 @@ async def test_mcp_backed_rpc_deployment_becomes_unrunnable_after_source_removed
|
||||
}
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
transport=httpx.ASGITransport(app=create_rpc_app(server, drafts=True)),
|
||||
async with httpx2.AsyncClient(
|
||||
transport=httpx2.ASGITransport(app=create_rpc_app(server, drafts=True)),
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(url="http://test/rpc", http_client=http_client)
|
||||
@@ -747,8 +747,8 @@ async def test_mcp_backed_rpc_workflow_reuses_real_stdio_fixture_session(
|
||||
source_registry_store=FileSourceRegistryStore(config.store_root),
|
||||
)
|
||||
|
||||
async with httpx.AsyncClient(
|
||||
transport=httpx.ASGITransport(app=create_rpc_app(server, drafts=True)),
|
||||
async with httpx2.AsyncClient(
|
||||
transport=httpx2.ASGITransport(app=create_rpc_app(server, drafts=True)),
|
||||
base_url="http://test",
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(url="http://test/rpc", http_client=http_client)
|
||||
|
||||
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass, replace
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
import httpx2
|
||||
|
||||
from wf_api import WorkflowSourceRegistryApi
|
||||
from wf_server import build_local_static_workflow_server
|
||||
@@ -80,7 +80,7 @@ class FakeMutationProvider:
|
||||
return {"removed": True, "source_id": source_id}
|
||||
|
||||
|
||||
async def _rpc(client: httpx.AsyncClient, method: str, params: dict) -> dict:
|
||||
async def _rpc(client: httpx2.AsyncClient, method: str, params: dict) -> dict:
|
||||
response = await client.post(
|
||||
"/rpc",
|
||||
json={"jsonrpc": "2.0", "id": "test", "method": method, "params": params},
|
||||
@@ -105,8 +105,10 @@ def _server_with_mutation_provider(tmp_path: Any) -> Any:
|
||||
async def test_rpc_source_registry_list_unavailable_on_local_static(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store")
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client, "workflow.admin.source_registry.list", {"limit": 10}
|
||||
)
|
||||
@@ -120,8 +122,10 @@ async def test_rpc_source_registry_inspect_unavailable_on_local_static(
|
||||
) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store")
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.inspect",
|
||||
@@ -140,8 +144,10 @@ async def test_rpc_source_registry_methods_return_registry_payloads(tmp_path) ->
|
||||
),
|
||||
)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
listed = await _rpc(
|
||||
client, "workflow.admin.source_registry.list", {"limit": 10}
|
||||
)
|
||||
@@ -165,8 +171,10 @@ async def test_rpc_source_registry_methods_return_registry_payloads(tmp_path) ->
|
||||
async def test_rpc_source_registry_add_unavailable_on_local_static(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store")
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.add",
|
||||
@@ -180,8 +188,10 @@ async def test_rpc_source_registry_add_unavailable_on_local_static(tmp_path) ->
|
||||
async def test_rpc_source_registry_update_unavailable_on_local_static(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store")
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.update",
|
||||
@@ -195,8 +205,10 @@ async def test_rpc_source_registry_update_unavailable_on_local_static(tmp_path)
|
||||
async def test_rpc_source_registry_enable_unavailable_on_local_static(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store")
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.enable",
|
||||
@@ -212,8 +224,10 @@ async def test_rpc_source_registry_disable_unavailable_on_local_static(
|
||||
) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store")
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.disable",
|
||||
@@ -227,8 +241,10 @@ async def test_rpc_source_registry_disable_unavailable_on_local_static(
|
||||
async def test_rpc_source_registry_remove_unavailable_on_local_static(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store")
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.remove",
|
||||
@@ -245,8 +261,10 @@ async def test_rpc_source_registry_remove_unavailable_on_local_static(tmp_path)
|
||||
async def test_rpc_source_registry_add_returns_entry(tmp_path) -> None:
|
||||
server = _server_with_mutation_provider(tmp_path)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.add",
|
||||
@@ -271,8 +289,10 @@ async def test_rpc_source_registry_add_returns_entry(tmp_path) -> None:
|
||||
async def test_rpc_source_registry_update_returns_entry(tmp_path) -> None:
|
||||
server = _server_with_mutation_provider(tmp_path)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.update",
|
||||
@@ -295,8 +315,10 @@ async def test_rpc_source_registry_enable_returns_entry(tmp_path) -> None:
|
||||
),
|
||||
)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.enable",
|
||||
@@ -310,8 +332,10 @@ async def test_rpc_source_registry_enable_returns_entry(tmp_path) -> None:
|
||||
async def test_rpc_source_registry_disable_returns_entry(tmp_path) -> None:
|
||||
server = _server_with_mutation_provider(tmp_path)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.disable",
|
||||
@@ -325,8 +349,10 @@ async def test_rpc_source_registry_disable_returns_entry(tmp_path) -> None:
|
||||
async def test_rpc_source_registry_remove_returns_removed(tmp_path) -> None:
|
||||
server = _server_with_mutation_provider(tmp_path)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.remove",
|
||||
@@ -344,8 +370,10 @@ async def test_rpc_source_registry_remove_returns_removed(tmp_path) -> None:
|
||||
async def test_rpc_source_registry_add_missing_entry_raises_error(tmp_path) -> None:
|
||||
server = _server_with_mutation_provider(tmp_path)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.add",
|
||||
@@ -358,8 +386,10 @@ async def test_rpc_source_registry_add_missing_entry_raises_error(tmp_path) -> N
|
||||
async def test_rpc_source_registry_update_missing_source_raises_error(tmp_path) -> None:
|
||||
server = _server_with_mutation_provider(tmp_path)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.update",
|
||||
@@ -372,8 +402,10 @@ async def test_rpc_source_registry_update_missing_source_raises_error(tmp_path)
|
||||
async def test_rpc_source_registry_remove_missing_source_raises_error(tmp_path) -> None:
|
||||
server = _server_with_mutation_provider(tmp_path)
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
client,
|
||||
"workflow.admin.source_registry.remove",
|
||||
@@ -389,8 +421,8 @@ async def test_rpc_source_registry_remove_missing_source_raises_error(tmp_path)
|
||||
async def test_rpc_client_source_registry_calls_correct_methods(tmp_path) -> None:
|
||||
server = build_local_static_workflow_server(tmp_path / "store")
|
||||
app = create_rpc_app(server)
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
async with httpx.AsyncClient(
|
||||
transport = httpx2.ASGITransport(app=app)
|
||||
async with httpx2.AsyncClient(
|
||||
transport=transport, base_url="http://test"
|
||||
) as http_client:
|
||||
client = RpcWorkflowApiClient(
|
||||
@@ -466,8 +498,8 @@ async def test_rpc_client_source_registry_mutation_methods_exist() -> None:
|
||||
|
||||
async def test_rpc_source_registry_apply_unavailable_on_local_static(tmp_path) -> None:
|
||||
app = create_rpc_app(build_local_static_workflow_server(tmp_path / "store"))
|
||||
async with httpx.AsyncClient(
|
||||
transport=httpx.ASGITransport(app=app),
|
||||
async with httpx2.AsyncClient(
|
||||
transport=httpx2.ASGITransport(app=app),
|
||||
base_url="http://test",
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
@@ -506,8 +538,8 @@ async def test_rpc_source_registry_apply_returns_summary(tmp_path) -> None:
|
||||
source_registry_admin=admin,
|
||||
)
|
||||
app = create_rpc_app(server)
|
||||
async with httpx.AsyncClient(
|
||||
transport=httpx.ASGITransport(app=app),
|
||||
async with httpx2.AsyncClient(
|
||||
transport=httpx2.ASGITransport(app=app),
|
||||
base_url="http://test",
|
||||
) as client:
|
||||
payload = await _rpc(
|
||||
|
||||
Reference in New Issue
Block a user