From 739a67fdcb732db1d67984059be5b0fcdc75ec70 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 31 Aug 2025 08:40:28 +0200 Subject: [PATCH] test: add test for new webhook functionality --- tests/rpc/test_rpc_webhook.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/rpc/test_rpc_webhook.py b/tests/rpc/test_rpc_webhook.py index b60e52177..24629d5e8 100644 --- a/tests/rpc/test_rpc_webhook.py +++ b/tests/rpc/test_rpc_webhook.py @@ -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)