Update exchange validate_pairs and related tests
This commit is contained in:
parent
c3d00a8825
commit
cba8745164
@ -107,7 +107,7 @@ def validate_pairs(pairs: List[str]) -> None:
|
||||
)
|
||||
if pair not in markets:
|
||||
raise OperationalException(
|
||||
'Pair {} is not available at {}'.format(pair, _API.id.lower()))
|
||||
'Pair {} is not available at {}'.format(pair, get_name()))
|
||||
|
||||
|
||||
def exchange_has(endpoint: str) -> bool:
|
||||
|
@ -68,7 +68,8 @@ def test_validate_pairs_not_compatible(default_conf, mocker):
|
||||
api_mock.load_markets = MagicMock(return_value={
|
||||
'ETH/BTC': '', 'TKN/BTC': '', 'TRST/BTC': '', 'SWT/BTC': '', 'BCC/BTC': ''
|
||||
})
|
||||
default_conf['stake_currency'] = 'ETH'
|
||||
conf = deepcopy(default_conf)
|
||||
conf['stake_currency'] = 'ETH'
|
||||
mocker.patch('freqtrade.exchange._API', api_mock)
|
||||
mocker.patch.dict('freqtrade.exchange._CONF', conf)
|
||||
with pytest.raises(OperationalException, match=r'not compatible'):
|
||||
@ -78,18 +79,20 @@ def test_validate_pairs_not_compatible(default_conf, mocker):
|
||||
def test_validate_pairs_exception(default_conf, mocker, caplog):
|
||||
caplog.set_level(logging.INFO)
|
||||
api_mock = MagicMock()
|
||||
api_mock.load_markets = MagicMock(side_effect=ccxt.BaseError())
|
||||
api_mock.name = 'binance'
|
||||
api_mock.name = 'Binance'
|
||||
mocker.patch('freqtrade.exchange._API', api_mock)
|
||||
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
||||
|
||||
with pytest.raises(OperationalException, match=r'Pair ETH/BTC is not available at binance'):
|
||||
api_mock.load_markets = MagicMock(return_value={})
|
||||
with pytest.raises(OperationalException, match=r'Pair ETH/BTC is not available at Binance'):
|
||||
validate_pairs(default_conf['exchange']['pair_whitelist'])
|
||||
|
||||
api_mock.load_markets = MagicMock(side_effect=ccxt.BaseError())
|
||||
validate_pairs(default_conf['exchange']['pair_whitelist'])
|
||||
assert log_has('Unable to validate pairs (assuming they are correct). Reason: ',
|
||||
caplog.record_tuples)
|
||||
|
||||
|
||||
def test_validate_pairs_stake_exception(default_conf, mocker, caplog):
|
||||
caplog.set_level(logging.INFO)
|
||||
conf = deepcopy(default_conf)
|
||||
|
Loading…
Reference in New Issue
Block a user