diff --git a/tests/test_reconcile.py b/tests/test_reconcile.py index 292de3648d6476d04415aba9ffc7300da6fe9dc9..ba6d6ac655118e61351e7ca7e679fc6afed46f9d 100644 --- a/tests/test_reconcile.py +++ b/tests/test_reconcile.py @@ -5,6 +5,8 @@ import os import tempfile import textwrap +import pytest + from conservancy_beancount.reconcile.statement_reconciler import ( date_proximity, format_output, @@ -15,6 +17,7 @@ from conservancy_beancount.reconcile.statement_reconciler import ( read_fr_csv, remove_duplicate_words, remove_payee_junk, + round_to_month, subset_match, totals, write_metadata_to_books, @@ -388,3 +391,20 @@ def test_format_output(): matches, _, _ = match_statement_and_books(statement, books) output = format_output(matches, datetime.date(2022, 1, 1), datetime.date(2022, 2, 1), 'test.csv', True) assert '2022-01-01: 10.00 Patreon / Patreon / 12345 → 2022-01-01: 10.00 Patreon ✓ Matched' in output + + +month_test_data = [ + ((datetime.date(2022, 1, 2), datetime.date(2022, 1, 30)), + (datetime.date(2022, 1, 1), datetime.date(2022, 1, 31))), + ((datetime.date(2022, 4, 2), datetime.date(2022, 4, 29)), + (datetime.date(2022, 4, 1), datetime.date(2022, 4, 30))), + ((datetime.date(2022, 2, 2), datetime.date(2022, 2, 27)), + (datetime.date(2022, 2, 1), datetime.date(2022, 2, 28))), + ((datetime.date(2024, 2, 2), datetime.date(2024, 2, 27)), + (datetime.date(2024, 2, 1), datetime.date(2024, 2, 29))), +] + + +@pytest.mark.parametrize('input_dates,rounded_dates', month_test_data) +def test_rounds_to_full_month(input_dates, rounded_dates): + assert round_to_month(*input_dates) == rounded_dates