mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 00:23:07 +00:00
test: add test for new webhook functionality
This commit is contained in:
@@ -477,3 +477,33 @@ def test_send_msg_discord(default_conf, mocker):
|
||||
assert "title" in msg_mock.call_args_list[0][0][0]["embeds"][0]
|
||||
assert "color" in msg_mock.call_args_list[0][0][0]["embeds"][0]
|
||||
assert "fields" in msg_mock.call_args_list[0][0][0]["embeds"][0]
|
||||
|
||||
|
||||
def test_nested_payload_format(default_conf, mocker):
|
||||
webhook_config = {
|
||||
"enabled": True,
|
||||
"url": "https://example.com",
|
||||
"format": "json",
|
||||
"status": {
|
||||
"msgtype": "text",
|
||||
"text": {"content": "Status update: {status}", "contentlist": ["{status}"]},
|
||||
},
|
||||
}
|
||||
default_conf["webhook"] = webhook_config
|
||||
|
||||
webhook = Webhook(RPC(get_patched_freqtradebot(mocker, default_conf)), default_conf)
|
||||
|
||||
msg = {
|
||||
"type": RPCMessageType.STATUS,
|
||||
"status": "running",
|
||||
}
|
||||
|
||||
post = mocker.patch("freqtrade.rpc.webhook.post")
|
||||
webhook.send_msg(msg)
|
||||
|
||||
expected_payload = {
|
||||
"msgtype": "text",
|
||||
"text": {"content": "Status update: running", "contentlist": ["running"]},
|
||||
}
|
||||
|
||||
post.assert_called_once_with("https://example.com", json=expected_payload, timeout=10)
|
||||
|
||||
Reference in New Issue
Block a user