reconcile: Fix linter warnings.
This commit is contained in:
parent
da5caa3e6c
commit
97a05003f3
1 changed files with 19 additions and 4 deletions
|
@ -145,7 +145,6 @@ B4C = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_one_exact_match():
|
def test_one_exact_match():
|
||||||
statement = [S1]
|
statement = [S1]
|
||||||
books = [B1]
|
books = [B1]
|
||||||
|
@ -160,6 +159,7 @@ def test_one_exact_match():
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_multiple_exact_matches():
|
def test_multiple_exact_matches():
|
||||||
statement = [S1, S2]
|
statement = [S1, S2]
|
||||||
books = [B1, B2]
|
books = [B1, B2]
|
||||||
|
@ -169,6 +169,7 @@ def test_multiple_exact_matches():
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_one_mismatch():
|
def test_one_mismatch():
|
||||||
statement = [S1]
|
statement = [S1]
|
||||||
books = []
|
books = []
|
||||||
|
@ -178,6 +179,7 @@ def test_one_mismatch():
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_multiple_mismatches():
|
def test_multiple_mismatches():
|
||||||
statement = [S1]
|
statement = [S1]
|
||||||
books = [B2]
|
books = [B2]
|
||||||
|
@ -187,6 +189,7 @@ def test_multiple_mismatches():
|
||||||
[B2],
|
[B2],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_next_day_matches():
|
def test_next_day_matches():
|
||||||
statement = [S3]
|
statement = [S3]
|
||||||
books = [B3_next_day]
|
books = [B3_next_day]
|
||||||
|
@ -196,6 +199,7 @@ def test_next_day_matches():
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_next_week_matches():
|
def test_next_week_matches():
|
||||||
statement = [S3]
|
statement = [S3]
|
||||||
books = [B3_next_week]
|
books = [B3_next_week]
|
||||||
|
@ -205,6 +209,7 @@ def test_next_week_matches():
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_incorrect_amount_does_not_match():
|
def test_incorrect_amount_does_not_match():
|
||||||
statement = [S3]
|
statement = [S3]
|
||||||
books = [B3_mismatch_amount]
|
books = [B3_mismatch_amount]
|
||||||
|
@ -214,6 +219,7 @@ def test_incorrect_amount_does_not_match():
|
||||||
[B3_mismatch_amount],
|
[B3_mismatch_amount],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_payee_mismatch_ok_when_only_one_that_amount_and_date():
|
def test_payee_mismatch_ok_when_only_one_that_amount_and_date():
|
||||||
statement = [S3]
|
statement = [S3]
|
||||||
books = [B3_payee_mismatch_1]
|
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():
|
def test_payee_mismatch_not_ok_when_multiple_that_amount_and_date():
|
||||||
statement = [S3]
|
statement = [S3]
|
||||||
books = [B3_payee_mismatch_1, B3_payee_mismatch_2]
|
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],
|
[B3_payee_mismatch_1, B3_payee_mismatch_2],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_remove_payee_junk():
|
def test_remove_payee_junk():
|
||||||
assert remove_payee_junk('WIDGETSRUS INC PAYMENT 1') == 'WIDGETSRUS'
|
assert remove_payee_junk('WIDGETSRUS INC PAYMENT 1') == 'WIDGETSRUS'
|
||||||
assert remove_payee_junk('0000010017') == '10017'
|
assert remove_payee_junk('0000010017') == '10017'
|
||||||
|
|
||||||
|
|
||||||
def test_date_proximity():
|
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)) == 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=30)) == 0.5
|
||||||
assert date_proximity(datetime.date(2021, 8, 23), datetime.date(2021, 8, 23) - datetime.timedelta(days=60)) == 0.0
|
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():
|
def test_remove_duplicate_words():
|
||||||
assert remove_duplicate_words('Hi Foo Kow FOO') == 'Hi Foo Kow'
|
assert remove_duplicate_words('Hi Foo Kow FOO') == 'Hi Foo Kow'
|
||||||
|
|
||||||
|
|
||||||
def test_payee_matches_when_first_word_matches():
|
def test_payee_matches_when_first_word_matches():
|
||||||
assert payee_match('Gandi San Francisco', 'Gandi example.com renewal 1234567') == 1.0
|
assert payee_match('Gandi San Francisco', 'Gandi example.com renewal 1234567') == 1.0
|
||||||
assert payee_match('USPS 123456789 Portland', 'USPS John Brown') == 0.8
|
assert payee_match('USPS 123456789 Portland', 'USPS John Brown') == 0.8
|
||||||
|
|
||||||
|
|
||||||
def test_metadata_for_match(monkeypatch):
|
def test_metadata_for_match(monkeypatch):
|
||||||
monkeypatch.setenv('CONSERVANCY_REPOSITORY', '.')
|
monkeypatch.setenv('CONSERVANCY_REPOSITORY', '.')
|
||||||
assert metadata_for_match(([S1], [B1], []), 'statement.pdf', 'statement.csv') == [
|
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"'),
|
('2022/imports.beancount', 777, ' bank-statement-csv: "statement.csv:222"'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_no_metadata_if_no_matches():
|
def test_no_metadata_if_no_matches():
|
||||||
assert metadata_for_match(([S1], [], ['no match']), 'statement.pdf', 'statement.csv') == []
|
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(([], [B1], ['no match']), 'statement.pdf', 'statement.csv') == []
|
||||||
assert metadata_for_match(([S1], [B2], ['no match']), 'statement.pdf', 'statement.csv') == []
|
assert metadata_for_match(([S1], [B2], ['no match']), 'statement.pdf', 'statement.csv') == []
|
||||||
|
|
||||||
|
|
||||||
def test_write_to_books():
|
def test_write_to_books():
|
||||||
books = textwrap.dedent("""\
|
books = textwrap.dedent("""\
|
||||||
2021-08-16 txn "Gandi" "transfer seleniumconf.us"
|
2021-08-16 txn "Gandi" "transfer seleniumconf.us"
|
||||||
|
@ -283,6 +294,7 @@ def test_write_to_books():
|
||||||
Expenses:Hosting 15.50 USD""")
|
Expenses:Hosting 15.50 USD""")
|
||||||
os.remove(f.name)
|
os.remove(f.name)
|
||||||
|
|
||||||
|
|
||||||
def test_totals():
|
def test_totals():
|
||||||
assert totals([
|
assert totals([
|
||||||
([S1], [B1], []),
|
([S1], [B1], []),
|
||||||
|
@ -290,6 +302,7 @@ def test_totals():
|
||||||
([], [B3_next_day], []),
|
([], [B3_next_day], []),
|
||||||
]) == (decimal.Decimal('10'), decimal.Decimal('20'), decimal.Decimal('30'))
|
]) == (decimal.Decimal('10'), decimal.Decimal('20'), decimal.Decimal('30'))
|
||||||
|
|
||||||
|
|
||||||
def test_payee_not_considered_if_check_id_present():
|
def test_payee_not_considered_if_check_id_present():
|
||||||
# These records match aside from check-id.
|
# These records match aside from check-id.
|
||||||
statement = [S3]
|
statement = [S3]
|
||||||
|
@ -300,6 +313,7 @@ def test_payee_not_considered_if_check_id_present():
|
||||||
[B3_unmatched_check_id],
|
[B3_unmatched_check_id],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_subset_sum_match():
|
def test_subset_sum_match():
|
||||||
statement = [S4]
|
statement = [S4]
|
||||||
books = [B4A, B4B, B4C]
|
books = [B4A, B4B, B4C]
|
||||||
|
@ -309,6 +323,7 @@ def test_subset_sum_match():
|
||||||
[], # No remaining books trans.
|
[], # No remaining books trans.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_subset_passes_through_all_non_matches():
|
def test_subset_passes_through_all_non_matches():
|
||||||
"""This was used to locate a bug where some of the non-matches had
|
"""This was used to locate a bug where some of the non-matches had
|
||||||
gone missing due to mutation of books_trans."""
|
gone missing due to mutation of books_trans."""
|
||||||
|
@ -318,7 +333,7 @@ def test_subset_passes_through_all_non_matches():
|
||||||
]
|
]
|
||||||
books_trans = [
|
books_trans = [
|
||||||
B2, # No match
|
B2, # No match
|
||||||
B4A, B4B, B4C, # Match
|
B4A, B4B, B4C, # Match
|
||||||
B3_next_day, B3_next_week, # No match
|
B3_next_day, B3_next_week, # No match
|
||||||
]
|
]
|
||||||
assert subset_match(statement_trans, books_trans) == (
|
assert subset_match(statement_trans, books_trans) == (
|
||||||
|
|
Loading…
Reference in a new issue