Skip to content

Commit e21867e

Browse files
committed
Add Orders integration tests
1 parent 2783785 commit e21867e

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

test/test_orders_api.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,58 @@
1414
from __future__ import absolute_import
1515

1616
import unittest
17+
import os
1718

1819
import patch_api
1920
from patch_api.api.orders_api import OrdersApi # noqa: E501
21+
from patch_api.models.create_order_request import CreateOrderRequest
2022
from patch_api.rest import ApiException
2123

2224

2325
class TestOrdersApi(unittest.TestCase):
2426
"""OrdersApi unit test stubs"""
2527

2628
def setUp(self):
27-
self.api = patch_api.api.orders_api.OrdersApi() # noqa: E501
29+
configuration = patch_api.Configuration(api_key=os.environ.get('SANDBOX_API_KEY'))
30+
api_client = patch_api.ApiClient(configuration)
31+
self.api = OrdersApi(api_client=api_client) # noqa: E501
2832

2933
def tearDown(self):
3034
pass
3135

32-
def test_cancel_order(self):
33-
"""Test case for cancel_order
36+
def test_interactions_with_an_order(self):
37+
"""Test case for create_order, retrieve_order, cancel_order
38+
"""
3439

35-
Cancel an order # noqa: E501
40+
"""Create an order
3641
"""
37-
pass
42+
create_order_request = CreateOrderRequest(mass_g=100)
43+
order = self.api.create_order(create_order_request)
3844

39-
def test_create_order(self):
40-
"""Test case for create_order
45+
self.assertTrue(order)
4146

42-
Creates an order # noqa: E501
47+
"""Retrieve an order
4348
"""
44-
pass
49+
create_order_request = CreateOrderRequest(mass_g=100)
50+
order = self.api.create_order(create_order_request=create_order_request)
51+
retrieved_order = self.api.retrieve_order(id=order.data.id)
4552

46-
def test_place_order(self):
47-
"""Test case for place_order
53+
self.assertTrue(retrieved_order)
4854

49-
Place an order # noqa: E501
55+
"""Cancel an order
5056
"""
51-
pass
57+
cancelled_order = self.api.retrieve_order(id=order.data.id)
5258

53-
def test_retrieve_order(self):
54-
"""Test case for retrieve_order
59+
self.assertTrue(cancelled_order)
5560

56-
Retrieves an order # noqa: E501
57-
"""
58-
pass
5961

6062
def test_retrieve_orders(self):
6163
"""Test case for retrieve_orders
6264
6365
Retrieves a list of orders # noqa: E501
6466
"""
65-
pass
67+
orders = self.api.retrieve_orders()
68+
self.assertTrue(isinstance(orders.data, list))
6669

6770

6871
if __name__ == '__main__':

0 commit comments

Comments
 (0)