Skip to content

Commit b01ae54

Browse files
committed
test: adds test for order cancelation
1 parent 832d2bd commit b01ae54

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

tests/rest/test_authentication.py

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

1111
class AuthenticationTestCase(unittest.TestCase):
1212
def setUp(self):
13-
self.client = Client(keys['apiKey'], keys['apiSecret'])
13+
self.client = Client(keys['apiKey'], keys['apiSecret'], 60_000)
1414

1515
def tearDown(self):
1616
self.client.close()

tests/rest/test_public.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ def pprint(a_json_obj):
1818

1919
class Key_printer:
2020
def __init__(self):
21-
self.keys = {}
21+
self.keys = []
2222

2323
def add_keys(self, a_dict):
2424
for key in a_dict:
25-
self.keys[key] = 1
25+
self.keys.append(key)
2626

2727
def print_keys(self):
2828
print('')

tests/rest/test_trading.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import time
33
import unittest
4+
from cryptomarket.dataclasses.order import OrderStatus
45

56
from test_helpers import *
67

@@ -23,6 +24,8 @@ def tearDown(self):
2324
class GetTradingBalance(AuthCallsTestCase):
2425
def test_successfull_call(self):
2526
trading_balances = self.client.get_spot_trading_balances()
27+
print("**balances**")
28+
print(trading_balances)
2629
if len(trading_balances) == 0:
2730
self.fail("no balances")
2831
if not good_list(good_balance, trading_balances):
@@ -88,6 +91,7 @@ def test_successfull_call(self): # create order should work properly
8891
quantity='0.01',
8992
client_order_id=client_order_id,
9093
price='1000')
94+
print(order)
9195
if not good_order(order):
9296
self.fail("not good order")
9397
# get
@@ -151,6 +155,23 @@ def test_successfull_call(self):
151155
order = self.client.get_active_spot_order(client_order_id)
152156

153157

158+
159+
class CancelOrderByClientId(AuthCallsTestCase):
160+
def test_successfull_call(self):
161+
order = self.client.create_spot_order(
162+
symbol='ADAUSDT',
163+
side=args.Side.BUY,
164+
quantity='5',
165+
type=args.OrderType.LIMIT,
166+
price='0.1'
167+
)
168+
assert(order.status == OrderStatus.NEW)
169+
time.sleep(5)
170+
canceled_order = self.client.cancel_spot_order(order.client_order_id)
171+
assert(canceled_order.status == OrderStatus.CANCELED)
172+
173+
174+
154175
class GetAllTradingCommissions(AuthCallsTestCase):
155176
def test_successfull_call(self):
156177
result = self.client.get_all_trading_commissions()
@@ -204,6 +225,7 @@ def test_create_order_list(self):
204225
time_in_force=args.TimeInForce.FOK,
205226
quantity="0.1",
206227
price="10000")])
228+
print(orders)
207229
if not good_list(good_order, orders):
208230
self.fail("not valid orders: " + orders)
209231
self.client.cancel_all_orders()

0 commit comments

Comments
 (0)