check for Exception and log msgs
This commit is contained in:
parent
cd1a8e2c42
commit
b1fe5940fa
@ -16,6 +16,7 @@ from telegram.error import NetworkError
|
|||||||
from freqtrade import __version__
|
from freqtrade import __version__
|
||||||
from freqtrade.constants import CANCEL_REASON
|
from freqtrade.constants import CANCEL_REASON
|
||||||
from freqtrade.edge import PairInfo
|
from freqtrade.edge import PairInfo
|
||||||
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.freqtradebot import FreqtradeBot
|
from freqtrade.freqtradebot import FreqtradeBot
|
||||||
from freqtrade.loggers import setup_logging
|
from freqtrade.loggers import setup_logging
|
||||||
from freqtrade.persistence import PairLocks, Trade
|
from freqtrade.persistence import PairLocks, Trade
|
||||||
@ -1763,13 +1764,10 @@ def test__send_msg_keyboard(default_conf, mocker, caplog) -> None:
|
|||||||
# invalid keyboard in config -> default keyboard
|
# invalid keyboard in config -> default keyboard
|
||||||
freqtradebot.config['telegram']['enabled'] = True
|
freqtradebot.config['telegram']['enabled'] = True
|
||||||
freqtradebot.config['telegram']['keyboard'] = invalid_keys_list
|
freqtradebot.config['telegram']['keyboard'] = invalid_keys_list
|
||||||
|
err_msg = re.escape("config.telegram.keyboard: invalid commands for "
|
||||||
|
"custom keyboard: ['/not_valid', '/alsoinvalid']")
|
||||||
|
with pytest.raises(OperationalException, match=err_msg):
|
||||||
telegram = init_telegram(freqtradebot)
|
telegram = init_telegram(freqtradebot)
|
||||||
telegram._send_msg('test')
|
|
||||||
used_keyboard = bot.send_message.call_args[1]['reply_markup']
|
|
||||||
assert used_keyboard == default_keyboard
|
|
||||||
assert log_has("rpc.telegram: invalid commands for custom keyboard: "
|
|
||||||
"['/not_valid', '/alsoinvalid']", caplog)
|
|
||||||
assert log_has('rpc.telegram: using default keyboard.', caplog)
|
|
||||||
|
|
||||||
# valid keyboard in config -> custom keyboard
|
# valid keyboard in config -> custom keyboard
|
||||||
freqtradebot.config['telegram']['enabled'] = True
|
freqtradebot.config['telegram']['enabled'] = True
|
||||||
@ -1778,6 +1776,6 @@ def test__send_msg_keyboard(default_conf, mocker, caplog) -> None:
|
|||||||
telegram._send_msg('test')
|
telegram._send_msg('test')
|
||||||
used_keyboard = bot.send_message.call_args[1]['reply_markup']
|
used_keyboard = bot.send_message.call_args[1]['reply_markup']
|
||||||
assert used_keyboard == custom_keyboard
|
assert used_keyboard == custom_keyboard
|
||||||
assert log_has("rpc.telegram using custom keyboard from config.json: "
|
assert log_has("using custom keyboard from config.json: "
|
||||||
"[['/daily', '/stats', '/balance', '/profit'], ['/count', "
|
"[['/daily', '/stats', '/balance', '/profit'], ['/count', "
|
||||||
"'/start', '/reload_config', '/help']]", caplog)
|
"'/start', '/reload_config', '/help']]", caplog)
|
||||||
|
Loading…
Reference in New Issue
Block a user