Replace the usage of unit constants by enumerations in Tests [s-u] (#85937)

This commit is contained in:
Michael 2023-01-16 09:00:27 +01:00 committed by GitHub
parent 0b02abf708
commit 9709391b52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 254 additions and 221 deletions

View file

@ -7,7 +7,7 @@ from unittest.mock import patch
import pytest
from homeassistant.components.spaceapi import DOMAIN, SPACEAPI_VERSION, URL_API_SPACEAPI
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, PERCENTAGE, TEMP_CELSIUS
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, PERCENTAGE, UnitOfTemperature
from homeassistant.setup import async_setup_component
from tests.common import mock_coro
@ -62,8 +62,18 @@ CONFIG = {
SENSOR_OUTPUT = {
"temperature": [
{"location": "Home", "name": "temp1", "unit": TEMP_CELSIUS, "value": "25"},
{"location": "Home", "name": "temp2", "unit": TEMP_CELSIUS, "value": "23"},
{
"location": "Home",
"name": "temp1",
"unit": UnitOfTemperature.CELSIUS,
"value": "25",
},
{
"location": "Home",
"name": "temp2",
"unit": UnitOfTemperature.CELSIUS,
"value": "23",
},
],
"humidity": [
{"location": "Home", "name": "hum1", "unit": PERCENTAGE, "value": "88"}
@ -78,10 +88,14 @@ def mock_client(hass, hass_client):
hass.loop.run_until_complete(async_setup_component(hass, "spaceapi", CONFIG))
hass.states.async_set(
"test.temp1", 25, attributes={ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS}
"test.temp1",
25,
attributes={ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS},
)
hass.states.async_set(
"test.temp2", 23, attributes={ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS}
"test.temp2",
23,
attributes={ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS},
)
hass.states.async_set(
"test.hum1", 88, attributes={ATTR_UNIT_OF_MEASUREMENT: PERCENTAGE}