CI and images / lint (push) Successful in 2s
CI and images / extension-version (push) Successful in 2s
CI and images / frontend-build (push) Successful in 20s
CI and images / backend-lint-and-test (push) Successful in 30s
CI and images / integration (push) Successful in 2m18s
CI and images / sign-extension (push) Successful in 3s
CI and images / build-agent (push) Successful in 6s
CI and images / build-web (push) Successful in 1m44s
CI and images / smoke-web (push) Successful in 56s
CI and images / promote (push) Skipped
tests/factories.py holds image_row/make_image/make_image_async/make_tag. The 17 byte-identical _img/_tag helpers (15 modules) now import them under their old names, so no call site changed. frontend/test/support/stubFetch.js replaces 15 copies that differed only in formatting. Copies whose bodies differ (other defaults, other columns, a url-only stub) are left as they are; folding those needs a look at each caller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVjrnpQjRgHdvq95rASoiR
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
"""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
|