Add tests for get_quote_currencies

This commit is contained in:
Matthias 2020-01-11 12:01:34 +01:00
parent ca2880537d
commit 60b47b6eec
2 changed files with 22 additions and 1 deletions

View File

@ -216,7 +216,7 @@ class Exchange:
Return a list of supported quote currencies
"""
markets = self.markets
currencies = set([x['quote'] for _, x in markets.items()])
currencies = set([x.get('quote') for _, x in markets.items()])
return list(currencies)
def klines(self, pair_interval: Tuple[str, str], copy=True) -> DataFrame:

View File

@ -318,6 +318,27 @@ def test__reload_markets_exception(default_conf, mocker, caplog):
assert log_has_re(r"Could not reload markets.*", caplog)
@pytest.mark.parametrize("stake_currency", ['ETH', 'BTC', 'USDT'])
def test_validate_stake_currency(default_conf, stake_currency, mocker, caplog):
default_conf['stake_currency'] = stake_currency
api_mock = MagicMock()
type(api_mock).markets = PropertyMock(return_value={
'ETH/BTC': {'quote': 'BTC'}, 'LTC/BTC': {'quote': 'BTC'},
'XRP/ETH': {'quote': 'ETH'}, 'NEO/USDT': {'quote': 'USDT'},
})
mocker.patch('freqtrade.exchange.Exchange._init_ccxt', MagicMock(return_value=api_mock))
mocker.patch('freqtrade.exchange.Exchange.validate_pairs')
mocker.patch('freqtrade.exchange.Exchange.validate_timeframes')
mocker.patch('freqtrade.exchange.Exchange._load_async_markets')
Exchange(default_conf)
def test_get_quote_currencies(default_conf, mocker):
ex = get_patched_exchange(mocker, default_conf)
assert set(ex.get_quote_currencies()) == set(['USD', 'BTC', 'USDT'])
def test_validate_pairs(default_conf, mocker): # test exchange.validate_pairs directly
api_mock = MagicMock()
type(api_mock).markets = PropertyMock(return_value={