From 06af85fbe0d28a40816d99001cdd559ca0984afc Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Fri, 30 Oct 2026 08:48:27 -0700 Subject: [PATCH] test(proxy): mark the remaining new websocket test variables Final Builds the logging mocks with model_call_details in the constructor instead of setting it afterwards. --- .../test_openai_websocket_passthrough_logging_handler.py | 3 +-- .../pass_through_endpoints/test_pass_through_endpoints.py | 6 +++--- .../proxy/pass_through_endpoints/test_success_handler.py | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/unit/proxy/pass_through_endpoints/llm_provider_handlers/test_openai_websocket_passthrough_logging_handler.py b/tests/unit/proxy/pass_through_endpoints/llm_provider_handlers/test_openai_websocket_passthrough_logging_handler.py index 1bc4e0fe4d2..6d2e22fbfcd 100644 --- a/tests/unit/proxy/pass_through_endpoints/llm_provider_handlers/test_openai_websocket_passthrough_logging_handler.py +++ b/tests/unit/proxy/pass_through_endpoints/llm_provider_handlers/test_openai_websocket_passthrough_logging_handler.py @@ -23,8 +23,7 @@ SESSION_START: Final = datetime(2026, 1, 1, 12, 0, 0) def _logging_obj() -> MagicMock: - logging_obj = MagicMock() - logging_obj.model_call_details = {} + logging_obj: Final = MagicMock(model_call_details={}) return logging_obj diff --git a/tests/unit/proxy/pass_through_endpoints/test_pass_through_endpoints.py b/tests/unit/proxy/pass_through_endpoints/test_pass_through_endpoints.py index 9f97110e1af..2903b3a1ac2 100644 --- a/tests/unit/proxy/pass_through_endpoints/test_pass_through_endpoints.py +++ b/tests/unit/proxy/pass_through_endpoints/test_pass_through_endpoints.py @@ -8056,7 +8056,7 @@ async def test_websocket_passthrough_still_bills_a_session_the_client_walked_out REALTIME_RESPONSE_DONE, json.dumps({"type": "response.output_text.delta", "delta": "too late"}), ) - websocket = _client_websocket(_pending_receive) + websocket: Final = _client_websocket(_pending_receive) websocket.send_text = AsyncMock(side_effect=[None, None, WebSocketDisconnect(code=1006)]) with ( @@ -8136,7 +8136,7 @@ def _turn_taking_client( frame: Final = next(script, None) return {"type": "websocket.disconnect"} if frame is None else _received_frame(frame) - websocket = _client_websocket(receive) + websocket: Final = _client_websocket(receive) async def send_text(text: str) -> None: if websocket.application_state == WebSocketState.DISCONNECTED: @@ -8529,7 +8529,7 @@ async def test_websocket_passthrough_bills_the_turn_a_client_walked_out_of_once_ client_left: Final = asyncio.Event() send_failed: Final = asyncio.Event() - client = _turn_taking_client( + client: Final = _turn_taking_client( [json.dumps({"type": "response.create", "model": "gpt-5.4"})], answered_by='"response.created"' ) receive: Final = client.receive diff --git a/tests/unit/proxy/pass_through_endpoints/test_success_handler.py b/tests/unit/proxy/pass_through_endpoints/test_success_handler.py index 988828f48de..2e2446b8ecf 100644 --- a/tests/unit/proxy/pass_through_endpoints/test_success_handler.py +++ b/tests/unit/proxy/pass_through_endpoints/test_success_handler.py @@ -668,8 +668,7 @@ REALTIME_FRAMES: Final = [ def _normalize(url_route: str, response_body: dict[str, object] | list[dict[str, object]]) -> dict: - logging_obj = MagicMock() - logging_obj.model_call_details = {} + logging_obj: Final = MagicMock(model_call_details={}) return PassThroughEndpointLogging().normalize_llm_passthrough_logging_payload( httpx_response=MagicMock(spec=httpx.Response), response_body=response_body,