Fix cloud webhook body (#20739)
* Bugfix cloud webhooks text response * address comments * Fix lint
This commit is contained in:
parent
c812176e94
commit
29b64d56be
5 changed files with 40 additions and 35 deletions
24
tests/components/cloud/test_utils.py
Normal file
24
tests/components/cloud/test_utils.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
"""Test aiohttp request helper."""
|
||||
from aiohttp import web
|
||||
|
||||
from homeassistant.components.cloud import utils
|
||||
|
||||
|
||||
def test_serialize_text():
|
||||
"""Test serializing a text response."""
|
||||
response = web.Response(status=201, text='Hello')
|
||||
assert utils.aiohttp_serialize_response(response) == {
|
||||
'status': 201,
|
||||
'body': 'Hello',
|
||||
'headers': {'Content-Type': 'text/plain; charset=utf-8'},
|
||||
}
|
||||
|
||||
|
||||
def test_serialize_json():
|
||||
"""Test serializing a JSON response."""
|
||||
response = web.json_response({"how": "what"})
|
||||
assert utils.aiohttp_serialize_response(response) == {
|
||||
'status': 200,
|
||||
'body': '{"how": "what"}',
|
||||
'headers': {'Content-Type': 'application/json; charset=utf-8'},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue