"""Throwaway rows for tests: one copy of the placeholder columns (#3109). `ImageRecord` needs a unique path and sha256 plus six NOT NULL columns no test cares about. Fifteen modules re-typed the same builder, so a new NOT NULL column meant fifteen separate patches. The tests that need these rows import them from here, usually under their old local name (`make_image as _img`), so their call sites did not change. """ from backend.app.models import ImageRecord, Tag, TagKind def image_row(sha: str, emb=None, **overrides) -> ImageRecord: """An unsaved ImageRecord keyed by `sha`; `emb` is its SigLIP embedding.""" fields = { "path": f"/images/{sha}.jpg", "sha256": sha, "size_bytes": 1, "mime": "image/jpeg", "width": 1, "height": 1, "origin": "imported_filesystem", "integrity_status": "unknown", } if emb is not None: fields["siglip_embedding"] = emb fields.update(overrides) return ImageRecord(**fields) def make_image(db, sha: str, emb=None, **overrides) -> ImageRecord: """image_row, added and flushed on a sync session.""" img = image_row(sha, emb, **overrides) db.add(img) db.flush() return img async def make_image_async(db, sha: str, emb=None, **overrides) -> ImageRecord: """image_row, added and flushed on an async session.""" img = image_row(sha, emb, **overrides) db.add(img) await db.flush() return img def make_tag(db, name: str, **overrides) -> Tag: """A general tag, added and flushed on a sync session.""" tag = Tag(**{"name": name, "kind": TagKind.general, **overrides}) db.add(tag) db.flush() return tag