Submitting with unit test for the working scenario.

Strongly recommend core team check the unit test is even targetting the
correct code in exchange/__init__.py

I have a real knowledge gap on mocker, in so far as how tests map to
what they're targeting.
This commit is contained in:
creslinux
2018-07-28 20:32:10 +00:00
parent 8648ac9da2
commit 0a059662b3
2 changed files with 39 additions and 3 deletions

View File

@@ -51,6 +51,36 @@ def test_init_exception(default_conf, mocker):
mocker.patch("ccxt.binance", MagicMock(side_effect=AttributeError))
Exchange(default_conf)
def test_set_sandbox(default_conf, mocker):
"""
Test working scenario
"""
api_mock = MagicMock()
api_mock.load_markets = MagicMock(return_value={
'ETH/BTC': '', 'LTC/BTC': '', 'XRP/BTC': '', 'NEO/BTC': ''
})
url_mock = PropertyMock(return_value={'test': "api-public.sandbox.gdax.com", '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())
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)
def test_validate_pairs(default_conf, mocker):
api_mock = MagicMock()