fix(test): archive members need structured imgs+threshold0; provenance payload gained attachments key
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -48,13 +48,31 @@ def _jpeg_bytes(color):
|
|||||||
return buf.getvalue()
|
return buf.getvalue()
|
||||||
|
|
||||||
|
|
||||||
|
def _split_bytes(orient):
|
||||||
|
"""Structured half/half image — solid colors phash-collapse (distance
|
||||||
|
0); orthogonal splits are distinct only at phash_threshold=0 (see
|
||||||
|
reference-phash-test-images)."""
|
||||||
|
im = Image.new("L", (256, 256), 0)
|
||||||
|
px = im.load()
|
||||||
|
for y in range(256):
|
||||||
|
for x in range(256):
|
||||||
|
if (x / 256 if orient == "v" else y / 256) >= 0.5:
|
||||||
|
px[x, y] = 255
|
||||||
|
buf = io.BytesIO()
|
||||||
|
im.convert("RGB").save(buf, "JPEG")
|
||||||
|
return buf.getvalue()
|
||||||
|
|
||||||
|
|
||||||
def test_archive_imports_members_and_stores_archive(importer, import_layout):
|
def test_archive_imports_members_and_stores_archive(importer, import_layout):
|
||||||
import_root, _ = import_layout
|
import_root, _ = import_layout
|
||||||
|
# Distinct structure + threshold 0 so BOTH members import (solid
|
||||||
|
# colors would phash-collapse; reference-phash-test-images).
|
||||||
|
importer.settings.phash_threshold = 0
|
||||||
arc = import_root / "Bob" / "set.cbz"
|
arc = import_root / "Bob" / "set.cbz"
|
||||||
arc.parent.mkdir(parents=True, exist_ok=True)
|
arc.parent.mkdir(parents=True, exist_ok=True)
|
||||||
with zipfile.ZipFile(arc, "w") as zf:
|
with zipfile.ZipFile(arc, "w") as zf:
|
||||||
zf.writestr("a.jpg", _jpeg_bytes((200, 10, 10)))
|
zf.writestr("a.jpg", _split_bytes("v"))
|
||||||
zf.writestr("b.jpg", _jpeg_bytes((10, 200, 10)))
|
zf.writestr("b.jpg", _split_bytes("h"))
|
||||||
zf.writestr("readme.txt", b"hello")
|
zf.writestr("readme.txt", b"hello")
|
||||||
arc.with_suffix(".cbz.json").write_text(json.dumps(
|
arc.with_suffix(".cbz.json").write_text(json.dumps(
|
||||||
{"category": "patreon", "id": "777", "title": "Set"}))
|
{"category": "patreon", "id": "777", "title": "Set"}))
|
||||||
|
|||||||
@@ -58,7 +58,9 @@ async def test_for_image_no_provenance_returns_empty_list(db):
|
|||||||
rec = await _seed_image(db)
|
rec = await _seed_image(db)
|
||||||
svc = ProvenanceService(db)
|
svc = ProvenanceService(db)
|
||||||
payload = await svc.for_image(rec.id)
|
payload = await svc.for_image(rec.id)
|
||||||
assert payload == {"image_id": rec.id, "provenance": []}
|
assert payload == {
|
||||||
|
"image_id": rec.id, "provenance": [], "attachments": []
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|||||||
Reference in New Issue
Block a user