From 40df0dcf3d5653dc8aba3cf68f724480885b2a34 Mon Sep 17 00:00:00 2001 From: Misagh Date: Tue, 2 Apr 2019 18:45:18 +0200 Subject: [PATCH] tests fixed --- freqtrade/__init__.py | 2 +- freqtrade/exchange/exchange.py | 4 ++-- freqtrade/tests/exchange/test_exchange.py | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/freqtrade/__init__.py b/freqtrade/__init__.py index 30fed8c53..292613297 100644 --- a/freqtrade/__init__.py +++ b/freqtrade/__init__.py @@ -17,7 +17,7 @@ class OperationalException(BaseException): """ -class InvalidOrder(BaseException): +class InvalidOrderException(BaseException): """ This is returned when the order is not valid. Example: If stoploss on exchange order is hit, then trying to cancel the order diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 2b7e41847..7f4ab062c 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -14,7 +14,7 @@ import ccxt.async_support as ccxt_async from pandas import DataFrame from freqtrade import (constants, DependencyException, OperationalException, - TemporaryError, InvalidOrder) + TemporaryError, InvalidOrderException) from freqtrade.data.converter import parse_ticker_dataframe logger = logging.getLogger(__name__) @@ -608,7 +608,7 @@ class Exchange(object): try: return self._api.cancel_order(order_id, pair) except ccxt.InvalidOrder as e: - raise DependencyException( + raise InvalidOrderException( f'Could not cancel order. Message: {e}') except (ccxt.NetworkError, ccxt.ExchangeError) as e: raise TemporaryError( diff --git a/freqtrade/tests/exchange/test_exchange.py b/freqtrade/tests/exchange/test_exchange.py index eed16d39b..4deb74c67 100644 --- a/freqtrade/tests/exchange/test_exchange.py +++ b/freqtrade/tests/exchange/test_exchange.py @@ -11,7 +11,8 @@ import ccxt import pytest from pandas import DataFrame -from freqtrade import DependencyException, OperationalException, TemporaryError +from freqtrade import (DependencyException, OperationalException, + TemporaryError, InvalidOrderException) from freqtrade.exchange import Binance, Exchange, Kraken from freqtrade.exchange.exchange import API_RETRY_COUNT from freqtrade.resolvers.exchange_resolver import ExchangeResolver @@ -1233,11 +1234,11 @@ def test_cancel_order(default_conf, mocker, exchange_name): exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name) assert exchange.cancel_order(order_id='_', pair='TKN/BTC') == 123 - with pytest.raises(DependencyException): + with pytest.raises(InvalidOrderException): api_mock.cancel_order = MagicMock(side_effect=ccxt.InvalidOrder) exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name) exchange.cancel_order(order_id='_', pair='TKN/BTC') - assert api_mock.cancel_order.call_count == API_RETRY_COUNT + 1 + assert api_mock.cancel_order.call_count == 1 ccxt_exceptionhandlers(mocker, default_conf, api_mock, exchange_name, "cancel_order", "cancel_order",