tests: Test updates for accrual report changes in the last commit.
Where assertions are removed from individual tests, I believe that functionality is covered by other tests (although probably not to the extent of checking multiple splits).
This commit is contained in:
parent
8ec3a12d5a
commit
ea69d58957
1 changed files with 12 additions and 8 deletions
|
@ -54,13 +54,21 @@ ACCRUALS_COUNT = sum(
|
|||
if post.account.startswith(('Assets:Receivable:', 'Liabilities:Payable:'))
|
||||
)
|
||||
|
||||
ACCOUNTS = [
|
||||
# Accounts where invoice and entity metadata are both used to identify accruals.
|
||||
INVOICE_ACCOUNTS = [
|
||||
'Assets:Receivable:Accounts',
|
||||
'Assets:Receivable:Loans',
|
||||
'Liabilities:Payable:Accounts',
|
||||
]
|
||||
|
||||
# Accounts where only entity metadata is used to identify accruals.
|
||||
ENTITY_ACCOUNTS = [
|
||||
'Assets:Prepaid:Expenses',
|
||||
'Liabilities:Payable:Vacation',
|
||||
]
|
||||
|
||||
ACCOUNTS = INVOICE_ACCOUNTS + ENTITY_ACCOUNTS
|
||||
|
||||
AGE_SUM_RE = re.compile(r'(?:\b(\d+) Years?)?(?: ?\b(\d+) Days?)?[–:]')
|
||||
|
||||
class AgingRow(NamedTuple):
|
||||
|
@ -268,7 +276,7 @@ def test_report_type_by_unknown_name(arg):
|
|||
accrual.ReportType.by_name(arg)
|
||||
|
||||
@pytest.mark.parametrize('acct_name,invoice,day', testutil.combine_values(
|
||||
ACCOUNTS,
|
||||
INVOICE_ACCOUNTS,
|
||||
['FIXME', '', None, *testutil.NON_STRING_METADATA_VALUES],
|
||||
itertools.count(1),
|
||||
))
|
||||
|
@ -321,7 +329,7 @@ def test_make_consistent_across_entity(acct_name):
|
|||
for key, posts in consistent.items():
|
||||
assert len(posts) == 1
|
||||
|
||||
@pytest.mark.parametrize('acct_name', ACCOUNTS)
|
||||
@pytest.mark.parametrize('acct_name', INVOICE_ACCOUNTS)
|
||||
def test_make_consistent_entity_differs_accrual_payment(acct_name):
|
||||
invoice = 'Invoices/DifferPay.pdf'
|
||||
txn = testutil.Transaction(postings=[
|
||||
|
@ -429,7 +437,6 @@ def test_make_consistent_with_three_one_split(account, day):
|
|||
entries = [testutil.Transaction(date=datetime.date(2019, 5, dd), postings=[(
|
||||
account, dd, meta,
|
||||
)]) for dd in [5, 15, 25]]
|
||||
meta['entity'] = '1Split'
|
||||
entries.insert(day // 10, testutil.Transaction(
|
||||
date=datetime.date(2019, 5, day),
|
||||
postings=[(account, -45, meta)],
|
||||
|
@ -446,12 +453,10 @@ def test_make_consistent_with_three_one_split(account, day):
|
|||
for related in actual.values():
|
||||
assert len(related) == post_count
|
||||
assert sum(post.units.number for post in related) == 0
|
||||
assert all(post.meta['invoice'] == meta['invoice'] for post in related)
|
||||
assert {post.meta['entity'] for post in related} == {'1Split', '3Split'}
|
||||
|
||||
@pytest.mark.parametrize('account', ACCOUNTS)
|
||||
def test_make_consistent_with_three_two_split(account):
|
||||
meta = {'rt-id': '1', 'invoice': 'rt:1/9'}
|
||||
meta = {'rt-id': '1', 'invoice': 'rt:1/9', 'entity': '5Split'}
|
||||
entries = [testutil.Transaction(date=datetime.date(2019, 5, day), postings=[(
|
||||
account, day * (1 if day % 10 else -1.5), meta,
|
||||
)]) for day in range(5, 30, 5)]
|
||||
|
@ -465,7 +470,6 @@ def test_make_consistent_with_three_two_split(account):
|
|||
for related in actual.values():
|
||||
assert len(related) >= 2
|
||||
assert sum(post.units.number for post in related) == 0
|
||||
assert all(post.meta['invoice'] == meta['invoice'] for post in related)
|
||||
|
||||
def check_output(output, expect_patterns):
|
||||
output.seek(0)
|
||||
|
|
Loading…
Reference in a new issue