Use enums in utility_meter tests (#62190)

* Use enums in utility_meter tests

* uno mas
pull/62215/head
Robert Hillis 2021-12-17 10:22:46 -05:00 committed by GitHub
parent 26d8d82061
commit 8683a30380
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -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"