diff --git a/tests/test_data_posting.py b/tests/test_data_posting.py index 9bd33473c38792d2d6b7474e2033d779bcae55c1..a53b1811bea9e1449e5e7d94ba701687234dd38d 100644 --- a/tests/test_data_posting.py +++ b/tests/test_data_posting.py @@ -82,3 +82,27 @@ def test_from_entries_mix_txns_and_other_directives(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 + +@pytest.mark.parametrize('cost_num', [105, 110, 115]) +def test_at_cost(cost_num): + post = data.Posting( + 'Income:Donations', + testutil.Amount(25, 'EUR'), + testutil.Cost(cost_num, 'JPY'), + None, + '*', + None, + ) + assert post.at_cost() == testutil.Amount(25 * cost_num, 'JPY') + +def test_at_cost_no_cost(): + amount = testutil.Amount(25, 'EUR') + post = data.Posting( + 'Income:Donations', + amount, + None, + None, + '*', + None, + ) + assert post.at_cost() == amount