diff --git a/tests/test_meta_entity.py b/tests/test_meta_entity.py index 4542fa4769b22f9acb0296e98a58b92ef02a684d..f9caac672f38310b313b0a601b489658a7dbc7a2 100644 --- a/tests/test_meta_entity.py +++ b/tests/test_meta_entity.py @@ -110,6 +110,36 @@ def test_invalid_values_on_transactions(hook, src_value): assert all(error.message == "transaction has invalid entity: {}".format(src_value) for error in hook.run(txn)) +@pytest.mark.parametrize('src_value', VALID_VALUES) +def test_valid_values_on_payee(hook, src_value): + txn = testutil.Transaction(payee=src_value, postings=[ + ('Assets:Cash', -25), + ('Expenses:General', 25), + ]) + assert not any(hook.run(txn)) + +@pytest.mark.parametrize('src_value', INVALID_VALUES) +def test_invalid_values_on_payee(hook, src_value): + txn = testutil.Transaction(payee=src_value, postings=[ + ('Assets:Cash', -25), + ('Expenses:General', 25), + ]) + errors = list(hook.run(txn)) + assert 1 <= len(errors) <= 2 + assert all(error.message == "transaction has invalid entity: {}".format(src_value) + for error in hook.run(txn)) + +@pytest.mark.parametrize('payee,src_value', testutil.combine_values( + INVALID_VALUES, + VALID_VALUES, +)) +def test_invalid_payee_but_valid_metadata(hook, payee, src_value): + txn = testutil.Transaction(**{'payee': payee, TEST_KEY: src_value}, postings=[ + ('Assets:Cash', -25), + ('Expenses:Other', 25), + ]) + assert not any(hook.run(txn)) + @pytest.mark.parametrize('account,required', [ ('Assets:Bank:Checking', False), ('Assets:Cash', False),