mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Fix test_telegram _init test
This commit is contained in:
parent
cf0b37057c
commit
c9e6137ad0
|
@ -166,6 +166,9 @@ class Telegram(RPCHandler):
|
|||
logger.info('using custom keyboard from '
|
||||
f'config.json: {self._keyboard}')
|
||||
|
||||
def _init_telegram_app(self):
|
||||
return Application.builder().token(self._config['telegram']['token']).build()
|
||||
|
||||
def _init(self) -> None:
|
||||
"""
|
||||
Initializes this module with the given config,
|
||||
|
@ -179,7 +182,7 @@ class Telegram(RPCHandler):
|
|||
self._loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(self._loop)
|
||||
|
||||
self._app = Application.builder().token(self._config['telegram']['token']).build()
|
||||
self._app = self._init_telegram_app()
|
||||
|
||||
# Register command handler and start telegram message polling
|
||||
handles = [
|
||||
|
|
|
@ -105,15 +105,18 @@ def test_telegram__init__(default_conf, mocker) -> None:
|
|||
|
||||
|
||||
def test_telegram_init(default_conf, mocker, caplog) -> None:
|
||||
start_polling = MagicMock()
|
||||
mocker.patch('freqtrade.rpc.telegram.Updater', MagicMock(return_value=start_polling))
|
||||
app_mock = MagicMock()
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram._start_thread', MagicMock())
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram._init_telegram_app', return_value=app_mock)
|
||||
mocker.patch('freqtrade.rpc.telegram.Telegram._startup_telegram', AsyncMock())
|
||||
|
||||
get_telegram_testobject(mocker, default_conf, mock=False)
|
||||
assert start_polling.call_count == 0
|
||||
telegram, _, _ = get_telegram_testobject(mocker, default_conf, mock=False)
|
||||
telegram._init()
|
||||
assert app_mock.call_count == 0
|
||||
|
||||
# number of handles registered
|
||||
assert start_polling.dispatcher.add_handler.call_count > 0
|
||||
assert start_polling.start_polling.call_count == 1
|
||||
assert app_mock.add_handler.call_count > 0
|
||||
# assert start_polling.start_polling.call_count == 1
|
||||
|
||||
message_str = ("rpc.telegram is listening for following commands: [['status'], ['profit'], "
|
||||
"['balance'], ['start'], ['stop'], "
|
||||
|
|
Loading…
Reference in New Issue
Block a user