Add test for all messagetypes

This commit is contained in:
Matthias 2019-08-30 07:05:22 +02:00
parent 75dc174c76
commit d060d27745

View File

@ -91,21 +91,24 @@ def test_send_msg(default_conf, mocker):
assert (msg_mock.call_args[0][0]["value3"] == assert (msg_mock.call_args[0][0]["value3"] ==
default_conf["webhook"]["webhooksell"]["value3"].format(**msg)) default_conf["webhook"]["webhooksell"]["value3"].format(**msg))
# Test notification for msgtype in [RPCMessageType.STATUS_NOTIFICATION,
msg = { RPCMessageType.WARNING_NOTIFICATION,
'type': RPCMessageType.STATUS_NOTIFICATION, RPCMessageType.CUSTOM_NOTIFICATION]:
'status': 'Unfilled sell order for BTC cancelled due to timeout' # Test notification
} msg = {
msg_mock = MagicMock() 'type': msgtype,
mocker.patch("freqtrade.rpc.webhook.Webhook._send_msg", msg_mock) 'status': 'Unfilled sell order for BTC cancelled due to timeout'
webhook.send_msg(msg) }
assert msg_mock.call_count == 1 msg_mock = MagicMock()
assert (msg_mock.call_args[0][0]["value1"] == mocker.patch("freqtrade.rpc.webhook.Webhook._send_msg", msg_mock)
default_conf["webhook"]["webhookstatus"]["value1"].format(**msg)) webhook.send_msg(msg)
assert (msg_mock.call_args[0][0]["value2"] == assert msg_mock.call_count == 1
default_conf["webhook"]["webhookstatus"]["value2"].format(**msg)) assert (msg_mock.call_args[0][0]["value1"] ==
assert (msg_mock.call_args[0][0]["value3"] == default_conf["webhook"]["webhookstatus"]["value1"].format(**msg))
default_conf["webhook"]["webhookstatus"]["value3"].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): def test_exception_send_msg(default_conf, mocker, caplog):