From feab9d3c2bbdae22902e91eeb424d39f1fd7c5cc Mon Sep 17 00:00:00 2001 From: Randall Keur Date: Thu, 7 Nov 2024 19:51:23 -0500 Subject: [PATCH] add test for creating an order --- tests/test_create_order.py | 74 ++++++++++++++++++++++++++++++++++++++ tests/test_instalabel.py | 2 +- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 tests/test_create_order.py diff --git a/tests/test_create_order.py b/tests/test_create_order.py new file mode 100644 index 0000000..e1b77b8 --- /dev/null +++ b/tests/test_create_order.py @@ -0,0 +1,74 @@ +from dateutil.parser import isoparse + +import shippo +from shippo.models.components import OrderCreateRequest, LineItemBase, WeightUnitEnum, AddressCreateRequest, \ + OrderStatusEnum + + +class TestCreateOrder: + + def test_create_order(self, api: shippo.Shippo): + order = api.orders.create(request=OrderCreateRequest( + placed_at='2016-09-23T01:28:12Z', + to_address=AddressCreateRequest( + country='US', + name='Shwan Ippotle', + company='Shippo', + street1='215 Clayton St.', + street3='', + street_no='', + city='San Francisco', + state='CA', + zip='94117', + phone='+1 555 341 9393', + email='shippotle@shippo.com', + is_residential=True, + metadata='Customer ID 123456', + validate=True, + ), + currency='USD', + notes='This customer is a VIP', + order_number='#1068', + order_status=OrderStatusEnum.PAID, + shipping_cost='12.83', + shipping_cost_currency='USD', + shipping_method='USPS First Class Package', + subtotal_price='12.1', + total_price='24.93', + total_tax='0.0', + weight='0.4', + weight_unit=WeightUnitEnum.LB, + from_address=AddressCreateRequest( + country='US', + name='Shwan Ippotle', + company='Shippo', + street1='215 Clayton St.', + street3='', + street_no='', + city='San Francisco', + state='CA', + zip='94117', + phone='+1 555 341 9393', + email='shippotle@shippo.com', + is_residential=True, + metadata='Customer ID 123456', + validate=True, + ), + line_items=[ + LineItemBase( + currency='USD', + manufacture_country='US', + max_delivery_time=isoparse('2016-07-23T00:00:00Z'), + max_ship_time=isoparse('2016-07-23T00:00:00Z'), + quantity=20, + sku='HM-123', + title='Hippo Magazines', + total_price='12.1', + variant_title='June Edition', + weight='0.4', + weight_unit=WeightUnitEnum.LB, + ), + ], + )) + + assert order is not None diff --git a/tests/test_instalabel.py b/tests/test_instalabel.py index 1255ada..8c537ba 100644 --- a/tests/test_instalabel.py +++ b/tests/test_instalabel.py @@ -47,7 +47,7 @@ def test_instalabel(self, api: shippo.Shippo): ) ] ), - order=get_order_object_id(api)), + order=get_order_object_id(api)), ) assert transaction is not None assert isinstance(transaction, Transaction)