This commit is contained in:
iuvbio 2019-03-10 16:36:25 +01:00
parent 8741017819
commit 1a92bf9e8e
2 changed files with 29 additions and 4 deletions

View File

@ -222,7 +222,6 @@ class Exchange(object):
self._last_markets_refresh + self.markets_refresh_interval
> arrow.utcnow().timestamp):
return None
else:
logger.debug("Performing scheduled market reload..")
self._load_markets(reload=True)

View File

@ -245,12 +245,38 @@ def test__load_markets(default_conf, mocker, caplog):
api_mock = MagicMock()
api_mock.load_markets = MagicMock(return_value=expected_return)
type(api_mock).markets = expected_return
mocker.patch('freqtrade.exchange.Exchange._init_ccxt', MagicMock(return_value=api_mock))
default_conf['exchange']['pair_whitelist'] = ['ETH/BTC']
ex = get_patched_exchange(mocker, default_conf, api_mock, id="binance")
assert ex.markets == expected_return
def test__reload_markets(default_conf, mocker, caplog):
caplog.set_level(logging.DEBUG)
api_mock = MagicMock()
initial_markets = {'ETH/BTC': {}}
type(api_mock).markets = initial_markets
updated_markets = {'ETH/BTC': {}, "LTC/BTC": {}}
default_conf['exchange']['markets_refresh_interval'] = 10
exchange = get_patched_exchange(mocker, default_conf, api_mock, id="binance")
exchange._last_markets_refresh = arrow.utcnow().timestamp
def _load_markets(*args, **kwargs):
exchange._api.markets = updated_markets
mocker.patch('freqtrade.exchange.Exchange._load_markets', _load_markets)
assert exchange.markets == initial_markets
# less than 10 minutes have passed, no reload
exchange._reload_markets()
assert exchange.markets == initial_markets
# more than 10 minutes have passed, reload is executed
exchange._last_markets_refresh = arrow.utcnow().timestamp - 15 * 60
exchange._reload_markets()
assert exchange.markets == updated_markets
assert log_has('Performing scheduled market reload..', caplog.record_tuples)
def test_validate_pairs(default_conf, mocker): # test exchange.validate_pairs directly
api_mock = MagicMock()
type(api_mock).markets = PropertyMock(return_value={