From 2d4bfa4375763ecd1473c17b9280e21253f9709a Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 26 May 2026 01:32:50 -0400 Subject: [PATCH] =?UTF-8?q?fix(fc-cleanup):=20test=20sha256=20fixtures=20s?= =?UTF-8?q?tay=20within=20varchar(64)=20+=20isort=20the=20registration=20i?= =?UTF-8?q?mport=20=E2=80=94=20Co-Authored-By:=20Claude=20Opus=204.7=20(1M?= =?UTF-8?q?=20context)=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_cleanup_service_audit.py | 5 ++++- tests/test_tasks_library_audit.py | 10 ++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/test_cleanup_service_audit.py b/tests/test_cleanup_service_audit.py index b215dbf..ec488d7 100644 --- a/tests/test_cleanup_service_audit.py +++ b/tests/test_cleanup_service_audit.py @@ -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, diff --git a/tests/test_tasks_library_audit.py b/tests/test_tasks_library_audit.py index 3599dfc..b10c35b 100644 --- a/tests/test_tasks_library_audit.py +++ b/tests/test_tasks_library_audit.py @@ -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,