26 lines
918 B
Python
26 lines
918 B
Python
"""unit test: resolve_price_before_drop detects a drop from the prior stored price
|
|
|
|
run from the repo root:
|
|
uv run pytest tests/test_price_before_drop.py
|
|
|
|
pure and offline — no Mongo, no product construction; just the drop rule
|
|
add_products_to_database relies on
|
|
"""
|
|
|
|
from monitor_utils.database import resolve_price_before_drop
|
|
|
|
|
|
def test_drop_returns_previous_price():
|
|
"""a strictly lower new price is a drop; the prior price is returned"""
|
|
|
|
assert resolve_price_before_drop(200.0, 150.0) == 200.0
|
|
|
|
|
|
def test_non_drops_return_none():
|
|
"""no prior price, an unchanged price, or a rise are not drops"""
|
|
|
|
assert resolve_price_before_drop(None, 150.0) is None # new product
|
|
assert resolve_price_before_drop(150.0, 150.0) is None # unchanged
|
|
assert resolve_price_before_drop(150.0, 200.0) is None # price rose
|
|
assert resolve_price_before_drop(200.0, None) is None # missing new price
|