generated from john/python-template
This commit is contained in:
@@ -10,6 +10,8 @@ from sqlalchemy import text
|
||||
from transcription.config import Settings
|
||||
from transcription.db.models import MaintenanceJobType
|
||||
from transcription.db.models import MaintenanceRunStatus
|
||||
from transcription.errors import ErrorCategory
|
||||
from transcription.services.maintenance import MaintenanceError
|
||||
from transcription.services.maintenance import MaintenanceExecution
|
||||
from transcription.services.maintenance import MaintenanceService
|
||||
|
||||
@@ -61,15 +63,12 @@ async def test_process_next_queued_run_persists_terminal_result(
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_runs_recreates_missing_table(default_session_factory, default_settings):
|
||||
async def test_list_runs_raises_when_table_is_missing(default_session_factory, default_settings):
|
||||
service = MaintenanceService(session_factory=default_session_factory, settings=default_settings)
|
||||
async with default_session_factory() as session:
|
||||
await session.exec(text("DROP TABLE maintenance_run"))
|
||||
await session.commit()
|
||||
|
||||
runs = await service.list_runs(limit=10)
|
||||
assert runs == []
|
||||
|
||||
created = await service.enqueue_run(job_type=MaintenanceJobType.BACKUP, triggered_by="test")
|
||||
listed = await service.list_runs(limit=10)
|
||||
assert any(run.id == created.id for run in listed)
|
||||
with pytest.raises(MaintenanceError) as exc:
|
||||
await service.list_runs(limit=10)
|
||||
assert exc.value.category == ErrorCategory.INFRA_PERSISTENT
|
||||
|
||||
Reference in New Issue
Block a user