1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Replace the usage of unit constants by enumerations in Tests [m-n] (#85935)

* replace unit conts by enums m-n

* fix mqtt
This commit is contained in:
Michael
2023-01-15 15:45:00 +01:00
committed by GitHub
parent e35ab75c0b
commit 104f74054b
16 changed files with 141 additions and 113 deletions

View File

@@ -15,10 +15,9 @@ from homeassistant.const import (
ATTR_DEVICE_CLASS,
ATTR_ICON,
ATTR_UNIT_OF_MEASUREMENT,
ENERGY_KILO_WATT_HOUR,
POWER_WATT,
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
UnitOfEnergy,
UnitOfPower,
UnitOfTemperature,
)
from homeassistant.core import HomeAssistant
from homeassistant.util.unit_system import (
@@ -69,7 +68,7 @@ async def test_power_sensor(
assert state
assert state.state == "1200"
assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.POWER
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == POWER_WATT
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfPower.WATT
assert state.attributes[ATTR_STATE_CLASS] is SensorStateClass.MEASUREMENT
@@ -86,7 +85,7 @@ async def test_energy_sensor(
assert state
assert state.state == "18000"
assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.ENERGY
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == ENERGY_KILO_WATT_HOUR
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfEnergy.KILO_WATT_HOUR
assert state.attributes[ATTR_STATE_CLASS] is SensorStateClass.TOTAL_INCREASING
@@ -125,7 +124,10 @@ async def test_distance_sensor(
@pytest.mark.parametrize(
"unit_system, unit",
[(METRIC_SYSTEM, TEMP_CELSIUS), (US_CUSTOMARY_SYSTEM, TEMP_FAHRENHEIT)],
[
(METRIC_SYSTEM, UnitOfTemperature.CELSIUS),
(US_CUSTOMARY_SYSTEM, UnitOfTemperature.FAHRENHEIT),
],
)
async def test_temperature_sensor(
hass: HomeAssistant,