feat(products): export hosted detail URL for fetched images; snapshot carries status (SD-0002 §6.5.5, INV-16)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -104,6 +104,24 @@ def test_more_images_than_variants_emits_image_only_rows():
|
||||
assert [r["Image Src"] for r in rows] == ["https://x/a.jpg", "https://x/b.jpg", "https://x/c.jpg"]
|
||||
|
||||
|
||||
def test_fetched_image_serializes_hosted_detail_url():
|
||||
product = CatalogProduct(
|
||||
id=1, handle="lamp", title="Lamp", option_names=(None, None, None),
|
||||
fields={"title": "Lamp", "status": "active"},
|
||||
variants=[CatalogVariant(id=1, options=(None, None, None), position=1, fields={})],
|
||||
images=[
|
||||
CatalogImage(id=55, source_url="https://m.example/a.png", position=1,
|
||||
alt_text=None, status="fetched"),
|
||||
CatalogImage(id=56, source_url="https://m.example/b.png", position=2,
|
||||
alt_text=None, status="failed"),
|
||||
],
|
||||
)
|
||||
rows = list(serialize._product_rows(product, base_url="https://shop.test"))
|
||||
srcs = [r.get("Image Src") for r in rows if r.get("Image Src")]
|
||||
assert "https://shop.test/api/products/images/55/detail" in srcs # fetched -> hosted
|
||||
assert "https://m.example/b.png" in srcs # failed -> source kept
|
||||
|
||||
|
||||
import random
|
||||
|
||||
from app.domains.products import codec, diff, validate
|
||||
|
||||
Reference in New Issue
Block a user