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)