Use picked weight for Giant quantity basis
This commit is contained in:
@@ -129,6 +129,63 @@ class EnrichGiantTests(unittest.TestCase):
|
||||
("2", "each"),
|
||||
enrich_giant.derive_normalized_quantity("2", "", "", "", "each"),
|
||||
)
|
||||
self.assertEqual(
|
||||
("1.68", "lb"),
|
||||
enrich_giant.derive_normalized_quantity("1", "", "", "", "weight", "1.68"),
|
||||
)
|
||||
|
||||
def test_parse_item_uses_picked_weight_for_loose_weight_items(self):
|
||||
banana = enrich_giant.parse_item(
|
||||
order_id="abc123",
|
||||
order_date="2026-03-01",
|
||||
raw_path=Path("raw/abc123.json"),
|
||||
line_no=1,
|
||||
item={
|
||||
"podId": 1,
|
||||
"shipQy": 1,
|
||||
"totalPickedWeight": 1.68,
|
||||
"unitPrice": 0.99,
|
||||
"itemName": "FRESH BANANA",
|
||||
"lbEachCd": "LB",
|
||||
"groceryAmount": 0.99,
|
||||
"primUpcCd": "111",
|
||||
"mvpSavings": 0,
|
||||
"rewardSavings": 0,
|
||||
"couponSavings": 0,
|
||||
"couponPrice": 0,
|
||||
"categoryId": "1",
|
||||
"categoryDesc": "Grocery",
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual("weight", banana["measure_type"])
|
||||
self.assertEqual("1.68", banana["normalized_quantity"])
|
||||
self.assertEqual("lb", banana["normalized_quantity_unit"])
|
||||
|
||||
patty = enrich_giant.parse_item(
|
||||
order_id="abc123",
|
||||
order_date="2026-03-01",
|
||||
raw_path=Path("raw/abc123.json"),
|
||||
line_no=2,
|
||||
item={
|
||||
"podId": 2,
|
||||
"shipQy": 1,
|
||||
"totalPickedWeight": 1.29,
|
||||
"unitPrice": 10.05,
|
||||
"itemName": "80% PATTIES PK12",
|
||||
"lbEachCd": "LB",
|
||||
"groceryAmount": 10.05,
|
||||
"primUpcCd": "222",
|
||||
"mvpSavings": 0,
|
||||
"rewardSavings": 0,
|
||||
"couponSavings": 0,
|
||||
"couponPrice": 0,
|
||||
"categoryId": "1",
|
||||
"categoryDesc": "Grocery",
|
||||
},
|
||||
)
|
||||
self.assertEqual("1.29", patty["normalized_quantity"])
|
||||
self.assertEqual("lb", patty["normalized_quantity_unit"])
|
||||
|
||||
def test_build_items_enriched_reads_raw_order_files_and_writes_csv(self):
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
|
||||
Reference in New Issue
Block a user