Skip to content

Commit

Permalink
add test for creating an order
Browse files Browse the repository at this point in the history
  • Loading branch information
rkeur7 committed Nov 8, 2024
1 parent 7f715b0 commit feab9d3
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
74 changes: 74 additions & 0 deletions tests/test_create_order.py
Original file line number Diff line number Diff line change
@@ -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='[email protected]',
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='[email protected]',
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
2 changes: 1 addition & 1 deletion tests/test_instalabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit feab9d3

Please sign in to comment.