Skip to content

Commit

Permalink
fix empty year test
Browse files Browse the repository at this point in the history
  • Loading branch information
reinvantveer committed Dec 1, 2023
1 parent 76653d8 commit 34d055a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tests/test_aggregation_by_year.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import datetime

from analysis.shared_parsers import to_sorted_yearly


Expand All @@ -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

0 comments on commit 34d055a

Please sign in to comment.