test: use object patching instead of direct assignment
This commit is contained in:
@@ -42,9 +42,7 @@ def test_fetch_stoploss_order_gate(default_conf, mocker):
|
|||||||
|
|
||||||
def test_cancel_stoploss_order_gate(default_conf, mocker):
|
def test_cancel_stoploss_order_gate(default_conf, mocker):
|
||||||
exchange = get_patched_exchange(mocker, default_conf, exchange="gate")
|
exchange = get_patched_exchange(mocker, default_conf, exchange="gate")
|
||||||
|
cancel_order_mock = mocker.patch.object(exchange, "cancel_order")
|
||||||
cancel_order_mock = MagicMock()
|
|
||||||
exchange.cancel_order = cancel_order_mock
|
|
||||||
|
|
||||||
exchange.cancel_stoploss_order("1234", "ETH/BTC")
|
exchange.cancel_stoploss_order("1234", "ETH/BTC")
|
||||||
assert cancel_order_mock.call_count == 1
|
assert cancel_order_mock.call_count == 1
|
||||||
|
|||||||
@@ -661,14 +661,13 @@ def test_stoploss_adjust_okx(mocker, default_conf, sl1, sl2, sl3, side):
|
|||||||
|
|
||||||
def test_stoploss_cancel_okx(mocker, default_conf):
|
def test_stoploss_cancel_okx(mocker, default_conf):
|
||||||
exchange = get_patched_exchange(mocker, default_conf, exchange="okx")
|
exchange = get_patched_exchange(mocker, default_conf, exchange="okx")
|
||||||
|
co_mock = mocker.patch.object(exchange, "cancel_order")
|
||||||
exchange.cancel_order = MagicMock()
|
|
||||||
|
|
||||||
exchange.cancel_stoploss_order("1234", "ETH/USDT")
|
exchange.cancel_stoploss_order("1234", "ETH/USDT")
|
||||||
assert exchange.cancel_order.call_count == 1
|
assert co_mock.call_count == 1
|
||||||
assert exchange.cancel_order.call_args_list[0][1]["order_id"] == "1234"
|
assert co_mock.call_args_list[0][1]["order_id"] == "1234"
|
||||||
assert exchange.cancel_order.call_args_list[0][1]["pair"] == "ETH/USDT"
|
assert co_mock.call_args_list[0][1]["pair"] == "ETH/USDT"
|
||||||
assert exchange.cancel_order.call_args_list[0][1]["params"] == {"stop": True}
|
assert co_mock.call_args_list[0][1]["params"] == {"stop": True}
|
||||||
|
|
||||||
|
|
||||||
def test__get_stop_params_okx(mocker, default_conf):
|
def test__get_stop_params_okx(mocker, default_conf):
|
||||||
|
|||||||
Reference in New Issue
Block a user