diff --git a/backend/tests/fixtures/shopify-export.csv b/backend/tests/fixtures/shopify-export.csv new file mode 100644 index 0000000..b650948 --- /dev/null +++ b/backend/tests/fixtures/shopify-export.csv @@ -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,

Soft cotton tee.

,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,,,,,,,, diff --git a/backend/tests/test_products_dialect_shopify.py b/backend/tests/test_products_dialect_shopify.py index 44d7af6..d888672 100644 --- a/backend/tests/test_products_dialect_shopify.py +++ b/backend/tests/test_products_dialect_shopify.py @@ -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"] == "

Soft cotton tee.

" + 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