From d060d277457b26e1e7229e04ccb3d6a95ef6e90d Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 30 Aug 2019 07:05:22 +0200 Subject: [PATCH] Add test for all messagetypes --- freqtrade/tests/rpc/test_rpc_webhook.py | 33 ++++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/freqtrade/tests/rpc/test_rpc_webhook.py b/freqtrade/tests/rpc/test_rpc_webhook.py index cc491d4dd..1c6c07e16 100644 --- a/freqtrade/tests/rpc/test_rpc_webhook.py +++ b/freqtrade/tests/rpc/test_rpc_webhook.py @@ -91,21 +91,24 @@ def test_send_msg(default_conf, mocker): assert (msg_mock.call_args[0][0]["value3"] == default_conf["webhook"]["webhooksell"]["value3"].format(**msg)) - # Test notification - msg = { - 'type': RPCMessageType.STATUS_NOTIFICATION, - 'status': 'Unfilled sell order for BTC cancelled due to timeout' - } - msg_mock = MagicMock() - mocker.patch("freqtrade.rpc.webhook.Webhook._send_msg", msg_mock) - webhook.send_msg(msg) - assert msg_mock.call_count == 1 - assert (msg_mock.call_args[0][0]["value1"] == - default_conf["webhook"]["webhookstatus"]["value1"].format(**msg)) - assert (msg_mock.call_args[0][0]["value2"] == - default_conf["webhook"]["webhookstatus"]["value2"].format(**msg)) - assert (msg_mock.call_args[0][0]["value3"] == - default_conf["webhook"]["webhookstatus"]["value3"].format(**msg)) + for msgtype in [RPCMessageType.STATUS_NOTIFICATION, + RPCMessageType.WARNING_NOTIFICATION, + RPCMessageType.CUSTOM_NOTIFICATION]: + # Test notification + msg = { + 'type': msgtype, + 'status': 'Unfilled sell order for BTC cancelled due to timeout' + } + msg_mock = MagicMock() + mocker.patch("freqtrade.rpc.webhook.Webhook._send_msg", msg_mock) + webhook.send_msg(msg) + assert msg_mock.call_count == 1 + assert (msg_mock.call_args[0][0]["value1"] == + default_conf["webhook"]["webhookstatus"]["value1"].format(**msg)) + assert (msg_mock.call_args[0][0]["value2"] == + default_conf["webhook"]["webhookstatus"]["value2"].format(**msg)) + assert (msg_mock.call_args[0][0]["value3"] == + default_conf["webhook"]["webhookstatus"]["value3"].format(**msg)) def test_exception_send_msg(default_conf, mocker, caplog):