diff --git a/freqtrade/exchange/__init__.py b/freqtrade/exchange/__init__.py index a47acec20..a658a790a 100644 --- a/freqtrade/exchange/__init__.py +++ b/freqtrade/exchange/__init__.py @@ -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: diff --git a/freqtrade/tests/exchange/test_exchange.py b/freqtrade/tests/exchange/test_exchange.py index b45573d6a..d6fa420e5 100644 --- a/freqtrade/tests/exchange/test_exchange.py +++ b/freqtrade/tests/exchange/test_exchange.py @@ -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)