File diff 8b8bdc022508 → d7e2ab34b925
tests/test_meta_project.py
Show inline comments
...
 
@@ -109,6 +109,8 @@ def test_which_accounts_required_on(hook, account, required):
 
    assert required == any(errors)
 

	
 
@pytest.mark.parametrize('account', [
 
    'Equity:Funds:Unrestricted',
 
    'Equity:Realized:CurrencyConversion',
 
    'Expenses:Payroll:Salary',
 
    'Expenses:Payroll:Tax',
 
    'Liabilities:Payable:Vacation',
...
 
@@ -122,6 +124,38 @@ def test_default_values(hook, account):
 
    assert not errors
 
    testutil.check_post_meta(txn, None, {TEST_KEY: DEFAULT_VALUE})
 

	
 
@pytest.mark.parametrize('equity,other_acct,value', testutil.combine_values(
 
    ['Equity:Funds:Unrestricted', 'Equity:Realized:CurrencyConversion'],
 
    ['Assets:Checking', 'Liabilities:CreditCard'],
 
    VALID_VALUES,
 
))
 
def test_equity_override_txn_meta(hook, equity, other_acct, value):
 
    if value == DEFAULT_VALUE:
 
        value = f'Not{value}'
 
    txn = testutil.Transaction(**{TEST_KEY: value}, postings=[
 
        (other_acct, 100),
 
        (equity, -100),
 
    ])
 
    errors = list(hook.run(txn))
 
    assert not errors
 
    testutil.check_post_meta(txn, None, {TEST_KEY: DEFAULT_VALUE})
 

	
 
@pytest.mark.parametrize('equity,other_acct,value', testutil.combine_values(
 
    ['Equity:Funds:Unrestricted', 'Equity:Realized:CurrencyConversion'],
 
    ['Assets:Checking', 'Liabilities:CreditCard'],
 
    VALID_VALUES,
 
))
 
def test_equity_override_post_meta(hook, equity, other_acct, value):
 
    if value == DEFAULT_VALUE:
 
        value = f'Not{value}'
 
    txn = testutil.Transaction(postings=[
 
        (other_acct, 100),
 
        (equity, -100, {TEST_KEY: value}),
 
    ])
 
    actual = {error.message for error in hook.run(txn)}
 
    assert actual == {f"{equity} has invalid {TEST_KEY}: {value}"}
 
    testutil.check_post_meta(txn, None, {TEST_KEY: DEFAULT_VALUE})
 

	
 
@pytest.mark.parametrize('date,required', [
 
    (testutil.EXTREME_FUTURE_DATE, False),
 
    (testutil.FUTURE_DATE, True),