From a999c9b3fb4767546d70032af62bdd0f873311c9 Mon Sep 17 00:00:00 2001 From: KaseyCantu Date: Thu, 10 Jun 2021 09:39:12 -0500 Subject: [PATCH 1/3] DX-1076 - Multiple carrier accounts. https://auctane.atlassian.net/browse/DX-1076 --- tests/services/test_get_carrier_accounts.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/services/test_get_carrier_accounts.py b/tests/services/test_get_carrier_accounts.py index bc106bc..3e24ad0 100644 --- a/tests/services/test_get_carrier_accounts.py +++ b/tests/services/test_get_carrier_accounts.py @@ -28,3 +28,24 @@ def test_no_accounts_setup(self) -> None: assert type(accounts) is list assert len(accounts) == 0 + + def test_multiple_accounts(self) -> None: + """DX-1076 - Multiple carrier accounts.""" + accounts = stub_get_carrier_accounts() + + assert len(accounts) == 5 + assert accounts[0]["carrier"]["code"] == Carriers.UPS.value + assert accounts[1]["carrier"]["code"] == Carriers.FEDEX.value + assert accounts[2]["carrier"]["code"] == Carriers.FEDEX.value + assert accounts[3]["carrier"]["code"] == Carriers.USPS.value + assert accounts[4]["carrier"]["code"] == Carriers.STAMPS_COM.value + + for account in accounts: + assert account["account_id"].startswith("car_") + assert account["name"] is not None + assert account["account_number"] is not None + assert account["carrier"] is not None + assert account["carrier"]["code"] is not None + assert type(account["carrier"]["code"]) == str + assert account["carrier"]["name"] is not None + assert type(account["carrier"]["name"]) == str From 60b52184ee2067ce0553d67610f3024b7f101d36 Mon Sep 17 00:00:00 2001 From: KaseyCantu Date: Thu, 10 Jun 2021 09:41:13 -0500 Subject: [PATCH 2/3] Fixed order of tests to match ticket number order. --- tests/services/test_get_carrier_accounts.py | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/services/test_get_carrier_accounts.py b/tests/services/test_get_carrier_accounts.py index 3e24ad0..20be7b7 100644 --- a/tests/services/test_get_carrier_accounts.py +++ b/tests/services/test_get_carrier_accounts.py @@ -6,22 +6,6 @@ class TestGetCarrierAccounts: - def test_multiple_accounts_of_same_carrier(self): - """DX-1077 - Multiple accounts of the same carrier.""" - accounts = stub_get_carrier_accounts() - - assert len(accounts) == 5 - assert accounts[0]["carrier"]["code"] == Carriers.UPS.value - assert accounts[0]["account_id"] != accounts[1]["account_id"] - assert accounts[1]["carrier"]["code"] == Carriers.FEDEX.value - assert accounts[2]["carrier"]["code"] == Carriers.FEDEX.value - assert accounts[3]["carrier"]["code"] == Carriers.USPS.value - assert accounts[4]["carrier"]["code"] == Carriers.STAMPS_COM.value - - for account in accounts: - assert account["account_id"].startswith("car_") - assert account["name"] is not None - def test_no_accounts_setup(self) -> None: """DX-1075 - No accounts setup yet.""" accounts = stub_get_carrier_accounts(carrier_code="sendle") @@ -49,3 +33,19 @@ def test_multiple_accounts(self) -> None: assert type(account["carrier"]["code"]) == str assert account["carrier"]["name"] is not None assert type(account["carrier"]["name"]) == str + + def test_multiple_accounts_of_same_carrier(self): + """DX-1077 - Multiple accounts of the same carrier.""" + accounts = stub_get_carrier_accounts() + + assert len(accounts) == 5 + assert accounts[0]["carrier"]["code"] == Carriers.UPS.value + assert accounts[0]["account_id"] != accounts[1]["account_id"] + assert accounts[1]["carrier"]["code"] == Carriers.FEDEX.value + assert accounts[2]["carrier"]["code"] == Carriers.FEDEX.value + assert accounts[3]["carrier"]["code"] == Carriers.USPS.value + assert accounts[4]["carrier"]["code"] == Carriers.STAMPS_COM.value + + for account in accounts: + assert account["account_id"].startswith("car_") + assert account["name"] is not None From cd69d4651c1b4ef5a8c9f201280bd87e194ce170 Mon Sep 17 00:00:00 2001 From: KaseyCantu Date: Thu, 10 Jun 2021 09:53:46 -0500 Subject: [PATCH 3/3] DX-1078 - Get carrier accounts server-side error https://auctane.atlassian.net/browse/DX-1078 --- tests/services/test_get_carrier_accounts.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/services/test_get_carrier_accounts.py b/tests/services/test_get_carrier_accounts.py index 20be7b7..ef251e6 100644 --- a/tests/services/test_get_carrier_accounts.py +++ b/tests/services/test_get_carrier_accounts.py @@ -1,6 +1,6 @@ """Tests for the GetCarrierAccounts service in the ShipEngine SDK.""" - -from shipengine_sdk.models import Carriers +from shipengine_sdk.errors import ClientSystemError +from shipengine_sdk.models import Carriers, ErrorCode, ErrorSource, ErrorType from ..util.test_helpers import stub_get_carrier_accounts @@ -49,3 +49,14 @@ def test_multiple_accounts_of_same_carrier(self): for account in accounts: assert account["account_id"].startswith("car_") assert account["name"] is not None + + def test_server_side_error(self) -> None: + """DX-1078 - Get carrier accounts server-side error.""" + try: + stub_get_carrier_accounts("access_worldwide") + except ClientSystemError as err: + assert err.request_id is not None + assert err.request_id.startswith("req_") is True + assert err.source == ErrorSource.SHIPENGINE.value + assert err.error_type == ErrorType.SYSTEM.value + assert err.error_code == ErrorCode.UNSPECIFIED.value