From 97a05003f345ef00285befdf3cc2a98d6950e0ed 2022-03-02 22:36:33 From: Ben Sturmfels Date: 2022-03-02 22:36:33 Subject: [PATCH] reconcile: Fix linter warnings. --- diff --git a/tests/test_reconcile.py b/tests/test_reconcile.py index 48835b19d0f64bb3881349b0d52086eadea090c0..893dff3c0b1851c48e7a81eb8f3633ea7c64c47b 100644 --- a/tests/test_reconcile.py +++ b/tests/test_reconcile.py @@ -145,7 +145,6 @@ B4C = { } - def test_one_exact_match(): statement = [S1] books = [B1] @@ -160,6 +159,7 @@ def test_one_exact_match(): [], ) + def test_multiple_exact_matches(): statement = [S1, S2] books = [B1, B2] @@ -169,6 +169,7 @@ def test_multiple_exact_matches(): [], ) + def test_one_mismatch(): statement = [S1] books = [] @@ -178,6 +179,7 @@ def test_one_mismatch(): [], ) + def test_multiple_mismatches(): statement = [S1] books = [B2] @@ -187,6 +189,7 @@ def test_multiple_mismatches(): [B2], ) + def test_next_day_matches(): statement = [S3] books = [B3_next_day] @@ -196,6 +199,7 @@ def test_next_day_matches(): [], ) + def test_next_week_matches(): statement = [S3] books = [B3_next_week] @@ -205,6 +209,7 @@ def test_next_week_matches(): [], ) + def test_incorrect_amount_does_not_match(): statement = [S3] books = [B3_mismatch_amount] @@ -214,6 +219,7 @@ def test_incorrect_amount_does_not_match(): [B3_mismatch_amount], ) + def test_payee_mismatch_ok_when_only_one_that_amount_and_date(): statement = [S3] books = [B3_payee_mismatch_1] @@ -223,6 +229,7 @@ def test_payee_mismatch_ok_when_only_one_that_amount_and_date(): [], ) + def test_payee_mismatch_not_ok_when_multiple_that_amount_and_date(): statement = [S3] books = [B3_payee_mismatch_1, B3_payee_mismatch_2] @@ -233,25 +240,27 @@ def test_payee_mismatch_not_ok_when_multiple_that_amount_and_date(): [B3_payee_mismatch_1, B3_payee_mismatch_2], ) + def test_remove_payee_junk(): assert remove_payee_junk('WIDGETSRUS INC PAYMENT 1') == 'WIDGETSRUS' assert remove_payee_junk('0000010017') == '10017' + def test_date_proximity(): assert date_proximity(datetime.date(2021, 8, 23), datetime.date(2021, 8, 23)) == 1.0 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' def test_remove_duplicate_words(): assert remove_duplicate_words('Hi Foo Kow FOO') == 'Hi Foo Kow' + def test_payee_matches_when_first_word_matches(): assert payee_match('Gandi San Francisco', 'Gandi example.com renewal 1234567') == 1.0 assert payee_match('USPS 123456789 Portland', 'USPS John Brown') == 0.8 + def test_metadata_for_match(monkeypatch): monkeypatch.setenv('CONSERVANCY_REPOSITORY', '.') assert metadata_for_match(([S1], [B1], []), 'statement.pdf', 'statement.csv') == [ @@ -259,11 +268,13 @@ def test_metadata_for_match(monkeypatch): ('2022/imports.beancount', 777, ' bank-statement-csv: "statement.csv:222"'), ] + def test_no_metadata_if_no_matches(): assert metadata_for_match(([S1], [], ['no match']), 'statement.pdf', 'statement.csv') == [] assert metadata_for_match(([], [B1], ['no match']), 'statement.pdf', 'statement.csv') == [] assert metadata_for_match(([S1], [B2], ['no match']), 'statement.pdf', 'statement.csv') == [] + def test_write_to_books(): books = textwrap.dedent("""\ 2021-08-16 txn "Gandi" "transfer seleniumconf.us" @@ -283,6 +294,7 @@ def test_write_to_books(): Expenses:Hosting 15.50 USD""") os.remove(f.name) + def test_totals(): assert totals([ ([S1], [B1], []), @@ -290,6 +302,7 @@ 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] @@ -300,6 +313,7 @@ def test_payee_not_considered_if_check_id_present(): [B3_unmatched_check_id], ) + def test_subset_sum_match(): statement = [S4] books = [B4A, B4B, B4C] @@ -309,6 +323,7 @@ def test_subset_sum_match(): [], # No remaining books trans. ) + def test_subset_passes_through_all_non_matches(): """This was used to locate a bug where some of the non-matches had gone missing due to mutation of books_trans.""" @@ -318,7 +333,7 @@ def test_subset_passes_through_all_non_matches(): ] books_trans = [ B2, # No match - B4A, B4B, B4C, # Match + B4A, B4B, B4C, # Match B3_next_day, B3_next_week, # No match ] assert subset_match(statement_trans, books_trans) == (