Spaces:
Runtime error
Runtime error
File size: 988 Bytes
732b14f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | """Generation status must never remain stuck on ``generating``."""
from __future__ import annotations
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from app.services.generation import finalize_generation_status_if_stuck, run_generation
@pytest.mark.asyncio
async def test_run_generation_finally_clears_stuck_generating() -> None:
marked: list[str] = []
async def _stuck_finalize(rid: str, tid: str, **kwargs) -> None:
marked.append("finalize")
async def _body(**kwargs) -> None:
return None
with (
patch("app.services.generation._run_generation_body", side_effect=_body),
patch(
"app.services.generation.finalize_generation_status_if_stuck",
side_effect=_stuck_finalize,
),
):
await run_generation(
report_id="r1",
tenant_id="tenant-a",
template_id="D",
bullets=["note"],
)
assert marked == ["finalize"]
|