Replace occurances in test files

This commit is contained in:
Matthias 2020-06-01 20:47:27 +02:00
parent b2c241e607
commit 950f358982
14 changed files with 57 additions and 48 deletions

View File

@ -44,7 +44,7 @@ def test_start_new_config(mocker, caplog, exchange):
'stake_currency': 'USDT', 'stake_currency': 'USDT',
'stake_amount': 100, 'stake_amount': 100,
'fiat_display_currency': 'EUR', 'fiat_display_currency': 'EUR',
'ticker_interval': '15m', 'timeframe': '15m',
'dry_run': True, 'dry_run': True,
'exchange_name': exchange, 'exchange_name': exchange,
'exchange_key': 'sampleKey', 'exchange_key': 'sampleKey',
@ -68,7 +68,7 @@ def test_start_new_config(mocker, caplog, exchange):
result = rapidjson.loads(wt_mock.call_args_list[0][0][0], result = rapidjson.loads(wt_mock.call_args_list[0][0][0],
parse_mode=rapidjson.PM_COMMENTS | rapidjson.PM_TRAILING_COMMAS) parse_mode=rapidjson.PM_COMMENTS | rapidjson.PM_TRAILING_COMMAS)
assert result['exchange']['name'] == exchange assert result['exchange']['name'] == exchange
assert result['ticker_interval'] == '15m' assert result['timeframe'] == '15m'
def test_start_new_config_exists(mocker, caplog): def test_start_new_config_exists(mocker, caplog):

View File

@ -9,7 +9,7 @@
"fiat_display_currency": "USD", // C++-style comment "fiat_display_currency": "USD", // C++-style comment
"amount_reserve_percent" : 0.05, // And more, tabs before this comment "amount_reserve_percent" : 0.05, // And more, tabs before this comment
"dry_run": false, "dry_run": false,
"ticker_interval": "5m", "timeframe": "5m",
"trailing_stop": false, "trailing_stop": false,
"trailing_stop_positive": 0.005, "trailing_stop_positive": 0.005,
"trailing_stop_positive_offset": 0.0051, "trailing_stop_positive_offset": 0.0051,

View File

@ -12,7 +12,7 @@ from tests.conftest import get_patched_exchange
def test_ohlcv(mocker, default_conf, ohlcv_history): def test_ohlcv(mocker, default_conf, ohlcv_history):
default_conf["runmode"] = RunMode.DRY_RUN default_conf["runmode"] = RunMode.DRY_RUN
timeframe = default_conf["ticker_interval"] timeframe = default_conf["timeframe"]
exchange = get_patched_exchange(mocker, default_conf) exchange = get_patched_exchange(mocker, default_conf)
exchange._klines[("XRP/BTC", timeframe)] = ohlcv_history exchange._klines[("XRP/BTC", timeframe)] = ohlcv_history
exchange._klines[("UNITTEST/BTC", timeframe)] = ohlcv_history exchange._klines[("UNITTEST/BTC", timeframe)] = ohlcv_history
@ -53,47 +53,47 @@ def test_historic_ohlcv(mocker, default_conf, ohlcv_history):
def test_get_pair_dataframe(mocker, default_conf, ohlcv_history): def test_get_pair_dataframe(mocker, default_conf, ohlcv_history):
default_conf["runmode"] = RunMode.DRY_RUN default_conf["runmode"] = RunMode.DRY_RUN
ticker_interval = default_conf["ticker_interval"] timeframe = default_conf["timeframe"]
exchange = get_patched_exchange(mocker, default_conf) exchange = get_patched_exchange(mocker, default_conf)
exchange._klines[("XRP/BTC", ticker_interval)] = ohlcv_history exchange._klines[("XRP/BTC", timeframe)] = ohlcv_history
exchange._klines[("UNITTEST/BTC", ticker_interval)] = ohlcv_history exchange._klines[("UNITTEST/BTC", timeframe)] = ohlcv_history
dp = DataProvider(default_conf, exchange) dp = DataProvider(default_conf, exchange)
assert dp.runmode == RunMode.DRY_RUN assert dp.runmode == RunMode.DRY_RUN
assert ohlcv_history.equals(dp.get_pair_dataframe("UNITTEST/BTC", ticker_interval)) assert ohlcv_history.equals(dp.get_pair_dataframe("UNITTEST/BTC", timeframe))
assert isinstance(dp.get_pair_dataframe("UNITTEST/BTC", ticker_interval), DataFrame) assert isinstance(dp.get_pair_dataframe("UNITTEST/BTC", timeframe), DataFrame)
assert dp.get_pair_dataframe("UNITTEST/BTC", ticker_interval) is not ohlcv_history assert dp.get_pair_dataframe("UNITTEST/BTC", timeframe) is not ohlcv_history
assert not dp.get_pair_dataframe("UNITTEST/BTC", ticker_interval).empty assert not dp.get_pair_dataframe("UNITTEST/BTC", timeframe).empty
assert dp.get_pair_dataframe("NONESENSE/AAA", ticker_interval).empty assert dp.get_pair_dataframe("NONESENSE/AAA", timeframe).empty
# Test with and without parameter # Test with and without parameter
assert dp.get_pair_dataframe("UNITTEST/BTC", ticker_interval)\ assert dp.get_pair_dataframe("UNITTEST/BTC", timeframe)\
.equals(dp.get_pair_dataframe("UNITTEST/BTC")) .equals(dp.get_pair_dataframe("UNITTEST/BTC"))
default_conf["runmode"] = RunMode.LIVE default_conf["runmode"] = RunMode.LIVE
dp = DataProvider(default_conf, exchange) dp = DataProvider(default_conf, exchange)
assert dp.runmode == RunMode.LIVE assert dp.runmode == RunMode.LIVE
assert isinstance(dp.get_pair_dataframe("UNITTEST/BTC", ticker_interval), DataFrame) assert isinstance(dp.get_pair_dataframe("UNITTEST/BTC", timeframe), DataFrame)
assert dp.get_pair_dataframe("NONESENSE/AAA", ticker_interval).empty assert dp.get_pair_dataframe("NONESENSE/AAA", timeframe).empty
historymock = MagicMock(return_value=ohlcv_history) historymock = MagicMock(return_value=ohlcv_history)
mocker.patch("freqtrade.data.dataprovider.load_pair_history", historymock) mocker.patch("freqtrade.data.dataprovider.load_pair_history", historymock)
default_conf["runmode"] = RunMode.BACKTEST default_conf["runmode"] = RunMode.BACKTEST
dp = DataProvider(default_conf, exchange) dp = DataProvider(default_conf, exchange)
assert dp.runmode == RunMode.BACKTEST assert dp.runmode == RunMode.BACKTEST
assert isinstance(dp.get_pair_dataframe("UNITTEST/BTC", ticker_interval), DataFrame) assert isinstance(dp.get_pair_dataframe("UNITTEST/BTC", timeframe), DataFrame)
# assert dp.get_pair_dataframe("NONESENSE/AAA", ticker_interval).empty # assert dp.get_pair_dataframe("NONESENSE/AAA", timeframe).empty
def test_available_pairs(mocker, default_conf, ohlcv_history): def test_available_pairs(mocker, default_conf, ohlcv_history):
exchange = get_patched_exchange(mocker, default_conf) exchange = get_patched_exchange(mocker, default_conf)
ticker_interval = default_conf["ticker_interval"] timeframe = default_conf["timeframe"]
exchange._klines[("XRP/BTC", ticker_interval)] = ohlcv_history exchange._klines[("XRP/BTC", timeframe)] = ohlcv_history
exchange._klines[("UNITTEST/BTC", ticker_interval)] = ohlcv_history exchange._klines[("UNITTEST/BTC", timeframe)] = ohlcv_history
dp = DataProvider(default_conf, exchange) dp = DataProvider(default_conf, exchange)
assert len(dp.available_pairs) == 2 assert len(dp.available_pairs) == 2
assert dp.available_pairs == [("XRP/BTC", ticker_interval), ("UNITTEST/BTC", ticker_interval), ] assert dp.available_pairs == [("XRP/BTC", timeframe), ("UNITTEST/BTC", timeframe), ]
def test_refresh(mocker, default_conf, ohlcv_history): def test_refresh(mocker, default_conf, ohlcv_history):
@ -101,8 +101,8 @@ def test_refresh(mocker, default_conf, ohlcv_history):
mocker.patch("freqtrade.exchange.Exchange.refresh_latest_ohlcv", refresh_mock) mocker.patch("freqtrade.exchange.Exchange.refresh_latest_ohlcv", refresh_mock)
exchange = get_patched_exchange(mocker, default_conf, id="binance") exchange = get_patched_exchange(mocker, default_conf, id="binance")
ticker_interval = default_conf["ticker_interval"] timeframe = default_conf["timeframe"]
pairs = [("XRP/BTC", ticker_interval), ("UNITTEST/BTC", ticker_interval)] pairs = [("XRP/BTC", timeframe), ("UNITTEST/BTC", timeframe)]
pairs_non_trad = [("ETH/USDT", ticker_interval), ("BTC/TUSD", "1h")] pairs_non_trad = [("ETH/USDT", ticker_interval), ("BTC/TUSD", "1h")]

View File

@ -354,7 +354,7 @@ def test_init(default_conf, mocker) -> None:
assert {} == load_data( assert {} == load_data(
datadir=Path(''), datadir=Path(''),
pairs=[], pairs=[],
timeframe=default_conf['ticker_interval'] timeframe=default_conf['timeframe']
) )
@ -363,13 +363,13 @@ def test_init_with_refresh(default_conf, mocker) -> None:
refresh_data( refresh_data(
datadir=Path(''), datadir=Path(''),
pairs=[], pairs=[],
timeframe=default_conf['ticker_interval'], timeframe=default_conf['timeframe'],
exchange=exchange exchange=exchange
) )
assert {} == load_data( assert {} == load_data(
datadir=Path(''), datadir=Path(''),
pairs=[], pairs=[],
timeframe=default_conf['ticker_interval'] timeframe=default_conf['timeframe']
) )

View File

@ -117,7 +117,7 @@ def test_setup_hyperopt_configuration_with_arguments(mocker, default_conf, caplo
'--config', 'config.json', '--config', 'config.json',
'--hyperopt', 'DefaultHyperOpt', '--hyperopt', 'DefaultHyperOpt',
'--datadir', '/foo/bar', '--datadir', '/foo/bar',
'--ticker-interval', '1m', '--timeframe', '1m',
'--timerange', ':100', '--timerange', ':100',
'--enable-position-stacking', '--enable-position-stacking',
'--disable-max-market-positions', '--disable-max-market-positions',
@ -137,7 +137,7 @@ def test_setup_hyperopt_configuration_with_arguments(mocker, default_conf, caplo
assert log_has('Using data directory: {} ...'.format(config['datadir']), caplog) assert log_has('Using data directory: {} ...'.format(config['datadir']), caplog)
assert 'timeframe' in config assert 'timeframe' in config
assert log_has('Parameter -i/--ticker-interval detected ... Using timeframe: 1m ...', assert log_has('Parameter -i/--timeframe detected ... Using timeframe: 1m ...',
caplog) caplog)
assert 'position_stacking' in config assert 'position_stacking' in config

View File

@ -54,12 +54,12 @@ def test_returns_latest_signal(mocker, default_conf, ohlcv_history):
def test_get_signal_empty(default_conf, mocker, caplog): def test_get_signal_empty(default_conf, mocker, caplog):
assert (False, False) == _STRATEGY.get_signal('foo', default_conf['ticker_interval'], assert (False, False) == _STRATEGY.get_signal('foo', default_conf['timeframe'],
DataFrame()) DataFrame())
assert log_has('Empty candle (OHLCV) data for pair foo', caplog) assert log_has('Empty candle (OHLCV) data for pair foo', caplog)
caplog.clear() caplog.clear()
assert (False, False) == _STRATEGY.get_signal('bar', default_conf['ticker_interval'], assert (False, False) == _STRATEGY.get_signal('bar', default_conf['timeframe'],
[]) [])
assert log_has('Empty candle (OHLCV) data for pair bar', caplog) assert log_has('Empty candle (OHLCV) data for pair bar', caplog)
@ -70,7 +70,7 @@ def test_get_signal_exception_valueerror(default_conf, mocker, caplog, ohlcv_his
_STRATEGY, '_analyze_ticker_internal', _STRATEGY, '_analyze_ticker_internal',
side_effect=ValueError('xyz') side_effect=ValueError('xyz')
) )
assert (False, False) == _STRATEGY.get_signal('foo', default_conf['ticker_interval'], assert (False, False) == _STRATEGY.get_signal('foo', default_conf['timeframe'],
ohlcv_history) ohlcv_history)
assert log_has_re(r'Strategy caused the following exception: xyz.*', caplog) assert log_has_re(r'Strategy caused the following exception: xyz.*', caplog)
@ -83,7 +83,7 @@ def test_get_signal_empty_dataframe(default_conf, mocker, caplog, ohlcv_history)
) )
mocker.patch.object(_STRATEGY, 'assert_df') mocker.patch.object(_STRATEGY, 'assert_df')
assert (False, False) == _STRATEGY.get_signal('xyz', default_conf['ticker_interval'], assert (False, False) == _STRATEGY.get_signal('xyz', default_conf['timeframe'],
ohlcv_history) ohlcv_history)
assert log_has('Empty dataframe for pair xyz', caplog) assert log_has('Empty dataframe for pair xyz', caplog)
@ -104,7 +104,7 @@ def test_get_signal_old_dataframe(default_conf, mocker, caplog, ohlcv_history):
return_value=mocked_history return_value=mocked_history
) )
mocker.patch.object(_STRATEGY, 'assert_df') mocker.patch.object(_STRATEGY, 'assert_df')
assert (False, False) == _STRATEGY.get_signal('xyz', default_conf['ticker_interval'], assert (False, False) == _STRATEGY.get_signal('xyz', default_conf['timeframe'],
ohlcv_history) ohlcv_history)
assert log_has('Outdated history for pair xyz. Last tick is 16 minutes old', caplog) assert log_has('Outdated history for pair xyz. Last tick is 16 minutes old', caplog)
@ -124,7 +124,7 @@ def test_assert_df_raise(default_conf, mocker, caplog, ohlcv_history):
_STRATEGY, 'assert_df', _STRATEGY, 'assert_df',
side_effect=StrategyError('Dataframe returned...') side_effect=StrategyError('Dataframe returned...')
) )
assert (False, False) == _STRATEGY.get_signal('xyz', default_conf['ticker_interval'], assert (False, False) == _STRATEGY.get_signal('xyz', default_conf['timeframe'],
ohlcv_history) ohlcv_history)
assert log_has('Unable to analyze candle (OHLCV) data for pair xyz: Dataframe returned...', assert log_has('Unable to analyze candle (OHLCV) data for pair xyz: Dataframe returned...',
caplog) caplog)

View File

@ -106,7 +106,7 @@ def test_strategy(result, default_conf):
assert default_conf['stoploss'] == -0.10 assert default_conf['stoploss'] == -0.10
assert strategy.ticker_interval == '5m' assert strategy.ticker_interval == '5m'
assert default_conf['ticker_interval'] == '5m' assert default_conf['timeframe'] == '5m'
df_indicators = strategy.advise_indicators(result, metadata=metadata) df_indicators = strategy.advise_indicators(result, metadata=metadata)
assert 'adx' in df_indicators assert 'adx' in df_indicators
@ -176,19 +176,19 @@ def test_strategy_override_trailing_stop_positive(caplog, default_conf):
caplog) caplog)
def test_strategy_override_ticker_interval(caplog, default_conf): def test_strategy_override_timeframe(caplog, default_conf):
caplog.set_level(logging.INFO) caplog.set_level(logging.INFO)
default_conf.update({ default_conf.update({
'strategy': 'DefaultStrategy', 'strategy': 'DefaultStrategy',
'ticker_interval': 60, 'timeframe': 60,
'stake_currency': 'ETH' 'stake_currency': 'ETH'
}) })
strategy = StrategyResolver.load_strategy(default_conf) strategy = StrategyResolver.load_strategy(default_conf)
assert strategy.ticker_interval == 60 assert strategy.ticker_interval == 60
assert strategy.stake_currency == 'ETH' assert strategy.stake_currency == 'ETH'
assert log_has("Override strategy 'ticker_interval' with value in config file: 60.", assert log_has("Override strategy 'timeframe' with value in config file: 60.",
caplog) caplog)

View File

@ -131,7 +131,7 @@ def test_parse_args_backtesting_custom() -> None:
assert call_args["verbosity"] == 0 assert call_args["verbosity"] == 0
assert call_args["command"] == 'backtesting' assert call_args["command"] == 'backtesting'
assert call_args["func"] is not None assert call_args["func"] is not None
assert call_args["ticker_interval"] == '1m' assert call_args["timeframe"] == '1m'
assert type(call_args["strategy_list"]) is list assert type(call_args["strategy_list"]) is list
assert len(call_args["strategy_list"]) == 2 assert len(call_args["strategy_list"]) == 2

View File

@ -87,7 +87,7 @@ def test_load_config_file_error_range(default_conf, mocker, caplog) -> None:
assert isinstance(x, str) assert isinstance(x, str)
assert (x == '{"max_open_trades": 1, "stake_currency": "BTC", ' assert (x == '{"max_open_trades": 1, "stake_currency": "BTC", '
'"stake_amount": .001, "fiat_display_currency": "USD", ' '"stake_amount": .001, "fiat_display_currency": "USD", '
'"ticker_interval": "5m", "dry_run": true, ') '"timeframe": "5m", "dry_run": true, ')
def test__args_to_config(caplog): def test__args_to_config(caplog):

View File

@ -924,7 +924,7 @@ def test_process_informative_pairs_added(default_conf, ticker, mocker) -> None:
assert refresh_mock.call_count == 1 assert refresh_mock.call_count == 1
assert ("BTC/ETH", "1m") in refresh_mock.call_args[0][0] assert ("BTC/ETH", "1m") in refresh_mock.call_args[0][0]
assert ("ETH/USDT", "1h") in refresh_mock.call_args[0][0] assert ("ETH/USDT", "1h") in refresh_mock.call_args[0][0]
assert ("ETH/BTC", default_conf["ticker_interval"]) in refresh_mock.call_args[0][0] assert ("ETH/BTC", default_conf["timeframe"]) in refresh_mock.call_args[0][0]
@pytest.mark.parametrize("side,ask,bid,last,last_ab,expected", [ @pytest.mark.parametrize("side,ask,bid,last,last_ab,expected", [

View File

@ -35,12 +35,12 @@ def test_parse_args_backtesting(mocker) -> None:
main(['backtesting']) main(['backtesting'])
assert backtesting_mock.call_count == 1 assert backtesting_mock.call_count == 1
call_args = backtesting_mock.call_args[0][0] call_args = backtesting_mock.call_args[0][0]
assert call_args["config"] == ['config.json'] assert call_args['config'] == ['config.json']
assert call_args["verbosity"] == 0 assert call_args['verbosity'] == 0
assert call_args["command"] == 'backtesting' assert call_args['command'] == 'backtesting'
assert call_args["func"] is not None assert call_args['func'] is not None
assert callable(call_args["func"]) assert callable(call_args['func'])
assert call_args["ticker_interval"] is None assert call_args['timeframe'] is None
def test_main_start_hyperopt(mocker) -> None: def test_main_start_hyperopt(mocker) -> None:

View File

@ -772,6 +772,7 @@ def test_to_json(default_conf, fee):
'max_rate': None, 'max_rate': None,
'strategy': None, 'strategy': None,
'ticker_interval': None, 'ticker_interval': None,
'timeframe': None,
'exchange': 'bittrex', 'exchange': 'bittrex',
} }
@ -829,6 +830,7 @@ def test_to_json(default_conf, fee):
'sell_order_status': None, 'sell_order_status': None,
'strategy': None, 'strategy': None,
'ticker_interval': None, 'ticker_interval': None,
'timeframe': None,
'exchange': 'bittrex', 'exchange': 'bittrex',
} }

View File

@ -47,7 +47,7 @@ def generate_empty_figure():
def test_init_plotscript(default_conf, mocker, testdatadir): def test_init_plotscript(default_conf, mocker, testdatadir):
default_conf['timerange'] = "20180110-20180112" default_conf['timerange'] = "20180110-20180112"
default_conf['trade_source'] = "file" default_conf['trade_source'] = "file"
default_conf['ticker_interval'] = "5m" default_conf['timeframe'] = "5m"
default_conf["datadir"] = testdatadir default_conf["datadir"] = testdatadir
default_conf['exportfilename'] = testdatadir / "backtest-result_test.json" default_conf['exportfilename'] = testdatadir / "backtest-result_test.json"
ret = init_plotscript(default_conf) ret = init_plotscript(default_conf)

File diff suppressed because one or more lines are too long