- Add FastAPI routes for surgery start/end, results, pending confirmation (WAV upload), and health checks. - Implement RTSP/Hikvision capture, consumable classification, session manager, MinIO/Baidu voice resolution, and DB persistence. - Add documentation (client API, video backends, staging checklist) and sample camera/RTSP config. - Add pytest suite (API contract, session manager, voice, repositories, pipeline persistence) and httpx dev dependency. - Replace deprecated HTTP_422_UNPROCESSABLE_ENTITY with HTTP_422_UNPROCESSABLE_CONTENT. - Fix SurgeryPipeline DB reads to use an explicit transaction with autobegin disabled. Made-with: Cursor
22 lines
778 B
Python
22 lines
778 B
Python
from app.services.consumable_classifier import PredictionCandidate
|
|
from app.services.video.session_manager import _rank_topk_for_candidates
|
|
|
|
|
|
def test_rank_respects_candidate_order() -> None:
|
|
topk = [
|
|
PredictionCandidate(label="缝线", confidence=0.9),
|
|
PredictionCandidate(label="纱布", confidence=0.5),
|
|
]
|
|
ordered = ["纱布", "缝线"]
|
|
ranked = _rank_topk_for_candidates(topk, ordered)
|
|
assert [c.label for c in ranked] == ["纱布", "缝线"]
|
|
|
|
|
|
def test_rank_without_candidates_keeps_model_order() -> None:
|
|
topk = [
|
|
PredictionCandidate(label="a", confidence=0.9),
|
|
PredictionCandidate(label="b", confidence=0.5),
|
|
]
|
|
ranked = _rank_topk_for_candidates(topk, [])
|
|
assert [c.label for c in ranked] == ["a", "b"]
|