From 081d3932b63f48dd2f6668b7798032572aeb2124 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste LE STANG Date: Sat, 20 Jan 2018 14:44:13 +0100 Subject: [PATCH] Fixing bug report #406 + unit test --- freqtrade/exchange/bittrex.py | 5 +++-- freqtrade/tests/exchange/test_exchange_bittrex.py | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/freqtrade/exchange/bittrex.py b/freqtrade/exchange/bittrex.py index e6cacbd4e..419f3dd94 100644 --- a/freqtrade/exchange/bittrex.py +++ b/freqtrade/exchange/bittrex.py @@ -122,9 +122,10 @@ class Bittrex(Exchange): raise OperationalException('{message} params=({pair})'.format( message=data['message'], pair=pair)) - + keys = ['Bid', 'Ask', 'Last'] if not data.get('result') or\ - not all(key in data.get('result', {}) for key in ['Bid', 'Ask', 'Last']): + not all(key in data.get('result', {}) for key in keys) or\ + not all(data.get('result', {})[key] is not None for key in keys): raise ContentDecodingError('{message} params=({pair})'.format( message='Got invalid response from bittrex', pair=pair)) diff --git a/freqtrade/tests/exchange/test_exchange_bittrex.py b/freqtrade/tests/exchange/test_exchange_bittrex.py index 4302f9f5f..be6b7cedd 100644 --- a/freqtrade/tests/exchange/test_exchange_bittrex.py +++ b/freqtrade/tests/exchange/test_exchange_bittrex.py @@ -232,6 +232,11 @@ def test_exchange_bittrex_get_ticker_bad(): with pytest.raises(btx.OperationalException, match=r'.*gone bad.*'): wb.get_ticker('BTC_ETH') + fb.result = {'success': True, + 'result': {'Bid': 1, 'Ask': 0, 'Last': None}} # incomplete result + with pytest.raises(ContentDecodingError, match=r'.*Got invalid response from bittrex params.*'): + wb.get_ticker('BTC_ETH') + def test_exchange_bittrex_get_ticker_history_one(): wb = make_wrap_bittrex()