Update test to also cover "no trade found" scenario

This commit is contained in:
Matthias 2022-04-09 10:04:10 +02:00
parent ddfc68d533
commit f385e2c2b6

View File

@ -1235,13 +1235,18 @@ def test_force_exit_no_pair(default_conf, update, ticker, fee, mocker) -> None:
patch_get_signal(freqtradebot) patch_get_signal(freqtradebot)
# /forceexit
context = MagicMock()
context.args = []
telegram._force_exit(update=update, context=context)
# No pair
assert msg_mock.call_args_list[0][1]['msg'] == 'No open trade found.'
# Create some test data # Create some test data
freqtradebot.enter_positions() freqtradebot.enter_positions()
msg_mock.reset_mock() msg_mock.reset_mock()
# /forcesell all # /forceexit
context = MagicMock()
context.args = []
telegram._force_exit(update=update, context=context) telegram._force_exit(update=update, context=context)
keyboard = msg_mock.call_args_list[0][1]['keyboard'] keyboard = msg_mock.call_args_list[0][1]['keyboard']
# 4 pairs + cancel # 4 pairs + cancel
@ -1258,7 +1263,7 @@ def test_force_exit_no_pair(default_conf, update, ticker, fee, mocker) -> None:
assert femock.call_count == 1 assert femock.call_count == 1
assert femock.call_args_list[0][0][0] == '2' assert femock.call_args_list[0][0][0] == '2'
# Retry selling - but cancel instead # Retry exiting - but cancel instead
update.callback_query.reset_mock() update.callback_query.reset_mock()
telegram._force_exit(update=update, context=context) telegram._force_exit(update=update, context=context)
# Use cancel button # Use cancel button