Skip to content

Commit 739a67f

Browse files
committed
test: add test for new webhook functionality
1 parent 48bd5cb commit 739a67f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/rpc/test_rpc_webhook.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,33 @@ def test_send_msg_discord(default_conf, mocker):
477477
assert "title" in msg_mock.call_args_list[0][0][0]["embeds"][0]
478478
assert "color" in msg_mock.call_args_list[0][0][0]["embeds"][0]
479479
assert "fields" in msg_mock.call_args_list[0][0][0]["embeds"][0]
480+
481+
482+
def test_nested_payload_format(default_conf, mocker):
483+
webhook_config = {
484+
"enabled": True,
485+
"url": "https://example.com",
486+
"format": "json",
487+
"status": {
488+
"msgtype": "text",
489+
"text": {"content": "Status update: {status}", "contentlist": ["{status}"]},
490+
},
491+
}
492+
default_conf["webhook"] = webhook_config
493+
494+
webhook = Webhook(RPC(get_patched_freqtradebot(mocker, default_conf)), default_conf)
495+
496+
msg = {
497+
"type": RPCMessageType.STATUS,
498+
"status": "running",
499+
}
500+
501+
post = mocker.patch("freqtrade.rpc.webhook.post")
502+
webhook.send_msg(msg)
503+
504+
expected_payload = {
505+
"msgtype": "text",
506+
"text": {"content": "Status update: running", "contentlist": ["running"]},
507+
}
508+
509+
post.assert_called_once_with("https://example.com", json=expected_payload, timeout=10)

0 commit comments

Comments
 (0)