Skip to content

Commit cd553e0

Browse files
committed
fix: error type
1 parent d12584f commit cd553e0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

easypost/services/billing_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
NO_BILLING_ERROR,
1010
)
1111
from easypost.easypost_object import convert_to_easypost_object
12-
from easypost.errors import PaymentError
12+
from easypost.errors import InvalidObjectError
1313
from easypost.models import Billing
1414
from easypost.requestor import (
1515
RequestMethod,
@@ -49,7 +49,7 @@ def retrieve_payment_methods(self, **params) -> Dict[str, Any]:
4949
)
5050

5151
if response.get("id") is None:
52-
raise PaymentError(message=NO_BILLING_ERROR)
52+
raise InvalidObjectError(message=NO_BILLING_ERROR)
5353

5454
return convert_to_easypost_object(response=response)
5555

@@ -71,8 +71,8 @@ def _get_payment_method_info(self, priority: str = "primary") -> List[str]:
7171
elif payment_method_id.startswith("bank_"):
7272
endpoint = "/bank_accounts"
7373
else:
74-
raise PaymentError(message=INVALID_PAYMENT_METHOD_ERROR)
74+
raise InvalidObjectError(message=INVALID_PAYMENT_METHOD_ERROR)
7575
else:
76-
raise PaymentError(message=INVALID_PAYMENT_METHOD_ERROR)
76+
raise InvalidObjectError(message=INVALID_PAYMENT_METHOD_ERROR)
7777

7878
return [endpoint, payment_method_id]

tests/test_billing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44

55
import easypost
6-
from easypost.errors import PaymentError
6+
from easypost.errors import InvalidObjectError
77

88

99
@patch(
@@ -54,7 +54,7 @@ def test_billing_payment_method_delete_bank_account(mock_request, mock_payment_m
5454
@patch("easypost.services.billing_service.Requestor.request", return_value={"mock": "response"})
5555
def test_billing_payment_method_delete_invalid(mock_request, mock_payment_methods, prod_client):
5656
"""Tests we raise an error when we receive an invalid payment method"""
57-
with pytest.raises(PaymentError):
57+
with pytest.raises(InvalidObjectError):
5858
_ = prod_client.billing.delete_payment_method(priority="primary")
5959

6060

@@ -65,7 +65,7 @@ def test_billing_payment_method_delete_invalid(mock_request, mock_payment_method
6565
@patch("easypost.services.billing_service.Requestor.request", return_value={"mock": "response"})
6666
def test_billing_payment_method_delete_bad_request(mock_request, mock_payment_methods, prod_client):
6767
"""Tests we raise an error when we cannot retrieve a payment method."""
68-
with pytest.raises(PaymentError):
68+
with pytest.raises(InvalidObjectError):
6969
_ = prod_client.billing.delete_payment_method(priority="tertiary")
7070

7171

@@ -81,7 +81,7 @@ def test_billing_retrieve_payment_methods(mock_request, prod_client):
8181
@patch("easypost.services.billing_service.Requestor.request", return_value={"mock": "response"})
8282
def test_billing_retrieve_payment_methods_no_billing_setup(mock_request, prod_client):
8383
"""Tests that we throw an error when we cannot retrieve payment methods due to no billing being setup."""
84-
with pytest.raises(PaymentError) as error:
84+
with pytest.raises(InvalidObjectError) as error:
8585
_ = prod_client.billing.retrieve_payment_methods()
8686

8787
mock_request.assert_called_once()

0 commit comments

Comments
 (0)