Added suppoort for regex in whitelist

This commit is contained in:
nas-
2021-01-12 01:13:58 +01:00
parent dbc25f00ac
commit 4d7ffa8c81
9 changed files with 93 additions and 51 deletions

View File

@@ -505,37 +505,38 @@ def test_validate_pairs(default_conf, mocker): # test exchange.validate_pairs d
Exchange(default_conf)
def test_validate_pairs_not_available(default_conf, mocker):
api_mock = MagicMock()
type(api_mock).markets = PropertyMock(return_value={
'XRP/BTC': {'inactive': True}
})
mocker.patch('freqtrade.exchange.Exchange._init_ccxt', MagicMock(return_value=api_mock))
mocker.patch('freqtrade.exchange.Exchange.validate_timeframes')
mocker.patch('freqtrade.exchange.Exchange.validate_stakecurrency')
mocker.patch('freqtrade.exchange.Exchange._load_async_markets')
with pytest.raises(OperationalException, match=r'not available'):
Exchange(default_conf)
def test_validate_pairs_exception(default_conf, mocker, caplog):
caplog.set_level(logging.INFO)
api_mock = MagicMock()
mocker.patch('freqtrade.exchange.Exchange.name', PropertyMock(return_value='Binance'))
type(api_mock).markets = PropertyMock(return_value={})
mocker.patch('freqtrade.exchange.Exchange._init_ccxt', api_mock)
mocker.patch('freqtrade.exchange.Exchange.validate_timeframes')
mocker.patch('freqtrade.exchange.Exchange.validate_stakecurrency')
mocker.patch('freqtrade.exchange.Exchange._load_async_markets')
with pytest.raises(OperationalException, match=r'Pair ETH/BTC is not available on Binance'):
Exchange(default_conf)
mocker.patch('freqtrade.exchange.Exchange.markets', PropertyMock(return_value={}))
Exchange(default_conf)
assert log_has('Unable to validate pairs (assuming they are correct).', caplog)
# This cannot happen anymore as expand_pairlist implicitly filters out unavaliablie pairs
# def test_validate_pairs_not_available(default_conf, mocker):
# api_mock = MagicMock()
# type(api_mock).markets = PropertyMock(return_value={
# 'XRP/BTC': {'inactive': True, 'base': 'XRP', 'quote': 'BTC'}
# })
# mocker.patch('freqtrade.exchange.Exchange._init_ccxt', MagicMock(return_value=api_mock))
# mocker.patch('freqtrade.exchange.Exchange.validate_timeframes')
# mocker.patch('freqtrade.exchange.Exchange.validate_stakecurrency')
# mocker.patch('freqtrade.exchange.Exchange._load_async_markets')
#
# with pytest.raises(OperationalException, match=r'not available'):
# Exchange(default_conf)
#
#
# def test_validate_pairs_exception(default_conf, mocker, caplog):
# caplog.set_level(logging.INFO)
# api_mock = MagicMock()
# mocker.patch('freqtrade.exchange.Exchange.name', PropertyMock(return_value='Binance'))
#
# type(api_mock).markets = PropertyMock(return_value={})
# mocker.patch('freqtrade.exchange.Exchange._init_ccxt', api_mock)
# mocker.patch('freqtrade.exchange.Exchange.validate_timeframes')
# mocker.patch('freqtrade.exchange.Exchange.validate_stakecurrency')
# mocker.patch('freqtrade.exchange.Exchange._load_async_markets')
#
# with pytest.raises(OperationalException, match=r'Pair ETH/BTC is not available on Binance'):
# Exchange(default_conf)
#
# mocker.patch('freqtrade.exchange.Exchange.markets', PropertyMock(return_value={}))
# Exchange(default_conf)
# assert log_has('Unable to validate pairs (assuming they are correct).', caplog)
def test_validate_pairs_restricted(default_conf, mocker, caplog):

View File

@@ -47,14 +47,15 @@ def test_init_plotscript(default_conf, mocker, testdatadir):
default_conf['timeframe'] = "5m"
default_conf["datadir"] = testdatadir
default_conf['exportfilename'] = testdatadir / "backtest-result_test.json"
ret = init_plotscript(default_conf)
supported_markets = ["TRX/BTC", "ADA/BTC"]
ret = init_plotscript(default_conf, supported_markets)
assert "ohlcv" in ret
assert "trades" in ret
assert "pairs" in ret
assert 'timerange' in ret
default_conf['pairs'] = ["TRX/BTC", "ADA/BTC"]
ret = init_plotscript(default_conf, 20)
ret = init_plotscript(default_conf, supported_markets, 20)
assert "ohlcv" in ret
assert "TRX/BTC" in ret["ohlcv"]
assert "ADA/BTC" in ret["ohlcv"]