From 163ecbc7d3d21b97565128fabbf93765394892f1 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Tue, 17 Mar 2020 18:06:43 -0400 Subject: [PATCH] data: iter_postings uses Account. --- conservancy_beancount/data.py | 1 + tests/test_data_iter_postings.py | 1 + 2 files changed, 2 insertions(+) diff --git a/conservancy_beancount/data.py b/conservancy_beancount/data.py index 458485c..723eff1 100644 --- a/conservancy_beancount/data.py +++ b/conservancy_beancount/data.py @@ -86,5 +86,6 @@ class PostingMeta(collections.abc.MutableMapping): def iter_postings(txn: Transaction) -> Iterator[Posting]: for index, source in enumerate(txn.postings): yield source._replace( + account=Account(source.account), meta=PostingMeta(txn, index, source), ) diff --git a/tests/test_data_iter_postings.py b/tests/test_data_iter_postings.py index d1dc9b2..cacb8fd 100644 --- a/tests/test_data_iter_postings.py +++ b/tests/test_data_iter_postings.py @@ -30,6 +30,7 @@ def simple_txn(index=None, key=None): def test_iter_postings(simple_txn): for source, post in zip(simple_txn.postings, data.iter_postings(simple_txn)): assert all(source[x] == post[x] for x in range(len(source) - 1)) + assert isinstance(post.account, data.Account) assert post.meta['note'] # Only works with PostingMeta def test_setting_metadata_propagates_to_source(simple_txn):