Use enums in utility_meter tests (#62190)
* Use enums in utility_meter tests * uno maspull/62215/head
parent
26d8d82061
commit
8683a30380
|
@ -5,8 +5,8 @@ from unittest.mock import patch
|
|||
|
||||
from homeassistant.components.sensor import (
|
||||
ATTR_STATE_CLASS,
|
||||
STATE_CLASS_TOTAL,
|
||||
STATE_CLASS_TOTAL_INCREASING,
|
||||
SensorDeviceClass,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.components.utility_meter.const import (
|
||||
ATTR_TARIFF,
|
||||
|
@ -269,15 +269,15 @@ async def test_device_class(hass):
|
|||
state = hass.states.get("sensor.energy_meter")
|
||||
assert state is not None
|
||||
assert state.state == "0"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == "energy"
|
||||
assert state.attributes.get(ATTR_STATE_CLASS) == STATE_CLASS_TOTAL
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) is SensorDeviceClass.ENERGY.value
|
||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == ENERGY_KILO_WATT_HOUR
|
||||
|
||||
state = hass.states.get("sensor.gas_meter")
|
||||
assert state is not None
|
||||
assert state.state == "0"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) is None
|
||||
assert state.attributes.get(ATTR_STATE_CLASS) == STATE_CLASS_TOTAL_INCREASING
|
||||
assert state.attributes.get(ATTR_STATE_CLASS) is SensorStateClass.TOTAL_INCREASING
|
||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "some_archaic_unit"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue