Use DeviceClass Enums in gogogate2 tests (#62137)

This commit is contained in:
Dave T 2021-12-17 07:45:39 +00:00 committed by GitHub
parent 28e373297f
commit 4418b0a43e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View file

@ -16,11 +16,10 @@ from ismartgate.common import (
)
from homeassistant.components.cover import (
DEVICE_CLASS_GARAGE,
DEVICE_CLASS_GATE,
DOMAIN as COVER_DOMAIN,
SUPPORT_CLOSE,
SUPPORT_OPEN,
CoverDeviceClass,
)
from homeassistant.components.gogogate2.const import (
DEVICE_TYPE_GOGOGATE2,
@ -282,11 +281,11 @@ async def test_availability(ismartgateapi_mock, hass: HomeAssistant) -> None:
assert hass.states.get("cover.door1")
assert (
hass.states.get("cover.door1").attributes[ATTR_DEVICE_CLASS]
== DEVICE_CLASS_GARAGE
== CoverDeviceClass.GARAGE
)
assert (
hass.states.get("cover.door2").attributes[ATTR_DEVICE_CLASS]
== DEVICE_CLASS_GATE
== CoverDeviceClass.GATE
)
api.async_info.side_effect = Exception("Error")

View file

@ -17,6 +17,7 @@ from ismartgate.common import (
)
from homeassistant.components.gogogate2.const import DEVICE_TYPE_ISMARTGATE, DOMAIN
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import (
ATTR_DEVICE_CLASS,
@ -25,8 +26,6 @@ from homeassistant.const import (
CONF_IP_ADDRESS,
CONF_PASSWORD,
CONF_USERNAME,
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_TEMPERATURE,
STATE_UNAVAILABLE,
STATE_UNKNOWN,
)
@ -296,11 +295,11 @@ async def test_availability(ismartgateapi_mock, hass: HomeAssistant) -> None:
assert hass.states.get("sensor.door3_temperature") is None
assert (
hass.states.get("sensor.door1_battery").attributes[ATTR_DEVICE_CLASS]
== DEVICE_CLASS_BATTERY
== SensorDeviceClass.BATTERY
)
assert (
hass.states.get("sensor.door1_temperature").attributes[ATTR_DEVICE_CLASS]
== DEVICE_CLASS_TEMPERATURE
== SensorDeviceClass.TEMPERATURE
)
assert (
hass.states.get("sensor.door1_temperature").attributes[ATTR_UNIT_OF_MEASUREMENT]