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
+4 -1
View File
@@ -28,9 +28,12 @@ def _make_image_record(db_sync, tmp_path, *, width, height, color):
and insert an ImageRecord row with all required NOT-NULL columns set."""
path = tmp_path / f"img_{width}x{height}_{color[0]}.png"
Image.new("RGB", (width, height), color).save(path)
# sha256 column is varchar(64) — use a deterministic 64-char pseudo
# hash built from the unique inputs.
sha = f"{width:04d}{height:04d}{color[0]:03d}".ljust(64, "0")[:64]
rec = ImageRecord(
path=str(path),
sha256=f"fake-{width}-{height}-{color[0]:03d}" + "0" * 50,
sha256=sha,
size_bytes=path.stat().st_size,
mime="image/png", # reference-image-record-required-columns
width=width,
+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,