Create canonical product layer scaffold

This commit is contained in:
ben
2026-03-16 00:43:21 -04:00
parent 9b13ec3b31
commit 347cd44d09
2 changed files with 179 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
import unittest
import build_canonical_layer
class CanonicalLayerTests(unittest.TestCase):
def test_build_canonical_layer_seeds_one_canonical_per_observed_product(self):
observed_rows = [
{
"observed_product_id": "gobs_1",
"representative_name_norm": "GALA APPLE",
"representative_brand": "SB",
"representative_variant": "",
"representative_size_value": "5",
"representative_size_unit": "lb",
"representative_pack_qty": "",
"representative_measure_type": "weight",
},
{
"observed_product_id": "gobs_2",
"representative_name_norm": "ROTINI",
"representative_brand": "",
"representative_variant": "",
"representative_size_value": "16",
"representative_size_unit": "oz",
"representative_pack_qty": "",
"representative_measure_type": "weight",
},
]
canonicals, links = build_canonical_layer.build_canonical_layer(observed_rows)
self.assertEqual(2, len(canonicals))
self.assertEqual(2, len(links))
self.assertEqual("GALA APPLE", canonicals[0]["canonical_name"])
self.assertEqual("5", canonicals[0]["normalized_quantity"])
self.assertEqual("lb", canonicals[0]["normalized_quantity_unit"])
self.assertEqual("seed_observed_product", links[0]["link_method"])
if __name__ == "__main__":
unittest.main()