Skip to content

Commit 5be741a

Browse files
committed
fix: ups carrier account tests
1 parent 4f93a56 commit 5be741a

6 files changed

Lines changed: 326 additions & 67 deletions

File tree

easypost/constant.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@
3636
"FedexAccount",
3737
"FedexSmartpostAccount",
3838
]
39-
_UPS_OATH_CARRIER_ACCOUNT_TYPES = [
39+
_UPS_OAUTH_CARRIER_ACCOUNT_TYPES = [
4040
"UpsAccount",
4141
"UpsMailInnovationsAccount",
4242
"UpsSurepostAccount",
4343
]
4444
_FILTERS_KEY = "filters"
45+
_EXCLUDED_CLASS_NAMES = ["ups_oauth_registrations"]

easypost/services/base_service.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
)
77

88
from easypost.constant import (
9+
_EXCLUDED_CLASS_NAMES,
910
_FILTERS_KEY,
1011
NO_MORE_PAGES_ERROR,
1112
)
@@ -30,7 +31,9 @@ def _snakecase_name(self, class_name: str) -> str:
3031
def _class_url(self, class_name: str) -> str:
3132
"""Generate a URL based on class name."""
3233
transformed_class_name = self._snakecase_name(class_name)
33-
if transformed_class_name[-1:] in ("s", "h"):
34+
if transformed_class_name in _EXCLUDED_CLASS_NAMES:
35+
return f"/{transformed_class_name}"
36+
elif transformed_class_name[-1:] in ("s", "h"):
3437
return f"/{transformed_class_name}es"
3538
else:
3639
return f"/{transformed_class_name}s"

easypost/services/carrier_account_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from easypost.constant import (
99
_CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOWS,
10-
_UPS_OATH_CARRIER_ACCOUNT_TYPES,
10+
_UPS_OAUTH_CARRIER_ACCOUNT_TYPES,
1111
MISSING_PARAMETER_ERROR,
1212
)
1313
from easypost.easypost_object import convert_to_easypost_object
@@ -33,7 +33,7 @@ def create(self, **params) -> CarrierAccount:
3333
raise MissingParameterError(MISSING_PARAMETER_ERROR.format("type"))
3434

3535
url = self._select_carrier_account_creation_endpoint(carrier_account_type=carrier_account_type)
36-
if carrier_account_type in _UPS_OATH_CARRIER_ACCOUNT_TYPES:
36+
if carrier_account_type in _UPS_OAUTH_CARRIER_ACCOUNT_TYPES:
3737
wrapped_params = {"ups_oauth_registrations": params}
3838
else:
3939
wrapped_params = {self._snakecase_name(self._model_class): params}
@@ -54,7 +54,7 @@ def update(self, id: str, **params) -> CarrierAccount:
5454
"""Update a CarrierAccount."""
5555
carrier_account = self.retrieve(id)
5656

57-
if carrier_account.get("type") in _UPS_OATH_CARRIER_ACCOUNT_TYPES:
57+
if carrier_account.get("type") in _UPS_OAUTH_CARRIER_ACCOUNT_TYPES:
5858
class_name = "UpsOauthRegistrations"
5959
else:
6060
class_name = self._model_class
@@ -75,7 +75,7 @@ def _select_carrier_account_creation_endpoint(self, carrier_account_type: Option
7575
"""Determines which API endpoint to use for the creation call."""
7676
if carrier_account_type in _CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOWS:
7777
return "/carrier_accounts/register"
78-
elif carrier_account_type in _UPS_OATH_CARRIER_ACCOUNT_TYPES:
78+
elif carrier_account_type in _UPS_OAUTH_CARRIER_ACCOUNT_TYPES:
7979
return "/ups_oauth_registrations"
8080

8181
return "/carrier_accounts"

tests/cassettes/test_carrier_account_create_ups.yaml

Lines changed: 80 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)