fix(fc-cleanup): test sha256 fixtures stay within varchar(64) + isort the registration import — Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

This commit is contained in:
2026-05-26 01:32:50 -04:00
parent 6ed2021ad6
commit 2d4bfa4375
2 changed files with 10 additions and 5 deletions
+6 -4
View File
@@ -8,21 +8,23 @@ import pytest
from PIL import Image
from sqlalchemy import select
import backend.app.tasks.library_audit # noqa: F401 — celery registration
from backend.app import celery_app
from backend.app.models import ImageRecord, LibraryAuditRun
import backend.app.tasks.library_audit # noqa: F401 — registration
pytestmark = pytest.mark.integration
def _mk_image(db_sync, tmp_path, *, mode, color, name):
path = tmp_path / name
Image.new(mode, (10, 10), color).save(path)
short_sha = f"fake-{name}"
# sha256 column is varchar(64) — pad/truncate a per-file pseudo hash
# exactly to 64 chars. Each test fixture file must have a unique
# sha256 (reference-image-record-path-unique peer constraint).
sha = f"audit-{name}".ljust(64, "x")[:64]
rec = ImageRecord(
path=str(path),
sha256=short_sha + "0" * (64 - len(short_sha)),
sha256=sha,
size_bytes=path.stat().st_size,
mime="image/png",
width=10, height=10,