diff --git a/tests/test_filters.py b/tests/test_filters.py index 24b02c4edd7d461f94adb95bbc4f4736f1c68240..9ba4bc4ddf538b5080972676d7a3996a7f8e8f40 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -134,3 +134,24 @@ def test_filter_for_rt_id_uses_first_link_only(): postings = data.Posting.from_entries(entries) actual = filters.filter_for_rt_id(postings, 350) check_filter(actual, entries, ()), + +@pytest.mark.parametrize('opening_txn', [ + testutil.OpeningBalance(), + None, +]) +def test_remove_opening_balance_txn(opening_txn): + entries = [ + testutil.Transaction(postings=[ + (account, amount), + ('Assets:Checking', -amount), + ]) + for account, amount in [ + ('Income:Donations', -50), + ('Expenses:Other', 75), + ]] + if opening_txn is not None: + entries.insert(1, opening_txn) + actual = filters.remove_opening_balance_txn(entries) + assert actual is opening_txn + assert len(entries) == 2 + assert opening_txn not in entries