diff --git a/tests/test_reconcile.py b/tests/test_reconcile.py index 186b5e5..7703921 100644 --- a/tests/test_reconcile.py +++ b/tests/test_reconcile.py @@ -4,7 +4,7 @@ import os import tempfile import textwrap -from conservancy_beancount.reconcile.prototype_amex_reconciler import ( +from conservancy_beancount.reconcile.statement_reconciler import ( match_statement_and_books, remove_payee_junk, date_proximity, @@ -15,6 +15,10 @@ from conservancy_beancount.reconcile.prototype_amex_reconciler import ( totals, ) +# These data structures represent individual transactions as taken from the +# statement ("S") or the books ("B"). + +# Statement transaction examples. S1 = { 'date': datetime.date(2022, 1, 1), 'amount': decimal.Decimal('10.00'), @@ -37,6 +41,7 @@ S3 = { 'line': 444, } +# Books transaction examples. B1 = { 'date': datetime.date(2022, 1, 1), 'amount': decimal.Decimal('10.00'), @@ -115,6 +120,11 @@ def test_one_exact_match(): statement = [S1] books = [B1] assert match_statement_and_books(statement, books) == [ + # Match, match, notes. + # + # The matches are a list so we can implement subset-sum matching where + # multiple books transactions may match to a single statement + # transaction. ([S1], [B1], []), ] @@ -180,8 +190,6 @@ def test_payee_mismatch_not_ok_when_multiple_that_amount_and_date(): ([], [B3_payee_mismatch_2], ['no match']), ] -# def test_subset_sum_with_same_date_and_payee(): - def test_remove_payee_junk(): assert remove_payee_junk('WIDGETSRUS INC PAYMENT 1') == 'WIDGETSRUS' assert remove_payee_junk('0000010017') == '10017' @@ -191,7 +199,6 @@ def test_date_proximity(): assert date_proximity(datetime.date(2021, 8, 23), datetime.date(2021, 8, 23) - datetime.timedelta(days=30)) == 0.5 assert date_proximity(datetime.date(2021, 8, 23), datetime.date(2021, 8, 23) - datetime.timedelta(days=60)) == 0.0 - def test_remove_duplicate_words(): assert remove_duplicate_words('Hi Foo Kow FOO') == 'Hi Foo Kow' @@ -240,7 +247,6 @@ def test_totals(): ([], [B3_next_day], []), ]) == (decimal.Decimal('10'), decimal.Decimal('20'), decimal.Decimal('30')) - def test_payee_not_considered_if_check_id_present(): # These records match aside from check-id. statement = [S3]