"""resolve 路径中 confirmation_id 的 URL 编码(与浏览器 / 历史客户端行为一致)。""" from __future__ import annotations from urllib.parse import quote, urljoin import httpx def test_post_resolve_url_encodes_confirmation_id() -> None: captured: dict = {} def handler(request: httpx.Request) -> httpx.Response: captured["url"] = str(request.url) return httpx.Response(200, json={"status": "accepted"}) transport = httpx.MockTransport(handler) base = "http://example.test:8080/" cid = "c/id+here" path = f"client/surgeries/123456/pending-confirmation/{quote(cid, safe='')}/resolve" url = urljoin(base, path) with httpx.Client(transport=transport) as client: r = client.post(url, files={"audio": ("voice.wav", b"RIFF....", "audio/wav")}) assert r.status_code == 200 assert captured["url"].endswith( "/client/surgeries/123456/pending-confirmation/c%2Fid%2Bhere/resolve" ) def test_pending_payload_field_names_match_contract() -> None: raw = { "surgery_id": "123456", "confirmation_id": "abc", "pending_queue_length": 1, "pending_queue_position": 1, "pending_cumulative_ordinal": 1, "prompt_text": "请确认", "prompt_audio_mp3_base64": "AA", "options": [{"label": "纱布", "confidence": 0.4}], "model_top1_label": "x", "model_top1_confidence": 0.41, "created_at": "2026-01-01T00:00:00+00:00", } assert raw["confirmation_id"] == "abc" assert raw["prompt_text"] == "请确认"