Compare commits
2
Commits
0fceafb364
...
2bf2c613a9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bf2c613a9 | ||
|
|
9a34ae5ca6 |
No files matched your search
@@ -211,7 +211,7 @@ def build_product_details(
|
||||
if not bypass_thresholds and not passes_percentage and not passes_price_drop:
|
||||
return
|
||||
|
||||
built = Product(
|
||||
built_product = Product(
|
||||
product_id=product_id,
|
||||
title=product["title"],
|
||||
url=product["url"],
|
||||
@@ -227,6 +227,7 @@ def build_product_details(
|
||||
promo_dollar_off=product.get("promoDollarOff"),
|
||||
promo_min_spend=product.get("promoMinSpend"),
|
||||
new_listing=new_listing,
|
||||
asin=product.get("asin"),
|
||||
),
|
||||
timing=ProductTiming(
|
||||
discovered_date=product["discoveredDate"],
|
||||
@@ -249,7 +250,7 @@ def build_product_details(
|
||||
member_deal=product["memberDeal"],
|
||||
),
|
||||
)
|
||||
return built
|
||||
return built_product
|
||||
|
||||
|
||||
async def run_monitor_cycle(
|
||||
|
||||
@@ -78,6 +78,17 @@ def test_promo_fields_read_through():
|
||||
assert product.metadata.percentage == 20
|
||||
|
||||
|
||||
def test_asin_reads_through():
|
||||
"""asin round-trips: convert_product_to_mongo writes it, so the consumer
|
||||
must read it back for the SellerAmp lookup"""
|
||||
product = build_product_details(_doc(asin="B0CHX3QBCH"), min_percentage=0)
|
||||
assert product.metadata.asin == "B0CHX3QBCH"
|
||||
|
||||
|
||||
def test_missing_asin_defaults_to_none():
|
||||
assert build_product_details(_doc(), min_percentage=0).metadata.asin is None
|
||||
|
||||
|
||||
def test_missing_promo_keys_default_to_none():
|
||||
"""a doc from a lagging monitor lacks promo keys -> None, not KeyError"""
|
||||
product = build_product_details(_doc(), min_percentage=0)
|
||||
|
||||
Reference in new issue
Block a user