from db.channel_taxonomy import master_path_key, master_path_from_fields


def test_master_path_key_normalizes_parts():
    assert master_path_key(category_l1="Kitchen", category_l2="Cabinets", collection="Spring Sale") == (
        "kitchen|cabinets||spring_sale"
    )


def test_master_path_from_fields_reads_canonical_codes():
    l1, l2, l3, coll = master_path_from_fields(
        {"category_l1": "A", "category_l2": "B", "collection": "Promo"}
    )
    assert l1 == "A"
    assert l2 == "B"
    assert l3 == ""
    assert coll == "Promo"
