diff --git a/freqtrade/tests/rpc/test_fiat_convert.py b/freqtrade/tests/rpc/test_fiat_convert.py index 66870efcc..1689ecac6 100644 --- a/freqtrade/tests/rpc/test_fiat_convert.py +++ b/freqtrade/tests/rpc/test_fiat_convert.py @@ -91,7 +91,7 @@ def test_fiat_convert_unsupported_crypto(mocker, caplog): mocker.patch('freqtrade.rpc.fiat_convert.CryptoToFiatConverter._cryptomap', return_value=[]) fiat_convert = CryptoToFiatConverter() assert fiat_convert._find_price(crypto_symbol='CRYPTO_123', fiat_symbol='EUR') == 0.0 - assert log_has('unsupported crypto-symbol CRYPTO_123 - returning 0.0', caplog.record_tuples) + assert log_has('unsupported crypto-symbol CRYPTO_123 - returning 0.0', caplog) def test_fiat_convert_get_price(mocker): @@ -190,7 +190,7 @@ def test_fiat_invalid_response(mocker, caplog): length_cryptomap = len(fiat_convert._cryptomap) assert length_cryptomap == 0 assert log_has('Could not load FIAT Cryptocurrency map for the following problem: TypeError', - caplog.record_tuples) + caplog) def test_convert_amount(mocker): diff --git a/freqtrade/tests/rpc/test_rpc_apiserver.py b/freqtrade/tests/rpc/test_rpc_apiserver.py index bd420ada6..a218d5622 100644 --- a/freqtrade/tests/rpc/test_rpc_apiserver.py +++ b/freqtrade/tests/rpc/test_rpc_apiserver.py @@ -148,8 +148,8 @@ def test_api_run(default_conf, mocker, caplog): assert isinstance(server_mock.call_args_list[0][0][2], Flask) assert hasattr(apiserver, "srv") - assert log_has("Starting HTTP Server at 127.0.0.1:8080", caplog.record_tuples) - assert log_has("Starting Local Rest Server.", caplog.record_tuples) + assert log_has("Starting HTTP Server at 127.0.0.1:8080", caplog) + assert log_has("Starting Local Rest Server.", caplog) # Test binding to public caplog.clear() @@ -165,22 +165,20 @@ def test_api_run(default_conf, mocker, caplog): assert server_mock.call_args_list[0][0][0] == "0.0.0.0" assert server_mock.call_args_list[0][0][1] == "8089" assert isinstance(server_mock.call_args_list[0][0][2], Flask) - assert log_has("Starting HTTP Server at 0.0.0.0:8089", caplog.record_tuples) - assert log_has("Starting Local Rest Server.", caplog.record_tuples) + assert log_has("Starting HTTP Server at 0.0.0.0:8089", caplog) + assert log_has("Starting Local Rest Server.", caplog) assert log_has("SECURITY WARNING - Local Rest Server listening to external connections", - caplog.record_tuples) + caplog) assert log_has("SECURITY WARNING - This is insecure please set to your loopback," - "e.g 127.0.0.1 in config.json", - caplog.record_tuples) + "e.g 127.0.0.1 in config.json", caplog) assert log_has("SECURITY WARNING - No password for local REST Server defined. " - "Please make sure that this is intentional!", - caplog.record_tuples) + "Please make sure that this is intentional!", caplog) # Test crashing flask caplog.clear() mocker.patch('freqtrade.rpc.api_server.make_server', MagicMock(side_effect=Exception)) apiserver.run() - assert log_has("Api server failed to start.", caplog.record_tuples) + assert log_has("Api server failed to start.", caplog) def test_api_cleanup(default_conf, mocker, caplog): @@ -199,7 +197,7 @@ def test_api_cleanup(default_conf, mocker, caplog): apiserver.cleanup() assert stop_mock.shutdown.call_count == 1 - assert log_has("Stopping API Server", caplog.record_tuples) + assert log_has("Stopping API Server", caplog) def test_api_reloadconf(botclient): diff --git a/freqtrade/tests/rpc/test_rpc_manager.py b/freqtrade/tests/rpc/test_rpc_manager.py index 91fd2297f..468e3e8e5 100644 --- a/freqtrade/tests/rpc/test_rpc_manager.py +++ b/freqtrade/tests/rpc/test_rpc_manager.py @@ -19,7 +19,7 @@ def test_init_telegram_disabled(mocker, default_conf, caplog) -> None: default_conf['telegram']['enabled'] = False rpc_manager = RPCManager(get_patched_freqtradebot(mocker, default_conf)) - assert not log_has('Enabling rpc.telegram ...', caplog.record_tuples) + assert not log_has('Enabling rpc.telegram ...', caplog) assert rpc_manager.registered_modules == [] @@ -28,7 +28,7 @@ def test_init_telegram_enabled(mocker, default_conf, caplog) -> None: mocker.patch('freqtrade.rpc.telegram.Telegram._init', MagicMock()) rpc_manager = RPCManager(get_patched_freqtradebot(mocker, default_conf)) - assert log_has('Enabling rpc.telegram ...', caplog.record_tuples) + assert log_has('Enabling rpc.telegram ...', caplog) len_modules = len(rpc_manager.registered_modules) assert len_modules == 1 assert 'telegram' in [mod.name for mod in rpc_manager.registered_modules] @@ -43,7 +43,7 @@ def test_cleanup_telegram_disabled(mocker, default_conf, caplog) -> None: rpc_manager = RPCManager(freqtradebot) rpc_manager.cleanup() - assert not log_has('Cleaning up rpc.telegram ...', caplog.record_tuples) + assert not log_has('Cleaning up rpc.telegram ...', caplog) assert telegram_mock.call_count == 0 @@ -59,7 +59,7 @@ def test_cleanup_telegram_enabled(mocker, default_conf, caplog) -> None: assert 'telegram' in [mod.name for mod in rpc_manager.registered_modules] rpc_manager.cleanup() - assert log_has('Cleaning up rpc.telegram ...', caplog.record_tuples) + assert log_has('Cleaning up rpc.telegram ...', caplog) assert 'telegram' not in [mod.name for mod in rpc_manager.registered_modules] assert telegram_mock.call_count == 1 @@ -75,7 +75,7 @@ def test_send_msg_telegram_disabled(mocker, default_conf, caplog) -> None: 'status': 'test' }) - assert log_has("Sending rpc message: {'type': status, 'status': 'test'}", caplog.record_tuples) + assert log_has("Sending rpc message: {'type': status, 'status': 'test'}", caplog) assert telegram_mock.call_count == 0 @@ -90,7 +90,7 @@ def test_send_msg_telegram_enabled(mocker, default_conf, caplog) -> None: 'status': 'test' }) - assert log_has("Sending rpc message: {'type': status, 'status': 'test'}", caplog.record_tuples) + assert log_has("Sending rpc message: {'type': status, 'status': 'test'}", caplog) assert telegram_mock.call_count == 1 @@ -100,7 +100,7 @@ def test_init_webhook_disabled(mocker, default_conf, caplog) -> None: default_conf['webhook'] = {'enabled': False} rpc_manager = RPCManager(get_patched_freqtradebot(mocker, default_conf)) - assert not log_has('Enabling rpc.webhook ...', caplog.record_tuples) + assert not log_has('Enabling rpc.webhook ...', caplog) assert rpc_manager.registered_modules == [] @@ -110,7 +110,7 @@ def test_init_webhook_enabled(mocker, default_conf, caplog) -> None: default_conf['webhook'] = {'enabled': True, 'url': "https://DEADBEEF.com"} rpc_manager = RPCManager(get_patched_freqtradebot(mocker, default_conf)) - assert log_has('Enabling rpc.webhook ...', caplog.record_tuples) + assert log_has('Enabling rpc.webhook ...', caplog) assert len(rpc_manager.registered_modules) == 1 assert 'webhook' in [mod.name for mod in rpc_manager.registered_modules] @@ -144,7 +144,7 @@ def test_init_apiserver_disabled(mocker, default_conf, caplog) -> None: default_conf['telegram']['enabled'] = False rpc_manager = RPCManager(get_patched_freqtradebot(mocker, default_conf)) - assert not log_has('Enabling rpc.api_server', caplog.record_tuples) + assert not log_has('Enabling rpc.api_server', caplog) assert rpc_manager.registered_modules == [] assert run_mock.call_count == 0 @@ -160,7 +160,7 @@ def test_init_apiserver_enabled(mocker, default_conf, caplog) -> None: "listen_port": "8080"} rpc_manager = RPCManager(get_patched_freqtradebot(mocker, default_conf)) - assert log_has('Enabling rpc.api_server', caplog.record_tuples) + assert log_has('Enabling rpc.api_server', caplog) assert len(rpc_manager.registered_modules) == 1 assert 'apiserver' in [mod.name for mod in rpc_manager.registered_modules] assert run_mock.call_count == 1 diff --git a/freqtrade/tests/rpc/test_rpc_telegram.py b/freqtrade/tests/rpc/test_rpc_telegram.py index 1bee5bff3..3575520ad 100644 --- a/freqtrade/tests/rpc/test_rpc_telegram.py +++ b/freqtrade/tests/rpc/test_rpc_telegram.py @@ -76,7 +76,7 @@ def test_init(default_conf, mocker, caplog) -> None: "['performance'], ['daily'], ['count'], ['reload_conf'], " \ "['stopbuy'], ['whitelist'], ['blacklist'], ['edge'], ['help'], ['version']]" - assert log_has(message_str, caplog.record_tuples) + assert log_has(message_str, caplog) def test_cleanup(default_conf, mocker) -> None: @@ -102,18 +102,9 @@ def test_authorized_only(default_conf, mocker, caplog) -> None: dummy = DummyCls(bot) dummy.dummy_handler(bot=MagicMock(), update=update) assert dummy.state['called'] is True - assert log_has( - 'Executing handler: dummy_handler for chat_id: 0', - caplog.record_tuples - ) - assert not log_has( - 'Rejected unauthorized message from: 0', - caplog.record_tuples - ) - assert not log_has( - 'Exception occurred within Telegram module', - caplog.record_tuples - ) + assert log_has('Executing handler: dummy_handler for chat_id: 0', caplog) + assert not log_has('Rejected unauthorized message from: 0', caplog) + assert not log_has('Exception occurred within Telegram module', caplog) def test_authorized_only_unauthorized(default_conf, mocker, caplog) -> None: @@ -128,18 +119,9 @@ def test_authorized_only_unauthorized(default_conf, mocker, caplog) -> None: dummy = DummyCls(bot) dummy.dummy_handler(bot=MagicMock(), update=update) assert dummy.state['called'] is False - assert not log_has( - 'Executing handler: dummy_handler for chat_id: 3735928559', - caplog.record_tuples - ) - assert log_has( - 'Rejected unauthorized message from: 3735928559', - caplog.record_tuples - ) - assert not log_has( - 'Exception occurred within Telegram module', - caplog.record_tuples - ) + assert not log_has('Executing handler: dummy_handler for chat_id: 3735928559', caplog) + assert log_has('Rejected unauthorized message from: 3735928559', caplog) + assert not log_has('Exception occurred within Telegram module', caplog) def test_authorized_only_exception(default_conf, mocker, caplog) -> None: @@ -156,18 +138,9 @@ def test_authorized_only_exception(default_conf, mocker, caplog) -> None: dummy.dummy_exception(bot=MagicMock(), update=update) assert dummy.state['called'] is False - assert not log_has( - 'Executing handler: dummy_handler for chat_id: 0', - caplog.record_tuples - ) - assert not log_has( - 'Rejected unauthorized message from: 0', - caplog.record_tuples - ) - assert log_has( - 'Exception occurred within Telegram module', - caplog.record_tuples - ) + assert not log_has('Executing handler: dummy_handler for chat_id: 0', caplog) + assert not log_has('Rejected unauthorized message from: 0', caplog) + assert log_has('Exception occurred within Telegram module', caplog) def test_status(default_conf, update, mocker, fee, ticker, markets) -> None: @@ -1440,7 +1413,4 @@ def test__send_msg_network_error(default_conf, mocker, caplog) -> None: # Bot should've tried to send it twice assert len(bot.method_calls) == 2 - assert log_has( - 'Telegram NetworkError: Oh snap! Trying one more time.', - caplog.record_tuples - ) + assert log_has('Telegram NetworkError: Oh snap! Trying one more time.', caplog) diff --git a/freqtrade/tests/rpc/test_rpc_webhook.py b/freqtrade/tests/rpc/test_rpc_webhook.py index a2dcd9b31..cc491d4dd 100644 --- a/freqtrade/tests/rpc/test_rpc_webhook.py +++ b/freqtrade/tests/rpc/test_rpc_webhook.py @@ -115,7 +115,7 @@ def test_exception_send_msg(default_conf, mocker, caplog): webhook = Webhook(get_patched_freqtradebot(mocker, default_conf)) webhook.send_msg({'type': RPCMessageType.BUY_NOTIFICATION}) assert log_has(f"Message type {RPCMessageType.BUY_NOTIFICATION} not configured for webhooks", - caplog.record_tuples) + caplog) default_conf["webhook"] = get_webhook_dict() default_conf["webhook"]["webhookbuy"]["value1"] = "{DEADBEEF:8f}" @@ -135,7 +135,7 @@ def test_exception_send_msg(default_conf, mocker, caplog): } webhook.send_msg(msg) assert log_has("Problem calling Webhook. Please check your webhook configuration. " - "Exception: 'DEADBEEF'", caplog.record_tuples) + "Exception: 'DEADBEEF'", caplog) msg_mock = MagicMock() mocker.patch("freqtrade.rpc.webhook.Webhook._send_msg", msg_mock) @@ -164,4 +164,4 @@ def test__send_msg(default_conf, mocker, caplog): post = MagicMock(side_effect=RequestException) mocker.patch("freqtrade.rpc.webhook.post", post) webhook._send_msg(msg) - assert log_has('Could not call webhook url. Exception: ', caplog.record_tuples) + assert log_has('Could not call webhook url. Exception: ', caplog)