2017-11-18 08:09:19 +00:00
|
|
|
# pragma pylint: disable=missing-docstring,C0103
|
2017-11-09 20:47:47 +00:00
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from freqtrade.exchange import validate_pairs
|
2017-11-20 21:15:19 +00:00
|
|
|
from freqtrade.misc import OperationalException
|
2017-11-09 20:47:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_validate_pairs(default_conf, mocker):
|
|
|
|
api_mock = MagicMock()
|
2017-11-13 20:34:47 +00:00
|
|
|
api_mock.get_markets = MagicMock(return_value=[
|
|
|
|
'BTC_ETH', 'BTC_TKN', 'BTC_TRST', 'BTC_SWT', 'BTC_BCC',
|
|
|
|
])
|
2017-11-09 20:47:47 +00:00
|
|
|
mocker.patch('freqtrade.exchange._API', api_mock)
|
|
|
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
|
|
|
validate_pairs(default_conf['exchange']['pair_whitelist'])
|
|
|
|
|
|
|
|
|
|
|
|
def test_validate_pairs_not_available(default_conf, mocker):
|
|
|
|
api_mock = MagicMock()
|
|
|
|
api_mock.get_markets = MagicMock(return_value=[])
|
|
|
|
mocker.patch('freqtrade.exchange._API', api_mock)
|
|
|
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
2017-11-20 21:15:19 +00:00
|
|
|
with pytest.raises(OperationalException, match=r'not available'):
|
2017-11-09 20:47:47 +00:00
|
|
|
validate_pairs(default_conf['exchange']['pair_whitelist'])
|
|
|
|
|
|
|
|
|
|
|
|
def test_validate_pairs_not_compatible(default_conf, mocker):
|
|
|
|
api_mock = MagicMock()
|
|
|
|
api_mock.get_markets = MagicMock(return_value=['BTC_ETH', 'BTC_TKN', 'BTC_TRST', 'BTC_SWT'])
|
|
|
|
default_conf['stake_currency'] = 'ETH'
|
|
|
|
mocker.patch('freqtrade.exchange._API', api_mock)
|
|
|
|
mocker.patch.dict('freqtrade.exchange._CONF', default_conf)
|
2017-11-20 21:15:19 +00:00
|
|
|
with pytest.raises(OperationalException, match=r'not compatible'):
|
2017-11-09 20:47:47 +00:00
|
|
|
validate_pairs(default_conf['exchange']['pair_whitelist'])
|