feat(products): Shopify dialect adapter — header detection + canonical mapping (SD-0002 §6.5.1, SLICE-8)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
"""Shopify dialect adapter — detection + the §6.5.1 mapping contract (SLICE-8)."""
|
||||
from app.domains.products.dialect_shopify import is_shopify_header, map_shopify_header
|
||||
|
||||
|
||||
def test_detects_shopify_by_signature_column():
|
||||
assert is_shopify_header(["Handle", "Title", "Body (HTML)", "Variant Price"]) is True
|
||||
assert is_shopify_header(["Handle", "Title", "Google Shopping / MPN"]) is True
|
||||
|
||||
|
||||
def test_canonical_header_is_not_shopify():
|
||||
assert is_shopify_header(["Handle", "Title", "Description", "Variant Cost"]) is False
|
||||
|
||||
|
||||
def test_ambiguous_shared_only_header_defaults_canonical():
|
||||
# Only columns common to both dialects -> not Shopify (safe default, never misparse).
|
||||
assert (
|
||||
is_shopify_header(["Handle", "Title", "Option1 Name", "Variant Price", "Image Src"])
|
||||
is False
|
||||
)
|
||||
|
||||
|
||||
def test_map_renames_and_passes_through():
|
||||
mapped, not_imported = map_shopify_header(
|
||||
["Handle", "Body (HTML)", "Cost per item", "Variant Price"]
|
||||
)
|
||||
assert mapped == ["Handle", "Description", "Variant Cost", "Variant Price"]
|
||||
assert not_imported == []
|
||||
|
||||
|
||||
def test_map_drops_type_and_weight_unit_overrides():
|
||||
mapped, not_imported = map_shopify_header(
|
||||
["Handle", "Type", "Variant Grams", "Variant Weight Unit"]
|
||||
)
|
||||
assert mapped == ["Handle", None, "Variant Weight", None]
|
||||
assert not_imported == ["Type", "Variant Weight Unit"]
|
||||
|
||||
|
||||
def test_map_drops_shopify_only_and_market_columns():
|
||||
mapped, not_imported = map_shopify_header(
|
||||
["Handle", "Variant Compare At Price", "Gift Card", "Price / International"]
|
||||
)
|
||||
assert mapped == ["Handle", None, None, None]
|
||||
assert not_imported == ["Variant Compare At Price", "Gift Card", "Price / International"]
|
||||
Reference in New Issue
Block a user