Update interface tests
This commit is contained in:
parent
bdb904e714
commit
b7388557a9
@ -495,34 +495,33 @@ def test_custom_exit(default_conf, fee, caplog) -> None:
|
|||||||
enter=False, exit_=False,
|
enter=False, exit_=False,
|
||||||
low=None, high=None)
|
low=None, high=None)
|
||||||
|
|
||||||
assert res.exit_flag is False
|
assert res == []
|
||||||
assert res.exit_type == ExitType.NONE
|
|
||||||
|
|
||||||
strategy.custom_exit = MagicMock(return_value=True)
|
strategy.custom_exit = MagicMock(return_value=True)
|
||||||
res = strategy.should_exit(trade, 1, now,
|
res = strategy.should_exit(trade, 1, now,
|
||||||
enter=False, exit_=False,
|
enter=False, exit_=False,
|
||||||
low=None, high=None)
|
low=None, high=None)
|
||||||
assert res.exit_flag is True
|
assert res[0].exit_flag is True
|
||||||
assert res.exit_type == ExitType.CUSTOM_EXIT
|
assert res[0].exit_type == ExitType.CUSTOM_EXIT
|
||||||
assert res.exit_reason == 'custom_exit'
|
assert res[0].exit_reason == 'custom_exit'
|
||||||
|
|
||||||
strategy.custom_exit = MagicMock(return_value='hello world')
|
strategy.custom_exit = MagicMock(return_value='hello world')
|
||||||
|
|
||||||
res = strategy.should_exit(trade, 1, now,
|
res = strategy.should_exit(trade, 1, now,
|
||||||
enter=False, exit_=False,
|
enter=False, exit_=False,
|
||||||
low=None, high=None)
|
low=None, high=None)
|
||||||
assert res.exit_type == ExitType.CUSTOM_EXIT
|
assert res[0].exit_type == ExitType.CUSTOM_EXIT
|
||||||
assert res.exit_flag is True
|
assert res[0].exit_flag is True
|
||||||
assert res.exit_reason == 'hello world'
|
assert res[0].exit_reason == 'hello world'
|
||||||
|
|
||||||
caplog.clear()
|
caplog.clear()
|
||||||
strategy.custom_exit = MagicMock(return_value='h' * 100)
|
strategy.custom_exit = MagicMock(return_value='h' * 100)
|
||||||
res = strategy.should_exit(trade, 1, now,
|
res = strategy.should_exit(trade, 1, now,
|
||||||
enter=False, exit_=False,
|
enter=False, exit_=False,
|
||||||
low=None, high=None)
|
low=None, high=None)
|
||||||
assert res.exit_type == ExitType.CUSTOM_EXIT
|
assert res[0].exit_type == ExitType.CUSTOM_EXIT
|
||||||
assert res.exit_flag is True
|
assert res[0].exit_flag is True
|
||||||
assert res.exit_reason == 'h' * 64
|
assert res[0].exit_reason == 'h' * 64
|
||||||
assert log_has_re('Custom exit reason returned from custom_exit is too long.*', caplog)
|
assert log_has_re('Custom exit reason returned from custom_exit is too long.*', caplog)
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ def test_may_execute_exit_stoploss_on_exchange_multi(default_conf, ticker, fee,
|
|||||||
side_effect=[stoploss_order_closed, stoploss_order_open, stoploss_order_open])
|
side_effect=[stoploss_order_closed, stoploss_order_open, stoploss_order_open])
|
||||||
# Sell 3rd trade (not called for the first trade)
|
# Sell 3rd trade (not called for the first trade)
|
||||||
should_sell_mock = MagicMock(side_effect=[
|
should_sell_mock = MagicMock(side_effect=[
|
||||||
ExitCheckTuple(exit_type=ExitType.NONE),
|
[],
|
||||||
ExitCheckTuple(exit_type=ExitType.EXIT_SIGNAL)]
|
[ExitCheckTuple(exit_type=ExitType.EXIT_SIGNAL)]]
|
||||||
)
|
)
|
||||||
cancel_order_mock = MagicMock()
|
cancel_order_mock = MagicMock()
|
||||||
mocker.patch('freqtrade.exchange.Binance.stoploss', stoploss)
|
mocker.patch('freqtrade.exchange.Binance.stoploss', stoploss)
|
||||||
@ -160,11 +160,11 @@ def test_forcebuy_last_unlimited(default_conf, ticker, fee, mocker, balance_rati
|
|||||||
_notify_exit=MagicMock(),
|
_notify_exit=MagicMock(),
|
||||||
)
|
)
|
||||||
should_sell_mock = MagicMock(side_effect=[
|
should_sell_mock = MagicMock(side_effect=[
|
||||||
ExitCheckTuple(exit_type=ExitType.NONE),
|
[],
|
||||||
ExitCheckTuple(exit_type=ExitType.EXIT_SIGNAL),
|
[ExitCheckTuple(exit_type=ExitType.EXIT_SIGNAL)],
|
||||||
ExitCheckTuple(exit_type=ExitType.NONE),
|
[],
|
||||||
ExitCheckTuple(exit_type=ExitType.NONE),
|
[],
|
||||||
ExitCheckTuple(exit_type=ExitType.NONE)]
|
[]]
|
||||||
)
|
)
|
||||||
mocker.patch("freqtrade.strategy.interface.IStrategy.should_exit", should_sell_mock)
|
mocker.patch("freqtrade.strategy.interface.IStrategy.should_exit", should_sell_mock)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user