Don't fail if fetchTickers is not availlable
This commit is contained in:
parent
a6f6a17393
commit
39c27cfc37
@ -1427,6 +1427,8 @@ class Exchange:
|
||||
:return: fetch_tickers result
|
||||
"""
|
||||
tickers: Tickers
|
||||
if not self.exchange_has('fetchTickers'):
|
||||
return {}
|
||||
if cached:
|
||||
with self._cache_lock:
|
||||
tickers = self._fetch_tickers_cache.get('fetch_tickers') # type: ignore
|
||||
|
@ -1834,6 +1834,7 @@ def test_get_tickers(default_conf, mocker, exchange_name):
|
||||
'last': 41,
|
||||
}
|
||||
}
|
||||
mocker.patch('freqtrade.exchange.exchange.Exchange.exchange_has', return_value=True)
|
||||
api_mock.fetch_tickers = MagicMock(return_value=tick)
|
||||
api_mock.fetch_bids_asks = MagicMock(return_value={})
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id=exchange_name)
|
||||
@ -1883,6 +1884,11 @@ def test_get_tickers(default_conf, mocker, exchange_name):
|
||||
assert api_mock.fetch_tickers.call_count == 1
|
||||
assert api_mock.fetch_bids_asks.call_count == (1 if exchange_name == 'binance' else 0)
|
||||
|
||||
api_mock.fetch_tickers.reset_mock()
|
||||
api_mock.fetch_bids_asks.reset_mock()
|
||||
mocker.patch('freqtrade.exchange.exchange.Exchange.exchange_has', return_value=False)
|
||||
assert exchange.get_tickers() == {}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("exchange_name", EXCHANGES)
|
||||
def test_fetch_ticker(default_conf, mocker, exchange_name):
|
||||
|
Loading…
Reference in New Issue
Block a user