Handle CLI request errors and backend whisper timeout
Some checks failed
CI / Backend (pull_request) Failing after 15s
CI / CLI (pull_request) Successful in 28s

This commit is contained in:
2026-05-27 13:08:56 +00:00
parent 44af756bd3
commit 1c6415d306
4 changed files with 67 additions and 10 deletions

View File

@@ -64,3 +64,22 @@ def test_transcriptions_maps_subprocess_failure(monkeypatch) -> None:
assert response.status_code == 502
assert response.json()["detail"] == "bad whisper day"
def test_transcriptions_maps_subprocess_timeout(monkeypatch) -> None:
def fake_run(command: list[str], check: bool, capture_output: bool, text: bool, timeout: int):
raise server.subprocess.TimeoutExpired(cmd=command, timeout=timeout)
monkeypatch.setattr(server.subprocess, "run", fake_run)
response = client.post(
"/transcriptions",
data={"model": "base", "output_format": "txt"},
files={"file": ("clip.wav", b"audio", "audio/wav")},
)
assert response.status_code == 504
assert (
response.json()["detail"]
== f"Whisper CLI timed out after {server.WHISPER_PROCESS_TIMEOUT_SECONDS}s and was terminated."
)