fixed price drops/moved logging outside of init_monitor

This commit is contained in:
TPV committed 2026-07-13 18:57:23 -07:00
1 parent 7d070dec40
commit 00d3c12ee0
3 files changed
+98 -27

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
"""unit test: resolve_price_before_drop detects a drop from the prior stored price
run from the repo root:
uv run python 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
test_drop_returns_previous_price()
test_non_drops_return_none()
print("price before drop test passed")