Add rest encoding test (#90404)

* Add rest encoding test

* docstring
This commit is contained in:
epenet 2023-03-28 16:29:24 +02:00 committed by GitHub
parent b4775ed2eb
commit 02e2e4d039
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,6 +106,31 @@ async def test_setup_minimum(hass: HomeAssistant) -> None:
assert len(hass.states.async_all("sensor")) == 1
@respx.mock
async def test_setup_encoding(hass: HomeAssistant) -> None:
"""Test setup with non-utf8 encoding."""
respx.get("http://localhost").respond(
status_code=HTTPStatus.OK,
stream=httpx.ByteStream("tack själv".encode(encoding="iso-8859-1")),
)
assert await async_setup_component(
hass,
DOMAIN,
{
"sensor": {
"name": "mysensor",
"encoding": "iso-8859-1",
"platform": "rest",
"resource": "http://localhost",
"method": "GET",
}
},
)
await hass.async_block_till_done()
assert len(hass.states.async_all("sensor")) == 1
assert hass.states.get("sensor.mysensor").state == "tack själv"
@respx.mock
async def test_manual_update(hass: HomeAssistant) -> None:
"""Test setup with minimum configuration."""