From 6824fa22c5f51148132adcb0044cb32a535817cc Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 13 Jun 2024 18:00:11 +0200 Subject: [PATCH] workaround for no previous price present --- changedetectionio/processors/restock_diff.py | 3 ++- changedetectionio/tests/test_restock_itemprop.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/changedetectionio/processors/restock_diff.py b/changedetectionio/processors/restock_diff.py index cdca1cd5..508e874d 100644 --- a/changedetectionio/processors/restock_diff.py +++ b/changedetectionio/processors/restock_diff.py @@ -179,7 +179,8 @@ class perform_site_check(difference_detection_processor): if watch.get('follow_price_changes') and watch.get('restock') and update_obj.get('restock') and update_obj['restock'].get('price'): price = float(update_obj['restock'].get('price')) - previous_price = float(watch['restock'].get('price')) + # Default to current price if no previous price found + previous_price = float(watch['restock'].get('price', price)) # It was different, but negate it further down if price != previous_price: diff --git a/changedetectionio/tests/test_restock_itemprop.py b/changedetectionio/tests/test_restock_itemprop.py index af84930e..1ef8458e 100644 --- a/changedetectionio/tests/test_restock_itemprop.py +++ b/changedetectionio/tests/test_restock_itemprop.py @@ -186,6 +186,7 @@ def test_itemprop_price_minmax_limit(client, live_server): res = client.get(url_for("index")) assert b'1890.45' in res.data assert b'unviewed' in res.data + res = client.get(url_for("form_delete", uuid="all"), follow_redirects=True) assert b'Deleted' in res.data