Create canonical product layer scaffold
This commit is contained in:
42
tests/test_canonical_layer.py
Normal file
42
tests/test_canonical_layer.py
Normal 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()
|
||||
Reference in New Issue
Block a user