From 2de5a59d890e2345eb1a935554b3453ab4047416 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 20 Mar 2023 06:38:42 +0100 Subject: [PATCH] Add test for dry-run fetching --- tests/exchange/test_okx.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/exchange/test_okx.py b/tests/exchange/test_okx.py index 30e23619b..2f862adda 100644 --- a/tests/exchange/test_okx.py +++ b/tests/exchange/test_okx.py @@ -528,3 +528,19 @@ def test_fetch_stoploss_order_okx(default_conf, mocker): assert resp['id'] == '1234' assert resp['id_stop'] == '123455' assert resp['type'] == 'stoploss' + + default_conf['dry_run'] = True + exchange = get_patched_exchange(mocker, default_conf, api_mock, id='okx') + dro_mock = mocker.patch(f"{EXMS}.fetch_dry_run_order", MagicMock(return_value={'id': '123455'})) + + api_mock.fetch_order.reset_mock() + api_mock.fetch_open_orders.reset_mock() + api_mock.fetch_closed_orders.reset_mock() + api_mock.fetch_canceled_orders.reset_mock() + resp = exchange.fetch_stoploss_order('1234', 'ETH/BTC') + + assert api_mock.fetch_order.call_count == 0 + assert api_mock.fetch_open_orders.call_count == 0 + assert api_mock.fetch_closed_orders.call_count == 0 + assert api_mock.fetch_canceled_orders.call_count == 0 + assert dro_mock.call_count == 1