From 20d17cbc52e30012f49eea19d16ca893242c48f9 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 15 Apr 2023 17:39:23 +0200 Subject: [PATCH] Disable telegram from default_conf --- tests/conftest.py | 2 +- tests/rpc/test_rpc_manager.py | 10 +++++++--- tests/rpc/test_rpc_telegram.py | 7 +++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 0aa6e70a8..2f2345d54 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -504,7 +504,7 @@ def get_default_conf(testdatadir): {"method": "StaticPairList"} ], "telegram": { - "enabled": True, + "enabled": False, "token": "token", "chat_id": "0", "notification_settings": {}, diff --git a/tests/rpc/test_rpc_manager.py b/tests/rpc/test_rpc_manager.py index 21c8b0813..f0bb72fc9 100644 --- a/tests/rpc/test_rpc_manager.py +++ b/tests/rpc/test_rpc_manager.py @@ -28,6 +28,7 @@ def test_init_telegram_disabled(mocker, default_conf, caplog) -> None: def test_init_telegram_enabled(mocker, default_conf, caplog) -> None: caplog.set_level(logging.DEBUG) + default_conf['telegram']['enabled'] = True mocker.patch('freqtrade.rpc.telegram.Telegram._init', MagicMock()) rpc_manager = RPCManager(get_patched_freqtradebot(mocker, default_conf)) @@ -52,6 +53,7 @@ def test_cleanup_telegram_disabled(mocker, default_conf, caplog) -> None: def test_cleanup_telegram_enabled(mocker, default_conf, caplog) -> None: caplog.set_level(logging.DEBUG) + default_conf['telegram']['enabled'] = True mocker.patch('freqtrade.rpc.telegram.Telegram._init', MagicMock()) telegram_mock = mocker.patch('freqtrade.rpc.telegram.Telegram.cleanup', MagicMock()) @@ -85,7 +87,7 @@ def test_send_msg_telegram_disabled(mocker, default_conf, caplog) -> None: def test_send_msg_telegram_error(mocker, default_conf, caplog) -> None: mocker.patch('freqtrade.rpc.telegram.Telegram._init', MagicMock()) mocker.patch('freqtrade.rpc.telegram.Telegram.send_msg', side_effect=ValueError()) - + default_conf['telegram']['enabled'] = True freqtradebot = get_patched_freqtradebot(mocker, default_conf) rpc_manager = RPCManager(freqtradebot) rpc_manager.send_msg({ @@ -99,6 +101,7 @@ def test_send_msg_telegram_error(mocker, default_conf, caplog) -> None: def test_process_msg_queue(mocker, default_conf, caplog) -> None: telegram_mock = mocker.patch('freqtrade.rpc.telegram.Telegram.send_msg') + default_conf['telegram']['enabled'] = True default_conf['telegram']['allow_custom_messages'] = True mocker.patch('freqtrade.rpc.telegram.Telegram._init') @@ -115,9 +118,9 @@ def test_process_msg_queue(mocker, default_conf, caplog) -> None: def test_send_msg_telegram_enabled(mocker, default_conf, caplog) -> None: + default_conf['telegram']['enabled'] = True telegram_mock = mocker.patch('freqtrade.rpc.telegram.Telegram.send_msg') mocker.patch('freqtrade.rpc.telegram.Telegram._init') - freqtradebot = get_patched_freqtradebot(mocker, default_conf) rpc_manager = RPCManager(freqtradebot) rpc_manager.send_msg({ @@ -166,7 +169,8 @@ def test_send_msg_webhook_CustomMessagetype(mocker, default_conf, caplog) -> Non caplog) -def test_startupmessages_telegram_enabled(mocker, default_conf, caplog) -> None: +def test_startupmessages_telegram_enabled(mocker, default_conf) -> None: + default_conf['telegram']['enabled'] = True telegram_mock = mocker.patch('freqtrade.rpc.telegram.Telegram.send_msg', MagicMock()) mocker.patch('freqtrade.rpc.telegram.Telegram._init', MagicMock()) diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index cc83f96e0..7978a2a23 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -36,6 +36,13 @@ from tests.conftest import (CURRENT_TEST_STRATEGY, EXMS, create_mock_trades, patch_exchange, patch_get_signal, patch_whitelist) +@pytest.fixture +def default_conf(default_conf) -> dict: + # Telegram is enabled by default + default_conf['telegram']['enabled'] = True + return default_conf + + class DummyCls(Telegram): """ Dummy class for testing the Telegram @authorized_only decorator