telegram: Adding forcebuy inline keyboard
This commit is contained in:
@@ -6,6 +6,7 @@ import re
|
||||
from datetime import datetime
|
||||
from random import choice, randint
|
||||
from string import ascii_uppercase
|
||||
from functools import reduce
|
||||
from unittest.mock import ANY, MagicMock
|
||||
|
||||
import arrow
|
||||
@@ -53,6 +54,12 @@ class DummyCls(Telegram):
|
||||
"""
|
||||
raise Exception('test')
|
||||
|
||||
def get_telegram_testobject_with_inline(mocker, default_conf, mock=True, ftbot=None):
|
||||
inline_msg_mock = MagicMock()
|
||||
telegram, ftbot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram._send_inline_msg', inline_msg_mock)
|
||||
|
||||
return telegram, ftbot, msg_mock, inline_msg_mock
|
||||
|
||||
def get_telegram_testobject(mocker, default_conf, mock=True, ftbot=None):
|
||||
msg_mock = MagicMock()
|
||||
@@ -901,6 +908,27 @@ def test_forcebuy_handle_exception(default_conf, update, mocker) -> None:
|
||||
assert msg_mock.call_args_list[0][0][0] == 'Forcebuy not enabled.'
|
||||
|
||||
|
||||
def test_forcebuy_no_pair(default_conf, update, mocker) -> None:
|
||||
mocker.patch('freqtrade.rpc.rpc.CryptoToFiatConverter._find_price', return_value=15000.0)
|
||||
|
||||
fbuy_mock = MagicMock(return_value=None)
|
||||
mocker.patch('freqtrade.rpc.RPC._rpc_forcebuy', fbuy_mock)
|
||||
|
||||
telegram, freqtradebot, _, inline_msg_mock = get_telegram_testobject_with_inline(mocker, default_conf)
|
||||
patch_get_signal(freqtradebot, (True, False))
|
||||
|
||||
context = MagicMock()
|
||||
context.args = []
|
||||
telegram._forcebuy(update=update, context=context)
|
||||
|
||||
assert fbuy_mock.call_count == 0
|
||||
assert inline_msg_mock.call_count == 1
|
||||
assert inline_msg_mock.call_args_list[0][0][0] == 'Which pair?'
|
||||
assert inline_msg_mock.call_args_list[0][1]['callback_query_handler'] == 'forcebuy'
|
||||
keyboard = inline_msg_mock.call_args_list[0][1]['keyboard']
|
||||
assert reduce(lambda acc, x: acc + len(x), keyboard, 0) == 4
|
||||
|
||||
|
||||
def test_performance_handle(default_conf, update, ticker, fee,
|
||||
limit_buy_order, limit_sell_order, mocker) -> None:
|
||||
|
||||
|
Reference in New Issue
Block a user