Merge pull request #376 from jblestang/fix_ticker_with_null_value
Fixing the ticker analysis with null values
This commit is contained in:
commit
80e7f37f50
@ -123,10 +123,8 @@ class Bittrex(Exchange):
|
||||
message=data['message'],
|
||||
pair=pair))
|
||||
|
||||
if not data.get('result') \
|
||||
or not data['result'].get('Bid') \
|
||||
or not data['result'].get('Ask') \
|
||||
or not data['result'].get('Last'):
|
||||
if not data.get('result') or\
|
||||
not all(key in data.get('result', {}) for key in ['Bid', 'Ask', 'Last']):
|
||||
raise ContentDecodingError('{message} params=({pair})'.format(
|
||||
message='Got invalid response from bittrex',
|
||||
pair=pair))
|
||||
|
@ -212,7 +212,18 @@ def test_exchange_bittrex_get_ticker_bad():
|
||||
wb = make_wrap_bittrex()
|
||||
fb = FakeBittrex()
|
||||
fb.result = {'success': True,
|
||||
'result': {'Bid': 1}} # incomplete result
|
||||
'result': {'Bid': 1, 'Ask': 0}} # incomplete result
|
||||
|
||||
with pytest.raises(ContentDecodingError, match=r'.*Got invalid response from bittrex params.*'):
|
||||
wb.get_ticker('BTC_ETH')
|
||||
fb.result = {'success': False,
|
||||
'message': 'gone bad'
|
||||
}
|
||||
with pytest.raises(btx.OperationalException, match=r'.*gone bad.*'):
|
||||
wb.get_ticker('BTC_ETH')
|
||||
|
||||
fb.result = {'success': True,
|
||||
'result': {}} # incomplete result
|
||||
with pytest.raises(ContentDecodingError, match=r'.*Got invalid response from bittrex params.*'):
|
||||
wb.get_ticker('BTC_ETH')
|
||||
fb.result = {'success': False,
|
||||
|
Loading…
Reference in New Issue
Block a user