Improve data-provider tests
This commit is contained in:
@@ -9,27 +9,31 @@ from freqtrade.tests.conftest import get_patched_exchange
|
||||
|
||||
def test_ohlcv(mocker, default_conf, ticker_history):
|
||||
default_conf['runmode'] = RunMode.DRY_RUN
|
||||
tick_interval = default_conf['ticker_interval']
|
||||
exchange = get_patched_exchange(mocker, default_conf)
|
||||
exchange._klines['XRP/BTC'] = ticker_history
|
||||
exchange._klines['UNITTEST/BTC'] = ticker_history
|
||||
exchange._klines[('XRP/BTC', tick_interval)] = ticker_history
|
||||
exchange._klines[('UNITTEST/BTC', tick_interval)] = ticker_history
|
||||
dp = DataProvider(default_conf, exchange)
|
||||
assert dp.runmode == RunMode.DRY_RUN
|
||||
assert ticker_history.equals(dp.ohlcv('UNITTEST/BTC'))
|
||||
assert isinstance(dp.ohlcv('UNITTEST/BTC'), DataFrame)
|
||||
assert dp.ohlcv('UNITTEST/BTC') is not ticker_history
|
||||
assert dp.ohlcv('UNITTEST/BTC', copy=False) is ticker_history
|
||||
assert not dp.ohlcv('UNITTEST/BTC').empty
|
||||
assert dp.ohlcv('NONESENSE/AAA').empty
|
||||
assert ticker_history.equals(dp.ohlcv('UNITTEST/BTC', tick_interval))
|
||||
assert isinstance(dp.ohlcv('UNITTEST/BTC', tick_interval), DataFrame)
|
||||
assert dp.ohlcv('UNITTEST/BTC', tick_interval) is not ticker_history
|
||||
assert dp.ohlcv('UNITTEST/BTC', tick_interval, copy=False) is ticker_history
|
||||
assert not dp.ohlcv('UNITTEST/BTC', tick_interval).empty
|
||||
assert dp.ohlcv('NONESENSE/AAA', tick_interval).empty
|
||||
|
||||
# Test with and without parameter
|
||||
assert dp.ohlcv('UNITTEST/BTC', tick_interval).equals(dp.ohlcv('UNITTEST/BTC'))
|
||||
|
||||
default_conf['runmode'] = RunMode.LIVE
|
||||
dp = DataProvider(default_conf, exchange)
|
||||
assert dp.runmode == RunMode.LIVE
|
||||
assert isinstance(dp.ohlcv('UNITTEST/BTC'), DataFrame)
|
||||
assert isinstance(dp.ohlcv('UNITTEST/BTC', tick_interval), DataFrame)
|
||||
|
||||
default_conf['runmode'] = RunMode.BACKTEST
|
||||
dp = DataProvider(default_conf, exchange)
|
||||
assert dp.runmode == RunMode.BACKTEST
|
||||
assert dp.ohlcv('UNITTEST/BTC').empty
|
||||
assert dp.ohlcv('UNITTEST/BTC', tick_interval).empty
|
||||
|
||||
|
||||
def test_historic_ohlcv(mocker, default_conf, ticker_history):
|
||||
@@ -49,8 +53,10 @@ def test_historic_ohlcv(mocker, default_conf, ticker_history):
|
||||
|
||||
def test_available_pairs(mocker, default_conf, ticker_history):
|
||||
exchange = get_patched_exchange(mocker, default_conf)
|
||||
exchange._klines['XRP/BTC'] = ticker_history
|
||||
exchange._klines['UNITTEST/BTC'] = ticker_history
|
||||
|
||||
tick_interval = default_conf['ticker_interval']
|
||||
exchange._klines[('XRP/BTC', tick_interval)] = ticker_history
|
||||
exchange._klines[('UNITTEST/BTC', tick_interval)] = ticker_history
|
||||
dp = DataProvider(default_conf, exchange)
|
||||
|
||||
assert len(dp.available_pairs) == 2
|
||||
|
Reference in New Issue
Block a user