From b68d0597fe093be3346388f9421332e9b07bfc1a Mon Sep 17 00:00:00 2001 From: javex Date: Tue, 3 Oct 2023 18:38:47 +1030 Subject: [PATCH] Add more merge test cases These were supposed to fail, but unfortunately didn't, so the bug is not as simple as the test cases try to check. However, I'll still leave them in since they're worth having. The bug described in #2 is probably elsewhere. --- tests/test_analysis.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/test_analysis.py b/tests/test_analysis.py index 21db7d5..f87227b 100644 --- a/tests/test_analysis.py +++ b/tests/test_analysis.py @@ -51,4 +51,22 @@ def test_merge_price_history(): assert item['price'] == 2 assert len(item['priceHistory']) == 2 assert item['priceHistory'][0]['price'] == 2 - assert item['priceHistory'][1]['price'] == 3 \ No newline at end of file + assert item['priceHistory'][1]['price'] == 3 + + # Repeat run of history on same day + old_items = [get_item()] + new_items = [old_items[0]] + items = analysis.merge_price_history(old_items, new_items) + assert len(items) == 1 + item = items[0] + assert len(item['priceHistory']) == 1 + + # Prices with history don't get overwritten + oldest_items = [get_item()] + middle_items = [get_item(price=2)] + newest_items = [get_item(price=2)] + items = analysis.merge_price_history(oldest_items, middle_items) + items = analysis.merge_price_history(items, newest_items) + assert len(items) == 1 + item = items[0] + assert len(item['priceHistory']) == 2