Convert ExchangeResolver to static loader class
This commit is contained in:
@@ -77,7 +77,7 @@ def get_patched_exchange(mocker, config, api_mock=None, id='bittrex',
|
||||
patch_exchange(mocker, api_mock, id, mock_markets)
|
||||
config["exchange"]["name"] = id
|
||||
try:
|
||||
exchange = ExchangeResolver(id, config).exchange
|
||||
exchange = ExchangeResolver.load_exchange(id, config)
|
||||
except ImportError:
|
||||
exchange = Exchange(config)
|
||||
return exchange
|
||||
|
@@ -124,19 +124,19 @@ def test_exchange_resolver(default_conf, mocker, caplog):
|
||||
mocker.patch('freqtrade.exchange.Exchange._load_async_markets', MagicMock())
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_pairs', MagicMock())
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_timeframes', MagicMock())
|
||||
exchange = ExchangeResolver('Bittrex', default_conf).exchange
|
||||
exchange = ExchangeResolver.load_exchange('Bittrex', default_conf)
|
||||
assert isinstance(exchange, Exchange)
|
||||
assert log_has_re(r"No .* specific subclass found. Using the generic class instead.", caplog)
|
||||
caplog.clear()
|
||||
|
||||
exchange = ExchangeResolver('kraken', default_conf).exchange
|
||||
exchange = ExchangeResolver.load_exchange('kraken', default_conf)
|
||||
assert isinstance(exchange, Exchange)
|
||||
assert isinstance(exchange, Kraken)
|
||||
assert not isinstance(exchange, Binance)
|
||||
assert not log_has_re(r"No .* specific subclass found. Using the generic class instead.",
|
||||
caplog)
|
||||
|
||||
exchange = ExchangeResolver('binance', default_conf).exchange
|
||||
exchange = ExchangeResolver.load_exchange('binance', default_conf)
|
||||
assert isinstance(exchange, Exchange)
|
||||
assert isinstance(exchange, Binance)
|
||||
assert not isinstance(exchange, Kraken)
|
||||
@@ -145,7 +145,7 @@ def test_exchange_resolver(default_conf, mocker, caplog):
|
||||
caplog)
|
||||
|
||||
# Test mapping
|
||||
exchange = ExchangeResolver('binanceus', default_conf).exchange
|
||||
exchange = ExchangeResolver.load_exchange('binanceus', default_conf)
|
||||
assert isinstance(exchange, Exchange)
|
||||
assert isinstance(exchange, Binance)
|
||||
assert not isinstance(exchange, Kraken)
|
||||
|
@@ -53,7 +53,8 @@ def test_load_pairlist_noexist(mocker, markets, default_conf):
|
||||
with pytest.raises(OperationalException,
|
||||
match=r"Impossible to load Pairlist 'NonexistingPairList'. "
|
||||
r"This class does not exist or contains Python code errors."):
|
||||
PairListResolver.load_pairlist('NonexistingPairList', bot.exchange, plm, default_conf, {}, 1)
|
||||
PairListResolver.load_pairlist('NonexistingPairList', bot.exchange, plm,
|
||||
default_conf, {}, 1)
|
||||
|
||||
|
||||
def test_refresh_market_pair_not_in_whitelist(mocker, markets, static_pl_conf):
|
||||
|
Reference in New Issue
Block a user