Merge origin/main into docs/agents-pr-only
CI / Backend (push) Successful in 11s
CI / CLI (push) Successful in 11s

This commit is contained in:
2026-06-04 17:44:34 +02:00
7 changed files with 146 additions and 17 deletions
+30 -2
View File
@@ -43,7 +43,7 @@ def test_transcriptions_returns_generated_artifact(monkeypatch, tmp_path: Path)
lambda prefix="": FakeTemporaryDirectory(tmp_path, prefix, created_paths),
)
def fake_run(command: list[str], check: bool, capture_output: bool, text: bool):
def fake_run(command: list[str], check: bool, capture_output: bool, text: bool, timeout: int):
output_dir = Path(command[command.index("--output_dir") + 1])
(output_dir / "clip.txt").write_text("hello world", encoding="utf-8")
@@ -77,7 +77,7 @@ def test_transcriptions_maps_subprocess_failure(monkeypatch, tmp_path: Path) ->
lambda prefix="": FakeTemporaryDirectory(tmp_path, prefix, created_paths),
)
def fake_run(command: list[str], check: bool, capture_output: bool, text: bool):
def fake_run(command: list[str], check: bool, capture_output: bool, text: bool, timeout: int):
class Result:
returncode = 1
stdout = ""
@@ -97,3 +97,31 @@ def test_transcriptions_maps_subprocess_failure(monkeypatch, tmp_path: Path) ->
assert response.json()["detail"] == "bad whisper day"
assert created_paths
assert all(not path.exists() for path in created_paths)
def test_transcriptions_maps_subprocess_timeout(monkeypatch, tmp_path: Path) -> None:
created_paths: list[Path] = []
monkeypatch.setattr(
server,
"TemporaryDirectory",
lambda prefix="": FakeTemporaryDirectory(tmp_path, prefix, created_paths),
)
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."
)
assert created_paths
assert all(not path.exists() for path in created_paths)