File diff 44762555d5eb → 8755d6af6700
tests/test_hook_ledger_entry.py
Show inline comments
...
 
@@ -161,48 +161,65 @@ def test_multiple_postings_same_account():
 
def test_custom_payee_line():
 
    render_vars = template_vars('ZZ', '10.00', other_vars={
 
        'custom_date': datetime.date(2014, 2, 13),
 
    })
 
    lines = render_lines(render_vars, 'Custom Payee')
 
    assert lines == [
 
        "",
 
        "2014/02/13  ZZ - Custom",
 
        "  Accrued:Accounts Receivable  10.00 USD",
 
        "  Income:Donations  -10.00 USD",
 
    ]
 

	
 
def test_line1_not_custom_payee():
 
    render_vars = template_vars('VV', '15.00', other_vars={
 
        'custom_date': datetime.date(2014, 2, 12),
 
    })
 
    lines = render_lines(render_vars, 'Simplest')
 
    assert lines == [
 
        "",
 
        "2015/03/14 VV",
 
        "  Accrued:Accounts Receivable  15.00 USD",
 
        "  Income:Donations  -15.00 USD",
 
    ]
 

	
 
@pytest.mark.parametrize('amount,expect_fee', [
 
    (40, 3),
 
    (80, 6),
 
])
 
def test_conditional(amount, expect_fee):
 
    expect_cash = amount - expect_fee
 
    amount_s = '{:.02f}'.format(amount)
 
    render_vars = template_vars('Buyer', amount_s)
 
    lines = render_lines(render_vars, 'Conditional')
 
    assert lines == [
 
        "",
 
        "2015/03/14 Buyer",
 
        "  Assets:Cash  {:.02f} USD".format(expect_cash),
 
        "  Expenses:Banking Fees  {:.02f} USD".format(expect_fee),
 
        "  Income:Sales  -{} USD".format(amount_s),
 
    ]
 

	
 
@pytest.mark.parametrize('amount_expr', [
 
    '',
 
    'name',
 
    '-',
 
    '()',
 
    '+()',
 
    '{}',
 
    '{{}}',
 
    '{()}',
 
    '{name',
 
    'name}',
 
    '{42}',
 
    '(5).real',
 
    '{amount.real}',
 
    '{amount.is_nan()}',
 
    '{Decimal}',
 
    '{FOO}',
 
])
 
def test_bad_amount_expression(amount_expr):
 
    with pytest.raises(errors.UserInputError):
 
        ledger_entry.Template(" Income  " + amount_expr)
 

	
 
class Config:
 
    def __init__(self, use_section):