Add test for /delete

This commit is contained in:
Matthias 2020-08-04 14:49:59 +02:00
parent 26c7341b7d
commit 4b0164770c
2 changed files with 29 additions and 2 deletions

View File

@ -94,7 +94,7 @@ class Telegram(RPC):
CommandHandler('forcesell', self._forcesell),
CommandHandler('forcebuy', self._forcebuy),
CommandHandler('trades', self._trades),
CommandHandler('delete', self._delete),
CommandHandler('delete', self._delete_trade),
CommandHandler('performance', self._performance),
CommandHandler('daily', self._daily),
CommandHandler('count', self._count),
@ -535,7 +535,7 @@ class Telegram(RPC):
self._send_msg(str(e))
@authorized_only
def _delete(self, update: Update, context: CallbackContext) -> None:
def _delete_trade(self, update: Update, context: CallbackContext) -> None:
"""
Handler for /delete <id>.
Delete the given trade

View File

@ -1177,6 +1177,33 @@ def test_telegram_trades(mocker, update, default_conf, fee):
assert "<pre>" in msg_mock.call_args_list[0][0][0]
def test_telegram_delete_trade(mocker, update, default_conf, fee):
msg_mock = MagicMock()
mocker.patch.multiple(
'freqtrade.rpc.telegram.Telegram',
_init=MagicMock(),
_send_msg=msg_mock
)
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
telegram = Telegram(freqtradebot)
context = MagicMock()
context.args = []
telegram._delete_trade(update=update, context=context)
assert "invalid argument" in msg_mock.call_args_list[0][0][0]
msg_mock.reset_mock()
create_mock_trades(fee)
context = MagicMock()
context.args = [1]
telegram._delete_trade(update=update, context=context)
msg_mock.call_count == 1
assert "Delete Result" in msg_mock.call_args_list[0][0][0]
assert "Deleted trade 1." in msg_mock.call_args_list[0][0][0]
def test_help_handle(default_conf, update, mocker) -> None:
msg_mock = MagicMock()
mocker.patch.multiple(