From cfe1e4876a00196cd40b938360042d08468b8ca2 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 14 Apr 2020 19:20:47 +0200 Subject: [PATCH] Improve testcase for cancel_order_empty --- freqtrade/exchange/exchange.py | 2 +- tests/exchange/test_exchange.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 073e28659..ad4824a10 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -908,7 +908,7 @@ class Exchange: :param order: Order dict as returned from get_order() :return: True if order has been cancelled without being filled, False otherwise. """ - return order['status'] in ('closed', 'canceled') and order.get('filled') == 0.0 + return order.get('status') in ('closed', 'canceled') and order.get('filled') == 0.0 @retrier def cancel_order(self, order_id: str, pair: str) -> None: diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 7f03eb547..cc3f95735 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -1711,6 +1711,8 @@ def test_cancel_order_dry_run(default_conf, mocker, exchange_name): ({'status': 'closed', 'filled': 0.0}, True), ({'status': 'canceled', 'filled': 0.0}, True), ({'status': 'canceled', 'filled': 10.0}, False), + ({'status': 'unknown', 'filled': 10.0}, False), + ({'result': 'testest123'}, False), ]) def test_check_order_canceled_empty(mocker, default_conf, exchange_name, order, result): exchange = get_patched_exchange(mocker, default_conf, id=exchange_name)