diff --git a/tests/test_reports_related_postings.py b/tests/test_reports_related_postings.py index 49f0534c8f5516e14004830e0086fe8373d772cd..bb4cdad4f0a4e07ec473f6408b3419de4b74f52c 100644 --- a/tests/test_reports_related_postings.py +++ b/tests/test_reports_related_postings.py @@ -398,3 +398,21 @@ def test_group_by_first_meta_link(link_swap_posts): actual = actual_all.get(key, '') assert len(actual) == 2 assert all(post.account == expect_account for post in actual) + +def test_group_by_account(): + entries = [ + testutil.Transaction(postings=[ + ('Income:Donations', -10), + ('Assets:Cash', 10), + ]), + testutil.Transaction(postings=[ + ('Income:Donations', -20), + ('Assets:Cash', 20), + ]), + ] + postings = data.Posting.from_entries(entries) + actual = dict(core.RelatedPostings.group_by_account(postings)) + assert len(actual) == 2 + for key, related in actual.items(): + assert len(related) == 2 + assert all(post.account == key for post in related)