tests: Generate configuration in accrual-report tests.
Usually reduces the amount of testing boilerplate.
This commit is contained in:
parent
396173b55d
commit
13df0390a1
1 changed files with 10 additions and 16 deletions
|
@ -346,7 +346,12 @@ def test_outgoing_report_custom_field_fallbacks(accrual_postings):
|
|||
r'^PAYMENT METHOD:\s*$',
|
||||
])
|
||||
|
||||
def run_main(arglist, config):
|
||||
def run_main(arglist, config=None):
|
||||
if config is None:
|
||||
config = testutil.TestConfig(
|
||||
books_path=testutil.test_path('books/accruals.beancount'),
|
||||
rt_client=RTClient(),
|
||||
)
|
||||
output = io.StringIO()
|
||||
errors = io.StringIO()
|
||||
retcode = accrual.main(arglist, output, errors, config)
|
||||
|
@ -366,15 +371,10 @@ def check_main_fails(arglist, config, error_flags, error_patterns):
|
|||
['entity=Lawyer'],
|
||||
])
|
||||
def test_main_outgoing_report(arglist):
|
||||
rt_client = RTClient()
|
||||
config = testutil.TestConfig(
|
||||
books_path=testutil.test_path('books/accruals.beancount'),
|
||||
rt_client=rt_client,
|
||||
)
|
||||
retcode, output, errors = run_main(arglist, config)
|
||||
retcode, output, errors = run_main(arglist)
|
||||
assert not errors.getvalue()
|
||||
assert retcode == 0
|
||||
rt_url = rt_client.DEFAULT_URL[:-9]
|
||||
rt_url = RTClient.DEFAULT_URL[:-9]
|
||||
rt_id_url = re.escape(f'<{rt_url}Ticket/Display.html?id=510>')
|
||||
contract_url = re.escape(f'<{rt_url}Ticket/Attachment/4000/4000/contract.pdf>')
|
||||
check_output(output, [
|
||||
|
@ -391,10 +391,7 @@ def test_main_outgoing_report(arglist):
|
|||
['entity=DonorB'],
|
||||
])
|
||||
def test_main_balance_report(arglist):
|
||||
config = testutil.TestConfig(
|
||||
books_path=testutil.test_path('books/accruals.beancount'),
|
||||
)
|
||||
retcode, output, errors = run_main(arglist, config)
|
||||
retcode, output, errors = run_main(arglist)
|
||||
assert not errors.getvalue()
|
||||
assert retcode == 0
|
||||
check_output(output, [
|
||||
|
@ -413,10 +410,7 @@ def test_main_no_books():
|
|||
['entity=NonExistent'],
|
||||
])
|
||||
def test_main_no_matches(arglist):
|
||||
config = testutil.TestConfig(
|
||||
books_path=testutil.test_path('books/accruals.beancount'),
|
||||
)
|
||||
check_main_fails(arglist, config, 8, [
|
||||
check_main_fails(arglist, None, 8, [
|
||||
r'^warning: no matching entries found to report$',
|
||||
])
|
||||
|
||||
|
|
Loading…
Reference in a new issue