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