mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 01:40:15 +08:00
28 lines
812 B
Python
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)
|