Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6e8aa80

Browse files
authoredJul 28, 2022
Add patch.estimates methods for GLEC-certified shipping estimates (#63)
* Add patch.estimates methods for GLEC-certified shipping estimates * Fix lint * Update changelog for python syntax * Lowercase constant values, update air param variable names * Remove distance_m * Not sure why freight_mass_g wasn't included
1 parent c5ae775 commit 6e8aa80

19 files changed

+2818
-41
lines changed
 

‎CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.24.0] - 2022-07-22
9+
10+
### Added
11+
12+
- Adds `patch.estimates.create_air_shipping_estimate` method
13+
- Adds `patch.estimates.create_rail_shipping_estimate` method
14+
- Adds `patch.estimates.create_road_shipping_estimate` method
15+
- Adds `patch.estimates.create_sea_shipping_estimate` method
16+
817
## [1.23.0] - 2022-06-03
918

1019
### Added

‎patch_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from __future__ import absolute_import
1717

18-
__version__ = "1.23.0"
18+
__version__ = "1.24.0"
1919

2020
# import ApiClient
2121
from patch_api.api_client import ApiClient

‎patch_api/api/estimates_api.py

Lines changed: 745 additions & 27 deletions
Large diffs are not rendered by default.

‎patch_api/api/orders_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class OrdersApi(object):
4646
"average_daily_balance_btc_sats",
4747
"average_daily_balance_eth_gwei",
4848
"timestamp",
49-
"origin_aiport",
50-
"destination_aiport",
49+
"origin_airport",
50+
"destination_airport",
5151
"aircraft_code",
5252
"cabin_class",
5353
"passenger_count",

‎patch_api/api/projects_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class ProjectsApi(object):
4646
"average_daily_balance_btc_sats",
4747
"average_daily_balance_eth_gwei",
4848
"timestamp",
49-
"origin_aiport",
50-
"destination_aiport",
49+
"origin_airport",
50+
"destination_airport",
5151
"aircraft_code",
5252
"cabin_class",
5353
"passenger_count",

‎patch_api/api/technology_types_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class TechnologyTypesApi(object):
4646
"average_daily_balance_btc_sats",
4747
"average_daily_balance_eth_gwei",
4848
"timestamp",
49-
"origin_aiport",
50-
"destination_aiport",
49+
"origin_airport",
50+
"destination_airport",
5151
"aircraft_code",
5252
"cabin_class",
5353
"passenger_count",

‎patch_api/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(
9191
self.default_headers[header_name] = header_value
9292
self.cookie = cookie
9393
# Set default User-Agent.
94-
self.user_agent = "patch-python/1.23.0"
94+
self.user_agent = "patch-python/1.24.0"
9595

9696
def __del__(self):
9797
if self._pool:

‎patch_api/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def to_debug_report(self):
341341
"OS: {env}\n"
342342
"Python Version: {pyversion}\n"
343343
"Version of the API: v1\n"
344-
"SDK Package Version: 1.23.0".format(
344+
"SDK Package Version: 1.24.0".format(
345345
env=sys.platform, pyversion=sys.version
346346
)
347347
)

‎patch_api/models/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
# import models into model package
1818
from patch_api.models.allocation import Allocation
19+
from patch_api.models.create_air_shipping_estimate_request import (
20+
CreateAirShippingEstimateRequest,
21+
)
1922
from patch_api.models.create_bitcoin_estimate_request import (
2023
CreateBitcoinEstimateRequest,
2124
)
@@ -26,6 +29,15 @@
2629
from patch_api.models.create_hotel_estimate_request import CreateHotelEstimateRequest
2730
from patch_api.models.create_mass_estimate_request import CreateMassEstimateRequest
2831
from patch_api.models.create_order_request import CreateOrderRequest
32+
from patch_api.models.create_rail_shipping_estimate_request import (
33+
CreateRailShippingEstimateRequest,
34+
)
35+
from patch_api.models.create_road_shipping_estimate_request import (
36+
CreateRoadShippingEstimateRequest,
37+
)
38+
from patch_api.models.create_sea_shipping_estimate_request import (
39+
CreateSeaShippingEstimateRequest,
40+
)
2941
from patch_api.models.create_shipping_estimate_request import (
3042
CreateShippingEstimateRequest,
3143
)
Lines changed: 345 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,345 @@
1+
# coding: utf-8
2+
3+
"""
4+
Patch API V1
5+
6+
The core API used to integrate with Patch's service # noqa: E501
7+
8+
The version of the OpenAPI document: v1
9+
Contact: engineering@usepatch.com
10+
Generated by: https://openapi-generator.tech
11+
"""
12+
13+
14+
import pprint
15+
import re # noqa: F401
16+
17+
import six
18+
19+
from patch_api.configuration import Configuration
20+
21+
22+
class CreateAirShippingEstimateRequest(object):
23+
"""NOTE: This class is auto generated by OpenAPI Generator.
24+
Ref: https://openapi-generator.tech
25+
26+
Do not edit the class manually.
27+
"""
28+
29+
"""
30+
Attributes:
31+
openapi_types (dict): The key is attribute name
32+
and the value is attribute type.
33+
attribute_map (dict): The key is attribute name
34+
and the value is json key in definition.
35+
"""
36+
openapi_types = {
37+
"destination_airport": "str",
38+
"origin_airport": "str",
39+
"aircraft_code": "str",
40+
"aircraft_type": "str",
41+
"freight_mass_g": "int",
42+
"emissions_scope": "str",
43+
"project_id": "str",
44+
"create_order": "bool",
45+
}
46+
47+
attribute_map = {
48+
"destination_airport": "destination_airport",
49+
"origin_airport": "origin_airport",
50+
"aircraft_code": "aircraft_code",
51+
"aircraft_type": "aircraft_type",
52+
"freight_mass_g": "freight_mass_g",
53+
"emissions_scope": "emissions_scope",
54+
"project_id": "project_id",
55+
"create_order": "create_order",
56+
}
57+
58+
def __init__(
59+
self,
60+
destination_airport=None,
61+
origin_airport=None,
62+
aircraft_code=None,
63+
aircraft_type="unknown",
64+
freight_mass_g=None,
65+
emissions_scope="wtw",
66+
project_id=None,
67+
create_order=False,
68+
local_vars_configuration=None,
69+
): # noqa: E501
70+
"""CreateAirShippingEstimateRequest - a model defined in OpenAPI""" # noqa: E501
71+
if local_vars_configuration is None:
72+
local_vars_configuration = Configuration()
73+
self.local_vars_configuration = local_vars_configuration
74+
75+
self._destination_airport = None
76+
self._origin_airport = None
77+
self._aircraft_code = None
78+
self._aircraft_type = None
79+
self._freight_mass_g = None
80+
self._emissions_scope = None
81+
self._project_id = None
82+
self._create_order = None
83+
self.discriminator = None
84+
85+
self.destination_airport = destination_airport
86+
self.origin_airport = origin_airport
87+
self.aircraft_code = aircraft_code
88+
self.aircraft_type = aircraft_type
89+
if freight_mass_g is not None:
90+
self.freight_mass_g = freight_mass_g
91+
self.emissions_scope = emissions_scope
92+
self.project_id = project_id
93+
self.create_order = create_order
94+
95+
@property
96+
def destination_airport(self):
97+
"""Gets the destination_airport of this CreateAirShippingEstimateRequest. # noqa: E501
98+
99+
100+
:return: The destination_airport of this CreateAirShippingEstimateRequest. # noqa: E501
101+
:rtype: str
102+
"""
103+
return self._destination_airport
104+
105+
@destination_airport.setter
106+
def destination_airport(self, destination_airport):
107+
"""Sets the destination_airport of this CreateAirShippingEstimateRequest.
108+
109+
110+
:param destination_airport: The destination_airport of this CreateAirShippingEstimateRequest. # noqa: E501
111+
:type: str
112+
"""
113+
114+
self._destination_airport = destination_airport
115+
116+
@property
117+
def origin_airport(self):
118+
"""Gets the origin_airport of this CreateAirShippingEstimateRequest. # noqa: E501
119+
120+
121+
:return: The origin_airport of this CreateAirShippingEstimateRequest. # noqa: E501
122+
:rtype: str
123+
"""
124+
return self._origin_airport
125+
126+
@origin_airport.setter
127+
def origin_airport(self, origin_airport):
128+
"""Sets the origin_airport of this CreateAirShippingEstimateRequest.
129+
130+
131+
:param origin_airport: The origin_airport of this CreateAirShippingEstimateRequest. # noqa: E501
132+
:type: str
133+
"""
134+
135+
self._origin_airport = origin_airport
136+
137+
@property
138+
def aircraft_code(self):
139+
"""Gets the aircraft_code of this CreateAirShippingEstimateRequest. # noqa: E501
140+
141+
142+
:return: The aircraft_code of this CreateAirShippingEstimateRequest. # noqa: E501
143+
:rtype: str
144+
"""
145+
return self._aircraft_code
146+
147+
@aircraft_code.setter
148+
def aircraft_code(self, aircraft_code):
149+
"""Sets the aircraft_code of this CreateAirShippingEstimateRequest.
150+
151+
152+
:param aircraft_code: The aircraft_code of this CreateAirShippingEstimateRequest. # noqa: E501
153+
:type: str
154+
"""
155+
156+
self._aircraft_code = aircraft_code
157+
158+
@property
159+
def aircraft_type(self):
160+
"""Gets the aircraft_type of this CreateAirShippingEstimateRequest. # noqa: E501
161+
162+
163+
:return: The aircraft_type of this CreateAirShippingEstimateRequest. # noqa: E501
164+
:rtype: str
165+
"""
166+
return self._aircraft_type
167+
168+
@aircraft_type.setter
169+
def aircraft_type(self, aircraft_type):
170+
"""Sets the aircraft_type of this CreateAirShippingEstimateRequest.
171+
172+
173+
:param aircraft_type: The aircraft_type of this CreateAirShippingEstimateRequest. # noqa: E501
174+
:type: str
175+
"""
176+
allowed_values = [None, "passenger", "cargo", "unknown"] # noqa: E501
177+
if (
178+
self.local_vars_configuration.client_side_validation
179+
and aircraft_type not in allowed_values
180+
): # noqa: E501
181+
raise ValueError(
182+
"Invalid value for `aircraft_type` ({0}), must be one of {1}".format( # noqa: E501
183+
aircraft_type, allowed_values
184+
)
185+
)
186+
187+
self._aircraft_type = aircraft_type
188+
189+
@property
190+
def freight_mass_g(self):
191+
"""Gets the freight_mass_g of this CreateAirShippingEstimateRequest. # noqa: E501
192+
193+
194+
:return: The freight_mass_g of this CreateAirShippingEstimateRequest. # noqa: E501
195+
:rtype: int
196+
"""
197+
return self._freight_mass_g
198+
199+
@freight_mass_g.setter
200+
def freight_mass_g(self, freight_mass_g):
201+
"""Sets the freight_mass_g of this CreateAirShippingEstimateRequest.
202+
203+
204+
:param freight_mass_g: The freight_mass_g of this CreateAirShippingEstimateRequest. # noqa: E501
205+
:type: int
206+
"""
207+
if (
208+
self.local_vars_configuration.client_side_validation
209+
and freight_mass_g is not None
210+
and freight_mass_g > 2000000000
211+
): # noqa: E501
212+
raise ValueError(
213+
"Invalid value for `freight_mass_g`, must be a value less than or equal to `2000000000`"
214+
) # noqa: E501
215+
if (
216+
self.local_vars_configuration.client_side_validation
217+
and freight_mass_g is not None
218+
and freight_mass_g < 0
219+
): # noqa: E501
220+
raise ValueError(
221+
"Invalid value for `freight_mass_g`, must be a value greater than or equal to `0`"
222+
) # noqa: E501
223+
224+
self._freight_mass_g = freight_mass_g
225+
226+
@property
227+
def emissions_scope(self):
228+
"""Gets the emissions_scope of this CreateAirShippingEstimateRequest. # noqa: E501
229+
230+
231+
:return: The emissions_scope of this CreateAirShippingEstimateRequest. # noqa: E501
232+
:rtype: str
233+
"""
234+
return self._emissions_scope
235+
236+
@emissions_scope.setter
237+
def emissions_scope(self, emissions_scope):
238+
"""Sets the emissions_scope of this CreateAirShippingEstimateRequest.
239+
240+
241+
:param emissions_scope: The emissions_scope of this CreateAirShippingEstimateRequest. # noqa: E501
242+
:type: str
243+
"""
244+
allowed_values = [None, "wtt", "ttw", "wtw"] # noqa: E501
245+
if (
246+
self.local_vars_configuration.client_side_validation
247+
and emissions_scope not in allowed_values
248+
): # noqa: E501
249+
raise ValueError(
250+
"Invalid value for `emissions_scope` ({0}), must be one of {1}".format( # noqa: E501
251+
emissions_scope, allowed_values
252+
)
253+
)
254+
255+
self._emissions_scope = emissions_scope
256+
257+
@property
258+
def project_id(self):
259+
"""Gets the project_id of this CreateAirShippingEstimateRequest. # noqa: E501
260+
261+
262+
:return: The project_id of this CreateAirShippingEstimateRequest. # noqa: E501
263+
:rtype: str
264+
"""
265+
return self._project_id
266+
267+
@project_id.setter
268+
def project_id(self, project_id):
269+
"""Sets the project_id of this CreateAirShippingEstimateRequest.
270+
271+
272+
:param project_id: The project_id of this CreateAirShippingEstimateRequest. # noqa: E501
273+
:type: str
274+
"""
275+
276+
self._project_id = project_id
277+
278+
@property
279+
def create_order(self):
280+
"""Gets the create_order of this CreateAirShippingEstimateRequest. # noqa: E501
281+
282+
283+
:return: The create_order of this CreateAirShippingEstimateRequest. # noqa: E501
284+
:rtype: bool
285+
"""
286+
return self._create_order
287+
288+
@create_order.setter
289+
def create_order(self, create_order):
290+
"""Sets the create_order of this CreateAirShippingEstimateRequest.
291+
292+
293+
:param create_order: The create_order of this CreateAirShippingEstimateRequest. # noqa: E501
294+
:type: bool
295+
"""
296+
297+
self._create_order = create_order
298+
299+
def to_dict(self):
300+
"""Returns the model properties as a dict"""
301+
result = {}
302+
303+
for attr, _ in six.iteritems(self.openapi_types):
304+
value = getattr(self, attr)
305+
if isinstance(value, list):
306+
result[attr] = list(
307+
map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)
308+
)
309+
elif hasattr(value, "to_dict"):
310+
result[attr] = value.to_dict()
311+
elif isinstance(value, dict):
312+
result[attr] = dict(
313+
map(
314+
lambda item: (item[0], item[1].to_dict())
315+
if hasattr(item[1], "to_dict")
316+
else item,
317+
value.items(),
318+
)
319+
)
320+
else:
321+
result[attr] = value
322+
323+
return result
324+
325+
def to_str(self):
326+
"""Returns the string representation of the model"""
327+
return pprint.pformat(self.to_dict())
328+
329+
def __repr__(self):
330+
"""For `print` and `pprint`"""
331+
return self.to_str()
332+
333+
def __eq__(self, other):
334+
"""Returns true if both objects are equal"""
335+
if not isinstance(other, CreateAirShippingEstimateRequest):
336+
return False
337+
338+
return self.to_dict() == other.to_dict()
339+
340+
def __ne__(self, other):
341+
"""Returns true if both objects are not equal"""
342+
if not isinstance(other, CreateAirShippingEstimateRequest):
343+
return True
344+
345+
return self.to_dict() != other.to_dict()

‎patch_api/models/create_order_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def state(self, state):
232232
:param state: The state of this CreateOrderRequest. # noqa: E501
233233
:type: str
234234
"""
235-
allowed_values = [None, "draft", "placed"] # noqa: E501
235+
allowed_values = [None, "draft", "reserved", "placed"] # noqa: E501
236236
if (
237237
self.local_vars_configuration.client_side_validation
238238
and state not in allowed_values

‎patch_api/models/create_rail_shipping_estimate_request.py

Lines changed: 423 additions & 0 deletions
Large diffs are not rendered by default.

‎patch_api/models/create_road_shipping_estimate_request.py

Lines changed: 573 additions & 0 deletions
Large diffs are not rendered by default.

‎patch_api/models/create_sea_shipping_estimate_request.py

Lines changed: 518 additions & 0 deletions
Large diffs are not rendered by default.

‎patch_api/models/order.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ def state(self, state):
298298
) # noqa: E501
299299
allowed_values = [
300300
"draft",
301+
"reserved",
301302
"placed",
302303
"processing",
303304
"complete",

‎patch_api/models/project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def type(self, type):
301301
def mechanism(self):
302302
"""Gets the mechanism of this Project. # noqa: E501
303303
304-
The mechanism of the project. Either removal or avoidance. # noqa: E501
304+
The mechanism of the project. One of: removal, avoidance, avoidance_and_removal. # noqa: E501
305305
306306
:return: The mechanism of this Project. # noqa: E501
307307
:rtype: str
@@ -312,7 +312,7 @@ def mechanism(self):
312312
def mechanism(self, mechanism):
313313
"""Sets the mechanism of this Project.
314314
315-
The mechanism of the project. Either removal or avoidance. # noqa: E501
315+
The mechanism of the project. One of: removal, avoidance, avoidance_and_removal. # noqa: E501
316316
317317
:param mechanism: The mechanism of this Project. # noqa: E501
318318
:type: str

‎requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ six >= 1.10
33
python_dateutil >= 2.5.3
44
setuptools >= 21.0.0
55
urllib3 >= 1.15.1
6-
pre-commit >= 2.19.0
6+
pre-commit >= 2.10.0

‎setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from setuptools import setup, find_packages # noqa: H301
1313

1414
NAME = "patch-api"
15-
VERSION = "1.23.0"
15+
VERSION = "1.24.0"
1616
# To install the library, run the following
1717
#
1818
# python setup.py install

‎test/test_estimates_api.py

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,184 @@ def test_create_hotel_estimate(self):
195195
estimate.data.mass_g, 15_000
196196
) # not setting an exact value since this is changing daily
197197

198+
def test_create_air_shipping_estimate_airport_iatas(self):
199+
"""Test case for create_air_shipping_estimate
200+
201+
Create an estimate based on airport iata values # noqa: E501
202+
"""
203+
estimate = self.api.create_air_shipping_estimate(
204+
destination_airport="JFK", freight_mass_g=19_158, origin_airport="ATL"
205+
)
206+
self.assertEqual(estimate.data.order, None)
207+
self.assertEqual(estimate.data.type, "shipping_air")
208+
self.assertGreater(
209+
estimate.data.mass_g, 10_000
210+
) # not setting an exact value since the mock values returned are randomized
211+
212+
def test_create_air_shipping_estimate_create_order(self):
213+
"""Test case for create_air_shipping_estimate
214+
215+
Create an estimate and an order # noqa: E501
216+
"""
217+
estimate = self.api.create_air_shipping_estimate(
218+
create_order=True,
219+
destination_airport="JFK",
220+
freight_mass_g=18_092,
221+
origin_airport="ATL",
222+
)
223+
self.assertGreater(estimate.data.order.amount, 2_000)
224+
self.assertEqual(estimate.data.type, "shipping_air")
225+
self.assertGreater(
226+
estimate.data.mass_g, 10_000
227+
) # not setting an exact value since the mock values returned are randomized
228+
229+
def test_create_rail_shipping_estimate_addresses(self):
230+
"""Test case for create_rail_shipping_estimate
231+
232+
Create an estimate based on locode values # noqa: E501
233+
"""
234+
estimate = self.api.create_rail_shipping_estimate(
235+
destination_country_code="US",
236+
destination_postal_code="90210",
237+
freight_mass_g=18092,
238+
origin_country_code="US",
239+
origin_postal_code="97209",
240+
)
241+
self.assertEqual(estimate.data.order, None)
242+
self.assertEqual(estimate.data.type, "shipping_rail")
243+
self.assertGreater(
244+
estimate.data.mass_g, 300
245+
) # not setting an exact value since the mock values returned are randomized
246+
247+
def test_create_rail_shipping_estimate_locodes(self):
248+
"""Test case for create_rail_shipping_estimate
249+
250+
Create an estimate based on locode values # noqa: E501
251+
"""
252+
estimate = self.api.create_rail_shipping_estimate(
253+
destination_locode="USSD2", freight_mass_g=18092, origin_locode="USSEA"
254+
)
255+
self.assertEqual(estimate.data.order, None)
256+
self.assertEqual(estimate.data.type, "shipping_rail")
257+
self.assertGreater(
258+
estimate.data.mass_g, 800
259+
) # not setting an exact value since the mock values returned are randomized
260+
261+
def test_create_rail_shipping_estimate_create_order(self):
262+
"""Test case for create_rail_shipping_estimate
263+
264+
Create an estimate and an order # noqa: E501
265+
"""
266+
estimate = self.api.create_rail_shipping_estimate(
267+
create_order=True,
268+
destination_locode="USSD2",
269+
freight_mass_g=19_217,
270+
origin_locode="USSEA",
271+
)
272+
self.assertGreater(estimate.data.order.amount, 900)
273+
self.assertEqual(estimate.data.type, "shipping_rail")
274+
self.assertGreater(
275+
estimate.data.mass_g, 800
276+
) # not setting an exact value since the mock values returned are randomized
277+
278+
def test_create_road_shipping_estimate_addresses(self):
279+
"""Test case for create_road_shipping_estimate
280+
281+
Create an estimate based on locode values # noqa: E501
282+
"""
283+
estimate = self.api.create_road_shipping_estimate(
284+
destination_country_code="US",
285+
destination_postal_code="90210",
286+
freight_mass_g=19_166,
287+
origin_country_code="US",
288+
origin_postal_code="97209",
289+
)
290+
self.assertEqual(estimate.data.order, None)
291+
self.assertEqual(estimate.data.type, "shipping_road")
292+
self.assertGreater(
293+
estimate.data.mass_g, 600
294+
) # not setting an exact value since the mock values returned are randomized
295+
296+
def test_create_road_shipping_estimate_locodes(self):
297+
"""Test case for create_road_shipping_estimate
298+
299+
Create an estimate based on locode values # noqa: E501
300+
"""
301+
estimate = self.api.create_road_shipping_estimate(
302+
destination_locode="USSD2", freight_mass_g=16_907, origin_locode="USSEA"
303+
)
304+
self.assertEqual(estimate.data.order, None)
305+
self.assertEqual(estimate.data.type, "shipping_road")
306+
self.assertGreater(
307+
estimate.data.mass_g, 1_000
308+
) # not setting an exact value since the mock values returned are randomized
309+
310+
def test_create_road_shipping_estimate_create_order(self):
311+
"""Test case for create_road_shipping_estimate
312+
313+
Create an estimate and an order # noqa: E501
314+
"""
315+
estimate = self.api.create_road_shipping_estimate(
316+
create_order=True,
317+
destination_locode="USSD2",
318+
freight_mass_g=21_933,
319+
origin_locode="USSEA",
320+
)
321+
self.assertGreater(estimate.data.order.amount, 1_000)
322+
self.assertEqual(estimate.data.type, "shipping_road")
323+
self.assertGreater(
324+
estimate.data.mass_g, 800
325+
) # not setting an exact value since the mock values returned are randomized
326+
327+
def test_create_sea_shipping_estimate_addresses(self):
328+
"""Test case for create_sea_shipping_estimate
329+
330+
Create an estimate based on address values # noqa: E501
331+
"""
332+
estimate = self.api.create_sea_shipping_estimate(
333+
destination_country_code="US",
334+
destination_postal_code="90210",
335+
freight_mass_g=26_906,
336+
origin_country_code="US",
337+
origin_postal_code="97209",
338+
)
339+
self.assertEqual(estimate.data.order, None)
340+
self.assertEqual(estimate.data.type, "shipping_sea")
341+
self.assertGreater(
342+
estimate.data.mass_g, 600
343+
) # not setting an exact value since the mock values returned are randomized
344+
345+
def test_create_sea_shipping_estimate_locodes(self):
346+
"""Test case for create_sea_shipping_estimate
347+
348+
Create an estimate based on locode values # noqa: E501
349+
"""
350+
estimate = self.api.create_sea_shipping_estimate(
351+
destination_locode="USSD2", freight_mass_g=17_311, origin_locode="USSEA"
352+
)
353+
self.assertEqual(estimate.data.order, None)
354+
self.assertEqual(estimate.data.type, "shipping_sea")
355+
self.assertGreater(
356+
estimate.data.mass_g, 1_000
357+
) # not setting an exact value since the mock values returned are randomized
358+
359+
def test_create_sea_shipping_estimate_create_order(self):
360+
"""Test case for create_sea_shipping_estimate
361+
362+
Create an estimate and an order # noqa: E501
363+
"""
364+
estimate = self.api.create_sea_shipping_estimate(
365+
create_order=True,
366+
destination_locode="USSD2",
367+
freight_mass_g=22_210,
368+
origin_locode="USSEA",
369+
)
370+
self.assertGreater(estimate.data.order.amount, 1_000)
371+
self.assertEqual(estimate.data.type, "shipping_sea")
372+
self.assertGreater(
373+
estimate.data.mass_g, 800
374+
) # not setting an exact value since the mock values returned are randomized
375+
198376

199377
if __name__ == "__main__":
200378
unittest.main()

0 commit comments

Comments
 (0)
Please sign in to comment.