fix(integration): lazy seed-snapshot (unblock unit job); isolate recover test from eager import

This commit is contained in:
2026-05-15 22:43:46 -04:00
parent 7a896605e0
commit dfa6a5c895
2 changed files with 45 additions and 24 deletions
+12 -1
View File
@@ -26,7 +26,7 @@ def _make_batch(session) -> int:
return batch.id
def test_recover_interrupted_only_old(db_sync):
def test_recover_interrupted_only_old(db_sync, monkeypatch):
batch_id = _make_batch(db_sync)
now = datetime.now(UTC)
@@ -41,6 +41,16 @@ def test_recover_interrupted_only_old(db_sync):
db_sync.add_all([fresh, stale])
db_sync.commit()
# Isolate the recover task: under eager Celery, the real
# import_media_file.delay() would run inline against the nonexistent
# /import/b.jpg and flip the just-requeued row 'queued' -> 'skipped'.
from backend.app.tasks import import_file
dispatched: list[int] = []
monkeypatch.setattr(
import_file.import_media_file, "delay", dispatched.append
)
from backend.app.tasks.maintenance import recover_interrupted_tasks
recovered = recover_interrupted_tasks.apply().get()
assert recovered == 1
@@ -50,6 +60,7 @@ def test_recover_interrupted_only_old(db_sync):
assert fresh.status == "processing"
assert stale.status == "queued"
assert stale.started_at is None
assert dispatched == [stale.id]
def test_cleanup_old_deletes_finished_old(db_sync):