From bbc663fce1d25dda07a5e137f27689edd5b3ea9d Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 31 Jan 2023 19:26:26 +0100 Subject: [PATCH] Add telegram test --- tests/rpc/test_rpc_telegram.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index a15620193..5e3c2bd18 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -1678,6 +1678,40 @@ def test_telegram_delete_trade(mocker, update, default_conf, fee, is_short): assert "Please make sure to take care of this asset" in msg_mock.call_args_list[0][0][0] +@pytest.mark.parametrize('is_short', [True, False]) +def test_telegram_delete_open_order(mocker, update, default_conf, fee, is_short, ticker): + + mocker.patch.multiple( + 'freqtrade.exchange.Exchange', + fetch_ticker=ticker, + ) + telegram, _, msg_mock = get_telegram_testobject(mocker, default_conf) + context = MagicMock() + context.args = [] + + telegram._cancel_open_order(update=update, context=context) + assert "Trade-id not set." in msg_mock.call_args_list[0][0][0] + + msg_mock.reset_mock() + create_mock_trades(fee, is_short=is_short) + + context = MagicMock() + context.args = [5] + telegram._cancel_open_order(update=update, context=context) + assert "No open order for trade_id" in msg_mock.call_args_list[0][0][0] + + msg_mock.reset_mock() + + trade = Trade.get_trades([Trade.id == 6]).first() + mocker.patch('freqtrade.exchange.Exchange.fetch_order', + return_value=trade.orders[-1].to_ccxt_object()) + context = MagicMock() + context.args = [6] + telegram._cancel_open_order(update=update, context=context) + assert msg_mock.call_count == 1 + assert "Open order canceled." in msg_mock.call_args_list[0][0][0] + + def test_help_handle(default_conf, update, mocker) -> None: telegram, _, msg_mock = get_telegram_testobject(mocker, default_conf)