Files
AstrBot/tests/test_webhook_server_response.py
Weilong Liao 1e3b12acc9 fix: preserve webhook callback responses
Preserve raw webhook callback responses and fix QQ webhook validation handling.
2026-07-03 00:25:09 +08:00

28 lines
812 B
Python

from fastapi.responses import JSONResponse, Response
from astrbot.core.platform.webhook_server import webhook_response_from_result
def test_webhook_response_preserves_plain_string():
response = webhook_response_from_result("success")
assert isinstance(response, Response)
assert response.body == b"success"
def test_webhook_response_preserves_tuple_headers():
response = webhook_response_from_result(
("accepted", 202, {"Content-Type": "text/plain"})
)
assert isinstance(response, Response)
assert response.status_code == 202
assert response.media_type == "text/plain"
assert response.body == b"accepted"
def test_webhook_response_keeps_json_for_dict():
response = webhook_response_from_result({"ok": True})
assert isinstance(response, JSONResponse)