Update tests for new config structure

This commit is contained in:
Matthias 2021-06-26 16:39:01 +02:00
parent 1067a9f356
commit 0235868c66
5 changed files with 27 additions and 32 deletions

View File

@ -551,7 +551,7 @@ def test_backtest_results(default_conf, fee, mocker, caplog, data) -> None:
if data.trailing_stop_positive is not None:
default_conf["trailing_stop_positive"] = data.trailing_stop_positive
default_conf["trailing_stop_positive_offset"] = data.trailing_stop_positive_offset
default_conf["ask_strategy"] = {"use_sell_signal": data.use_sell_signal}
default_conf["use_sell_signal"] = data.use_sell_signal
mocker.patch("freqtrade.exchange.Exchange.get_fee", return_value=0.0)
mocker.patch("freqtrade.exchange.Exchange.get_min_pair_stake_amount", return_value=0.00001)

View File

@ -465,7 +465,7 @@ def test_backtesting_pairlist_list(default_conf, mocker, caplog, testdatadir, ti
def test_backtest__enter_trade(default_conf, fee, mocker) -> None:
default_conf['ask_strategy']['use_sell_signal'] = False
default_conf['use_sell_signal'] = False
mocker.patch('freqtrade.exchange.Exchange.get_fee', fee)
mocker.patch("freqtrade.exchange.Exchange.get_min_pair_stake_amount", return_value=0.00001)
patch_exchange(mocker)
@ -511,7 +511,7 @@ def test_backtest__enter_trade(default_conf, fee, mocker) -> None:
def test_backtest_one(default_conf, fee, mocker, testdatadir) -> None:
default_conf['ask_strategy']['use_sell_signal'] = False
default_conf['use_sell_signal'] = False
mocker.patch('freqtrade.exchange.Exchange.get_fee', fee)
mocker.patch("freqtrade.exchange.Exchange.get_min_pair_stake_amount", return_value=0.00001)
patch_exchange(mocker)
@ -574,7 +574,7 @@ def test_backtest_one(default_conf, fee, mocker, testdatadir) -> None:
def test_backtest_1min_timeframe(default_conf, fee, mocker, testdatadir) -> None:
default_conf['ask_strategy']['use_sell_signal'] = False
default_conf['use_sell_signal'] = False
mocker.patch('freqtrade.exchange.Exchange.get_fee', fee)
mocker.patch("freqtrade.exchange.Exchange.get_min_pair_stake_amount", return_value=0.00001)
patch_exchange(mocker)
@ -819,7 +819,7 @@ def test_backtest_start_timerange(default_conf, mocker, caplog, testdatadir):
@pytest.mark.filterwarnings("ignore:deprecated")
def test_backtest_start_multi_strat(default_conf, mocker, caplog, testdatadir):
default_conf['ask_strategy'].update({
default_conf.update({
"use_sell_signal": True,
"sell_profit_only": False,
"sell_profit_offset": 0.0,
@ -894,7 +894,7 @@ def test_backtest_start_multi_strat(default_conf, mocker, caplog, testdatadir):
@pytest.mark.filterwarnings("ignore:deprecated")
def test_backtest_start_multi_strat_nomock(default_conf, mocker, caplog, testdatadir, capsys):
default_conf['ask_strategy'].update({
default_conf.update({
"use_sell_signal": True,
"sell_profit_only": False,
"sell_profit_offset": 0.0,

View File

@ -290,14 +290,12 @@ def test_strategy_override_use_sell_signal(caplog, default_conf):
assert strategy.use_sell_signal
assert isinstance(strategy.use_sell_signal, bool)
# must be inserted to configuration
assert 'use_sell_signal' in default_conf['ask_strategy']
assert default_conf['ask_strategy']['use_sell_signal']
assert 'use_sell_signal' in default_conf
assert default_conf['use_sell_signal']
default_conf.update({
'strategy': 'DefaultStrategy',
'ask_strategy': {
'use_sell_signal': False,
},
'use_sell_signal': False,
})
strategy = StrategyResolver.load_strategy(default_conf)
@ -315,14 +313,12 @@ def test_strategy_override_use_sell_profit_only(caplog, default_conf):
assert not strategy.sell_profit_only
assert isinstance(strategy.sell_profit_only, bool)
# must be inserted to configuration
assert 'sell_profit_only' in default_conf['ask_strategy']
assert not default_conf['ask_strategy']['sell_profit_only']
assert 'sell_profit_only' in default_conf
assert not default_conf['sell_profit_only']
default_conf.update({
'strategy': 'DefaultStrategy',
'ask_strategy': {
'sell_profit_only': True,
},
'sell_profit_only': True,
})
strategy = StrategyResolver.load_strategy(default_conf)

View File

@ -878,15 +878,15 @@ def test_validate_tsl(default_conf):
def test_validate_edge2(edge_conf):
edge_conf.update({"ask_strategy": {
edge_conf.update({
"use_sell_signal": True,
}})
})
# Passes test
validate_config_consistency(edge_conf)
edge_conf.update({"ask_strategy": {
edge_conf.update({
"use_sell_signal": False,
}})
})
with pytest.raises(OperationalException, match="Edge requires `use_sell_signal` to be True, "
"otherwise no sells will happen."):
validate_config_consistency(edge_conf)

View File

@ -2960,11 +2960,11 @@ def test_sell_profit_only_enable_profit(default_conf, limit_buy_order, limit_buy
buy=MagicMock(return_value=limit_buy_order_open),
get_fee=fee,
)
default_conf['ask_strategy'] = {
default_conf.update({
'use_sell_signal': True,
'sell_profit_only': True,
'sell_profit_offset': 0.1,
}
})
freqtrade = FreqtradeBot(default_conf)
patch_get_signal(freqtrade)
freqtrade.strategy.min_roi_reached = MagicMock(return_value=False)
@ -2977,7 +2977,7 @@ def test_sell_profit_only_enable_profit(default_conf, limit_buy_order, limit_buy
patch_get_signal(freqtrade, value=(False, True))
assert freqtrade.handle_trade(trade) is False
freqtrade.config['ask_strategy']['sell_profit_offset'] = 0.0
freqtrade.strategy.sell_profit_offset = 0.0
assert freqtrade.handle_trade(trade) is True
assert trade.sell_reason == SellType.SELL_SIGNAL.value
@ -2997,10 +2997,10 @@ def test_sell_profit_only_disable_profit(default_conf, limit_buy_order, limit_bu
buy=MagicMock(return_value=limit_buy_order_open),
get_fee=fee,
)
default_conf['ask_strategy'] = {
default_conf.update({
'use_sell_signal': True,
'sell_profit_only': False,
}
})
freqtrade = FreqtradeBot(default_conf)
patch_get_signal(freqtrade)
freqtrade.strategy.min_roi_reached = MagicMock(return_value=False)
@ -3028,10 +3028,10 @@ def test_sell_profit_only_enable_loss(default_conf, limit_buy_order, limit_buy_o
buy=MagicMock(return_value=limit_buy_order_open),
get_fee=fee,
)
default_conf['ask_strategy'] = {
default_conf.update({
'use_sell_signal': True,
'sell_profit_only': True,
}
})
freqtrade = FreqtradeBot(default_conf)
patch_get_signal(freqtrade)
freqtrade.strategy.stop_loss_reached = MagicMock(return_value=SellCheckTuple(
@ -3058,10 +3058,10 @@ def test_sell_profit_only_disable_loss(default_conf, limit_buy_order, limit_buy_
buy=MagicMock(return_value=limit_buy_order_open),
get_fee=fee,
)
default_conf['ask_strategy'] = {
default_conf.update({
'use_sell_signal': True,
'sell_profit_only': False,
}
})
freqtrade = FreqtradeBot(default_conf)
patch_get_signal(freqtrade)
@ -3209,9 +3209,8 @@ def test_ignore_roi_if_buy_signal(default_conf, limit_buy_order, limit_buy_order
buy=MagicMock(return_value=limit_buy_order_open),
get_fee=fee,
)
default_conf['ask_strategy'] = {
'ignore_roi_if_buy_signal': True
}
default_conf['ignore_roi_if_buy_signal'] = True
freqtrade = FreqtradeBot(default_conf)
patch_get_signal(freqtrade)
freqtrade.strategy.min_roi_reached = MagicMock(return_value=True)