Changeset - 69d079190ce7
[Not reviewed]
0 1 0
Brett Smith - 4 years ago 2020-07-02 17:08:21
brettcsmith@brettcsmith.org
tests: Test non-string values for payment-method metadata.
1 file changed with 1 insertions and 0 deletions:
0 comments (0 inline, 0 general)
tests/test_reports_accrual.py
Show inline comments
...
 
@@ -570,48 +570,49 @@ def test_outgoing_report_multi_invoice(accrual_postings, caplog):
 
    'usd ach',
 
    '  eur  wire',
 
    'cad   vendorportal  ',
 
    ' gbp check ',
 
])
 
def test_outgoing_report_good_payment_method(caplog, accrual_postings, arg):
 
    rt_id = 'rt:40'
 
    meta = {'rt-id': rt_id, 'invoice': 'rt:40/100', 'payment-method': arg}
 
    txn = testutil.Transaction(postings=[
 
        ('Liabilities:Payable:Accounts', -100, meta),
 
    ])
 
    rt_client = RTClient()
 
    run_outgoing(rt_id, data.Posting.from_txn(txn), rt_client)
 
    assert not caplog.records
 
    cf_values = rt_client.edits[rt_id[3:]]['CF_payment-method'].split()
 
    assert cf_values[0] == arg.split()[0].upper()
 
    assert len(cf_values) > 1
 

	
 
@pytest.mark.parametrize('arg', [
 
    '',
 
    'usd',
 
    'usd nonexistent',
 
    'check',
 
    'us check',
 
    *testutil.NON_STRING_METADATA_VALUES,
 
])
 
def test_outgoing_report_bad_payment_method(caplog, accrual_postings, arg):
 
    rt_id = 'rt:40'
 
    meta = {'rt-id': rt_id, 'invoice': 'rt:40/100', 'payment-method': arg}
 
    txn = testutil.Transaction(postings=[
 
        ('Liabilities:Payable:Accounts', -100, meta),
 
    ])
 
    rt_client = RTClient()
 
    run_outgoing(rt_id, data.Posting.from_txn(txn), rt_client)
 
    assert caplog.records
 
    for log in caplog.records:
 
        assert log.levelname == 'WARNING'
 
        assert log.message.startswith(f'cannot set payment-method for {rt_id}: ')
 
    assert 'CF_payment-method' not in rt_client.edits[rt_id[3:]]
 

	
 
def test_outgoing_report_without_rt_id(accrual_postings, caplog):
 
    invoice = 'rt://ticket/515/attachments/5150'
 
    related = accruals_by_meta(
 
        accrual_postings, invoice, wrap_type=accrual.AccrualPostings,
 
    )
 
    output = run_outgoing(None, related)
 
    assert caplog.records
 
    log = caplog.records[0]
 
    assert log.message.startswith(
0 comments (0 inline, 0 general)