Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing - CET-393 Python SDK - Label purchase error #96

Closed
wants to merge 8 commits into from
10 changes: 8 additions & 2 deletions tests/helpers_custom.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import string
from typing import List

from shippo.models.components import CarriersEnum, CarrierAccount
from shippo.models.operations import ListCarrierAccountsRequest
from shippo.models.components import CarriersEnum, CarrierAccount, Order
from shippo.models.operations import ListCarrierAccountsRequest, ListOrdersRequest

import shippo

Expand All @@ -15,3 +16,8 @@ def get_carrier_accounts(api: shippo.Shippo, carrier: CarriersEnum) -> List[Carr
carrier=carrier
))
return carrier_accounts.results


def get_order_object_id(api: shippo.Shippo) -> string:
orders = api.orders.list(request=ListOrdersRequest())
return orders.results[0].object_id
7 changes: 4 additions & 3 deletions tests/test_instalabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from shippo.models.components import CarriersEnum, DistanceUnitEnum, WeightUnitEnum, \
AddressCreateRequest, ParcelCreateRequest, ShipmentCreateRequest, \
InstantTransactionCreateRequest, Transaction
from tests.helpers_custom import get_carrier_account
from tests.helpers_custom import get_carrier_account, get_order_object_id


# https://docs.goshippo.com/docs/guides_general/single_call/
Expand Down Expand Up @@ -46,8 +46,9 @@ def test_instalabel(self, api: shippo.Shippo):
mass_unit=WeightUnitEnum.LB
)
]
)
))
),
order=get_order_object_id(api)),
)
assert transaction is not None
assert isinstance(transaction, Transaction)
assert transaction.rate.object_id is not None
6 changes: 3 additions & 3 deletions tests/test_purchase_label.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import shippo
from shippo.models.components import CarriersEnum, DistanceUnitEnum, WeightUnitEnum, \
AddressCreateRequest, ShipmentCreateRequest, TransactionCreateRequest, ParcelCreateRequest, Transaction
from tests.helpers_custom import get_carrier_accounts
from tests.helpers_custom import get_carrier_accounts, get_order_object_id


# https://docs.goshippo.com/docs/stories/single_rating_guide/
Expand Down Expand Up @@ -48,7 +48,7 @@ def test_purchase_label(self, api: shippo.Shippo):
assert shipment is not None

transaction = api.transactions.create(
TransactionCreateRequest(rate=shipment.rates[0].object_id)
TransactionCreateRequest(rate=shipment.rates[0].object_id, order=get_order_object_id(api))
)
assert transaction is not None

Expand Down Expand Up @@ -101,7 +101,7 @@ def test_purchase_label_using_reference_ids(self, api: shippo.Shippo):
assert shipment.address_return.object_id == address_from.object_id

transaction = api.transactions.create(
TransactionCreateRequest(rate=shipment.rates[0].object_id)
TransactionCreateRequest(rate=shipment.rates[0].object_id, order=get_order_object_id(api))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a verification on the order here? maybe I'm missing it without looking at the whole file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

)
assert transaction is not None
assert isinstance(transaction, Transaction)
Expand Down