Skip to content

Commit 5331fe4

Browse files
committed
fix: update method
1 parent bff5a0d commit 5331fe4

4 files changed

Lines changed: 113 additions & 46 deletions

File tree

easypost/services/carrier_account_service.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ def retrieve(self, id: str) -> CarrierAccount:
5252

5353
def update(self, id: str, **params) -> CarrierAccount:
5454
"""Update a CarrierAccount."""
55-
if params.get("type") in _UPS_OATH_CARRIER_ACCOUNT_TYPES:
55+
carrier_account = self.retrieve(id)
56+
57+
if carrier_account.get("type") in _UPS_OATH_CARRIER_ACCOUNT_TYPES:
5658
class_name = "UpsOauthRegistrations"
5759
else:
5860
class_name = self._model_class
61+
5962
return self._update_resource(class_name, id, **params)
6063

6164
def delete(self, id: str) -> None:

tests/cassettes/test_carrier_account_update.yaml

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

tests/cassettes/test_carrier_account_update_ups.yaml

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

tests/test_carrier_account.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from unittest.mock import patch
2+
13
import pytest
24
from easypost.errors.api.api_error import ApiError
35
from easypost.models import CarrierAccount
@@ -118,11 +120,14 @@ def test_carrier_account_create_ups(prod_client):
118120

119121

120122
@pytest.mark.vcr()
121-
def test_carrier_account_update_ups(prod_client):
123+
@patch("easypost.services.carrier_account_service.CarrierAccountService.retrieve")
124+
def test_carrier_account_update_ups(mock_retrieve, prod_client):
122125
"""Test updating a UPS Carrier Account.
123126
124127
We purposefully don't pass data here because real data is required for this endpoint
125128
which we don't have in a test context, simply assert that we sent the request correctly.
129+
130+
This test will require someone to ensure the cassette looks the way we want (URL)
126131
"""
127132
carrier_account = {
128133
"type": "UpsAccount",

0 commit comments

Comments
 (0)