diff --git a/arcus/exc.py b/arcus/exc.py index 7750f53..5019c06 100644 --- a/arcus/exc.py +++ b/arcus/exc.py @@ -248,7 +248,7 @@ def __init__(self, **kwargs): R16=FailedConsult, R17=InvalidAmount, R18=LimitExceeded, - R19=InvalidBiller, + R19=UnprocessableEntity, R20=InvalidBiller, R21=InvalidBiller, R22=BillerMaintenance, diff --git a/arcus/version.py b/arcus/version.py index 240371d..61a7ce1 100644 --- a/arcus/version.py +++ b/arcus/version.py @@ -1 +1 @@ -__version__ = '1.2.8' # pragma: no cover +__version__ = '1.2.9' # pragma: no cover diff --git a/tests/resources/cassettes/test_bill_payment_type_error.yaml b/tests/resources/cassettes/test_bill_payment_type_error.yaml new file mode 100644 index 0000000..84d112b --- /dev/null +++ b/tests/resources/cassettes/test_bill_payment_type_error.yaml @@ -0,0 +1,29 @@ +interactions: +- request: + body: '{"biller_id": 13599, "account_number": "559999", "amount": 100.0, "currency": + "MXN", "name_on_account": null}' + headers: + Accept: [application/vnd.regalii.v1.6+json] + Accept-Encoding: ['gzip, deflate'] + Authorization: ['APIAuth 88879c1b066dc9aea6201f27be2bbba9:5ZV1v+AlHt7SGRwJ+RFD0tYRQr8='] + Connection: [keep-alive] + Content-Length: ['109'] + Content-MD5: [U86ULvlq1wG/DVe1HygOkw==] + Content-Type: [application/json] + Date: ['Wed, 25 Sep 2019 23:47:50 GMT'] + User-Agent: [python-requests/2.21.0] + method: POST + uri: https://api.casiregalii.com/bill/pay + response: + body: {string: '{"code":"R19","message":"Payments with this biller are currently unavailable","mode":"STAGING"}'} + headers: + Cache-Control: [no-cache] + Connection: [keep-alive] + Content-Type: [application/json; charset=utf-8] + Date: ['Wed, 25 Sep 2019 23:47:51 GMT'] + Strict-Transport-Security: [max-age=31536000; includeSubDomains] + Transfer-Encoding: [chunked] + X-Request-Id: [7291a4fe-e4da-4133-9098-81dfb73df0e0] + X-Runtime: ['0.043308'] + status: {code: 422, message: Unprocessable Entity} +version: 1 diff --git a/tests/resources/test_bill_payments.py b/tests/resources/test_bill_payments.py index 73e8795..9b998ef 100644 --- a/tests/resources/test_bill_payments.py +++ b/tests/resources/test_bill_payments.py @@ -1,6 +1,6 @@ import pytest -from arcus.exc import InvalidAccountNumber +from arcus.exc import InvalidAccountNumber, UnprocessableEntity from arcus.resources import BillPayment @@ -40,6 +40,18 @@ def test_bill_payment_invalid_phone_number(client): assert exc.biller_id == biller_id +@pytest.mark.vcr +def test_bill_payment_type_error(client): + biller_id = 13599 + account_number = '559999' + amount = 100.0 + with pytest.raises(UnprocessableEntity) as excinfo: + client.bill_payments.create(biller_id, account_number, amount) + exc = excinfo.value + assert exc.account_number == account_number + assert exc.biller_id == biller_id + + def test_bill_payment_list(client): with pytest.raises(NotImplementedError): client.bill_payments.list()