From 34d055a14b22c30a2597869f53949b2a168b1081 Mon Sep 17 00:00:00 2001 From: reinvantveer Date: Fri, 1 Dec 2023 11:15:46 +0100 Subject: [PATCH] fix empty year test --- tests/test_aggregation_by_year.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test_aggregation_by_year.py b/tests/test_aggregation_by_year.py index 10ef8e1..6ca787c 100644 --- a/tests/test_aggregation_by_year.py +++ b/tests/test_aggregation_by_year.py @@ -1,3 +1,5 @@ +from datetime import datetime + from analysis.shared_parsers import to_sorted_yearly @@ -10,11 +12,19 @@ def test_year_aggregator() -> None: } } yearly_stats = to_sorted_yearly(test_data) - assert yearly_stats == { + expected = { 'some_mime_type': [ {'period': '2018', 'count': 300}, {'period': '2019', 'count': 0}, {'period': '2020', 'count': 300}, - {'period': '2021', 'count': 0}, ] } + + # Append following years without data + current_year = datetime.now().year + for year in range(2021, current_year): + expected['some_mime_type'].append({ + 'period': str(year), 'count': 0 + }) + + assert yearly_stats == expected