Add terminal review resolution workflow
This commit is contained in:
@@ -99,11 +99,12 @@ class PurchaseLogTests(unittest.TestCase):
|
||||
}
|
||||
]
|
||||
|
||||
rows = build_purchases.build_purchase_rows(
|
||||
rows, _observed, _canon, _links = build_purchases.build_purchase_rows(
|
||||
[giant_row],
|
||||
[costco_row],
|
||||
giant_orders,
|
||||
costco_orders,
|
||||
[],
|
||||
)
|
||||
|
||||
self.assertEqual(2, len(rows))
|
||||
@@ -195,6 +196,9 @@ class PurchaseLogTests(unittest.TestCase):
|
||||
costco_items_enriched_csv=str(costco_items),
|
||||
giant_orders_csv=str(giant_orders),
|
||||
costco_orders_csv=str(costco_orders),
|
||||
resolutions_csv=str(Path(tmpdir) / "review_resolutions.csv"),
|
||||
catalog_csv=str(Path(tmpdir) / "canonical_catalog.csv"),
|
||||
links_csv=str(Path(tmpdir) / "product_links.csv"),
|
||||
output_csv=str(purchases_csv),
|
||||
examples_csv=str(examples_csv),
|
||||
)
|
||||
@@ -208,6 +212,56 @@ class PurchaseLogTests(unittest.TestCase):
|
||||
self.assertEqual(2, len(purchase_rows))
|
||||
self.assertEqual(1, len(example_rows))
|
||||
|
||||
def test_build_purchase_rows_applies_manual_resolution(self):
|
||||
fieldnames = enrich_costco.OUTPUT_FIELDS
|
||||
giant_row = {field: "" for field in fieldnames}
|
||||
giant_row.update(
|
||||
{
|
||||
"retailer": "giant",
|
||||
"order_id": "g1",
|
||||
"line_no": "1",
|
||||
"observed_item_key": "giant:g1:1",
|
||||
"order_date": "2026-03-01",
|
||||
"item_name": "SB BAGGED ICE 20LB",
|
||||
"item_name_norm": "BAGGED ICE",
|
||||
"retailer_item_id": "100",
|
||||
"upc": "",
|
||||
"qty": "1",
|
||||
"unit": "EA",
|
||||
"line_total": "3.50",
|
||||
"unit_price": "3.50",
|
||||
"measure_type": "each",
|
||||
"raw_order_path": "giant_output/raw/g1.json",
|
||||
"is_discount_line": "false",
|
||||
"is_coupon_line": "false",
|
||||
"is_fee": "false",
|
||||
}
|
||||
)
|
||||
observed_rows, _canonical_rows, _link_rows, _observed_id_by_key, _canonical_by_observed = (
|
||||
build_purchases.build_link_state([giant_row])
|
||||
)
|
||||
observed_product_id = observed_rows[0]["observed_product_id"]
|
||||
rows, _observed, _canon, _links = build_purchases.build_purchase_rows(
|
||||
[giant_row],
|
||||
[],
|
||||
[{"order_id": "g1", "store_name": "Giant", "store_number": "42", "store_city": "Springfield", "store_state": "VA"}],
|
||||
[],
|
||||
[
|
||||
{
|
||||
"observed_product_id": observed_product_id,
|
||||
"canonical_product_id": "gcan_manual_ice",
|
||||
"resolution_action": "create",
|
||||
"status": "approved",
|
||||
"resolution_notes": "manual ice merge",
|
||||
"reviewed_at": "2026-03-16",
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
self.assertEqual("gcan_manual_ice", rows[0]["canonical_product_id"])
|
||||
self.assertEqual("approved", rows[0]["review_status"])
|
||||
self.assertEqual("create", rows[0]["resolution_action"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user