test(products): exhaustive Shopify->canonical mapping fixture (SD-0002 §6.5.1, SLICE-8)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 02:21:05 -07:00
parent 0c7a76a305
commit f170950aec
2 changed files with 39 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
Handle,Title,Body (HTML),Vendor,Product Category,Type,Tags,Published,Status,Option1 Name,Option1 Value,Variant SKU,Variant Grams,Variant Inventory Tracker,Variant Inventory Qty,Variant Inventory Policy,Variant Fulfillment Service,Variant Price,Variant Compare At Price,Variant Requires Shipping,Variant Taxable,Variant Barcode,Image Src,Image Position,Image Alt Text,Gift Card,SEO Title,SEO Description,Google Shopping / MPN,Variant Image,Variant Weight Unit,Cost per item,Status
star-tee,Star Tee,<p>Soft cotton tee.</p>,Wiggle Goods,Apparel & Accessories > Clothing,Shirts,"apparel, tees",TRUE,active,Size,S,WG-TEE-S,180,shopify,12,deny,manual,24.00,30.00,TRUE,TRUE,0001,https://img.example.com/star-tee.jpg,1,Star Tee,FALSE,Star Tee | Wiggle,Soft tee,MPN-1,https://img.example.com/star-s.jpg,g,11.00,active
star-tee,,,,,,,,,,M,WG-TEE-M,180,shopify,18,deny,manual,24.00,30.00,TRUE,TRUE,0002,,,,FALSE,,,,,g,11.00,
star-tee,,,,,,,,,,,,,,,,,,,,,,https://img.example.com/star-back.jpg,2,Star Tee back,,,,,,,,
1 Handle Title Body (HTML) Vendor Product Category Type Tags Published Status Option1 Name Option1 Value Variant SKU Variant Grams Variant Inventory Tracker Variant Inventory Qty Variant Inventory Policy Variant Fulfillment Service Variant Price Variant Compare At Price Variant Requires Shipping Variant Taxable Variant Barcode Image Src Image Position Image Alt Text Gift Card SEO Title SEO Description Google Shopping / MPN Variant Image Variant Weight Unit Cost per item Status
2 star-tee Star Tee <p>Soft cotton tee.</p> Wiggle Goods Apparel & Accessories > Clothing Shirts apparel, tees TRUE active Size S WG-TEE-S 180 shopify 12 deny manual 24.00 30.00 TRUE TRUE 0001 https://img.example.com/star-tee.jpg 1 Star Tee FALSE Star Tee | Wiggle Soft tee MPN-1 https://img.example.com/star-s.jpg g 11.00 active
3 star-tee M WG-TEE-M 180 shopify 18 deny manual 24.00 30.00 TRUE TRUE 0002 FALSE g 11.00
4 star-tee https://img.example.com/star-back.jpg 2 Star Tee back
@@ -1,6 +1,11 @@
"""Shopify dialect adapter — detection + the §6.5.1 mapping contract (SLICE-8)."""
from pathlib import Path
from app.domains.products.codec import parse_csv
from app.domains.products.dialect_shopify import is_shopify_header, map_shopify_header
_FIXTURE = Path(__file__).parent / "fixtures" / "shopify-export.csv"
def test_detects_shopify_by_signature_column():
assert is_shopify_header(["Handle", "Title", "Body (HTML)", "Variant Price"]) is True
@@ -41,3 +46,33 @@ def test_map_drops_shopify_only_and_market_columns():
)
assert mapped == ["Handle", None, None, None]
assert not_imported == ["Variant Compare At Price", "Gift Card", "Price / International"]
def test_shopify_fixture_maps_exhaustively():
parsed = parse_csv(_FIXTURE.read_bytes())
assert parsed.dialect == "shopify"
first = parsed.rows[0].cells
# renamed
assert first["Description"] == "<p>Soft cotton tee.</p>"
assert first["Google Product Category"] == "Apparel & Accessories > Clothing"
assert first["Variant Cost"] == "11.00"
assert first["Variant Weight"] == "180"
assert first["Variant Weight Unit"] == "g"
# direct
assert first["Variant SKU"] == "WG-TEE-S"
assert first["Image Src"] == "https://img.example.com/star-tee.jpg"
# not imported — warned, none leaked into canonical cells
for col in (
"Type",
"Variant Compare At Price",
"Gift Card",
"SEO Title",
"Google Shopping / MPN",
"Variant Weight Unit",
"Variant Inventory Policy",
"Variant Fulfillment Service",
"Variant Requires Shipping",
"Variant Taxable",
):
assert col in parsed.unknown_columns, col
assert "Variant Compare At Price" not in first