tests: Add test for trying to make outgoing report without rt-id.

Changes to other test cases are to make them *not* trip up this
error after adding it to the books.
This commit is contained in:
Brett Smith 2020-05-28 17:03:04 -04:00
parent d3e0a38073
commit 3a0b85c8f0
2 changed files with 17 additions and 10 deletions

View file

@ -38,8 +38,7 @@
Expenses:Services:Legal 200.00 USD Expenses:Services:Legal 200.00 USD
Liabilities:Payable:Accounts -200.00 USD Liabilities:Payable:Accounts -200.00 USD
2020-05-15 * "DonorB" "Donation pledge" 2020-05-15 * "MatchingProgram" "May matched donations"
rt-id: "rt://ticket/515"
invoice: "rt://ticket/515/attachments/5150" invoice: "rt://ticket/515/attachments/5150"
approval: "rt://ticket/515/attachments/5140" approval: "rt://ticket/515/attachments/5140"
Income:Donations -1500.00 USD Income:Donations -1500.00 USD

View file

@ -18,6 +18,7 @@ import collections
import copy import copy
import io import io
import itertools import itertools
import logging
import re import re
import pytest import pytest
@ -161,8 +162,8 @@ def test_search_term_parse_regexp_escaping(search, unmatched):
([], ACCRUALS_COUNT, lambda post: post.account.is_under( ([], ACCRUALS_COUNT, lambda post: post.account.is_under(
'Assets:Receivable:', 'Liabilities:Payable:', 'Assets:Receivable:', 'Liabilities:Payable:',
)), )),
([('invoice', '^rt:505/5050$')], 2, lambda post: post.meta['entity'] == 'DonorA'), ([('rt-id', '^rt:505$')], 2, lambda post: post.meta['entity'] == 'DonorA'),
([('rt-id', r'^rt:\D+515$')], 1, lambda post: post.meta['entity'] == 'DonorB'), ([('invoice', r'^rt:\D+515/')], 1, lambda post: post.meta['entity'] == 'MatchingProgram'),
([('entity', '^Lawyer$')], 3, lambda post: post.meta['rt-id'] == 'rt:510'), ([('entity', '^Lawyer$')], 3, lambda post: post.meta['rt-id'] == 'rt:510'),
([('entity', '^Lawyer$'), ('contract', '^rt:510/')], 2, ([('entity', '^Lawyer$'), ('contract', '^rt:510/')], 2,
lambda post: post.meta['invoice'].startswith('rt:510/')), lambda post: post.meta['invoice'].startswith('rt:510/')),
@ -324,6 +325,16 @@ def test_outgoing_report_fx_amounts(accrual_postings, caplog):
r'^TOTAL TO PAY: 1,000\.00 EUR \(\$1,100.00\)$', r'^TOTAL TO PAY: 1,000\.00 EUR \(\$1,100.00\)$',
]) ])
def test_outgoing_report_without_rt_id(accrual_postings, caplog):
invoice = 'rt://ticket/515/attachments/5150'
output = run_outgoing(invoice, accrual_postings)
assert caplog.records
log = caplog.records[0]
assert log.message.startswith(
f"can't generate outgoings report for {invoice} because no RT ticket available:",
)
assert not output.getvalue()
def run_main(arglist, config=None): def run_main(arglist, config=None):
if config is None: if config is None:
config = testutil.TestConfig( config = testutil.TestConfig(
@ -343,9 +354,8 @@ def check_main_fails(arglist, config, error_flags, error_patterns):
assert not output.getvalue() assert not output.getvalue()
@pytest.mark.parametrize('arglist', [ @pytest.mark.parametrize('arglist', [
['--report-type=balance'], ['--report-type=balance', 'entity=EarlyBird'],
['--report-type=outgoing'], ['--report-type=outgoing', 'entity=EarlyBird'],
['entity=EarlyBird'],
]) ])
def test_output_excludes_payments(arglist): def test_output_excludes_payments(arglist):
retcode, output, errors = run_main(arglist) retcode, output, errors = run_main(arglist)
@ -369,7 +379,6 @@ def test_output_payments_when_only_match(arglist, expect_invoice):
]) ])
@pytest.mark.parametrize('arglist', [ @pytest.mark.parametrize('arglist', [
['--report-type=outgoing'],
['510'], ['510'],
['510/6100'], ['510/6100'],
['entity=Lawyer'], ['entity=Lawyer'],
@ -390,9 +399,8 @@ def test_main_outgoing_report(arglist):
@pytest.mark.parametrize('arglist', [ @pytest.mark.parametrize('arglist', [
['-t', 'balance'], ['-t', 'balance'],
['515'],
['515/5150'], ['515/5150'],
['entity=DonorB'], ['entity=MatchingProgram'],
]) ])
def test_main_balance_report(arglist): def test_main_balance_report(arglist):
retcode, output, errors = run_main(arglist) retcode, output, errors = run_main(arglist)