Unit tests for sandbox pass / fail scenarios
Big Wave of appreciation to xmatthias for the guidence on how Mocker works
This commit is contained in:
parent
0a059662b3
commit
fc06d028b8
@ -63,24 +63,33 @@ def test_set_sandbox(default_conf, mocker):
|
||||
type(api_mock).urls = url_mock
|
||||
mocker.patch('freqtrade.exchange.Exchange._init_ccxt', MagicMock(return_value=api_mock))
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_timeframes', MagicMock())
|
||||
Exchange(default_conf)
|
||||
|
||||
# def test_set_sandbox_exception(default_conf, mocker):
|
||||
# """
|
||||
# Test Fail scenario
|
||||
# """
|
||||
# api_mock = MagicMock()
|
||||
# api_mock.load_markets = MagicMock(return_value={
|
||||
# 'ETH/BTC': '', 'LTC/BTC': '', 'XRP/BTC': '', 'NEO/BTC': ''
|
||||
# })
|
||||
# url_mock = PropertyMock(return_value={'api': 'https://api.gdax.com'})
|
||||
# type(api_mock).urls = url_mock
|
||||
#
|
||||
# mocker.patch('freqtrade.exchange.Exchange._init_ccxt', MagicMock(return_value=api_mock))
|
||||
# mocker.patch('freqtrade.exchange.Exchange.validate_timeframes', MagicMock())
|
||||
#
|
||||
# with pytest.raises(OperationalException, match=r'does not provide a sandbox api'):
|
||||
# Exchange(default_conf)
|
||||
exchange = Exchange(default_conf)
|
||||
liveurl = exchange._api.urls['api']
|
||||
default_conf['exchange']['sandbox'] = True
|
||||
exchange.set_sandbox(exchange._api, default_conf['exchange'], 'Logname')
|
||||
assert exchange._api.urls['api'] != liveurl
|
||||
|
||||
def test_set_sandbox_exception(default_conf, mocker):
|
||||
"""
|
||||
Test Fail scenario
|
||||
"""
|
||||
api_mock = MagicMock()
|
||||
api_mock.load_markets = MagicMock(return_value={
|
||||
'ETH/BTC': '', 'LTC/BTC': '', 'XRP/BTC': '', 'NEO/BTC': ''
|
||||
})
|
||||
url_mock = PropertyMock(return_value={'api': 'https://api.gdax.com'})
|
||||
type(api_mock).urls = url_mock
|
||||
|
||||
mocker.patch('freqtrade.exchange.Exchange._init_ccxt', MagicMock(return_value=api_mock))
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_timeframes', MagicMock())
|
||||
|
||||
with pytest.raises(OperationalException, match=r'does not provide a sandbox api'):
|
||||
exchange = Exchange(default_conf)
|
||||
default_conf['exchange']['sandbox'] = True
|
||||
exchange.set_sandbox(exchange._api, default_conf['exchange'], 'Logname')
|
||||
assert exchange._api.urls.get('test') == False
|
||||
|
||||
|
||||
def test_validate_pairs(default_conf, mocker):
|
||||
api_mock = MagicMock()
|
||||
|
Loading…
Reference in New Issue
Block a user