Use DeviceClass Enums in blebox tests (#62109)

This commit is contained in:
Dave T 2021-12-17 07:28:31 +00:00 committed by GitHub
parent ccf8dcd14a
commit f55668ff40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 12 deletions

View file

@ -8,9 +8,6 @@ import pytest
from homeassistant.components.cover import (
ATTR_CURRENT_POSITION,
ATTR_POSITION,
DEVICE_CLASS_DOOR,
DEVICE_CLASS_GATE,
DEVICE_CLASS_SHUTTER,
STATE_CLOSED,
STATE_CLOSING,
STATE_OPEN,
@ -19,6 +16,7 @@ from homeassistant.components.cover import (
SUPPORT_OPEN,
SUPPORT_SET_POSITION,
SUPPORT_STOP,
CoverDeviceClass,
)
from homeassistant.const import (
ATTR_DEVICE_CLASS,
@ -106,7 +104,7 @@ async def test_init_gatecontroller(gatecontroller, hass, config):
state = hass.states.get(entity_id)
assert state.name == "gateController-position"
assert state.attributes[ATTR_DEVICE_CLASS] == DEVICE_CLASS_GATE
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.GATE
supported_features = state.attributes[ATTR_SUPPORTED_FEATURES]
assert supported_features & SUPPORT_OPEN
@ -136,7 +134,7 @@ async def test_init_shutterbox(shutterbox, hass, config):
state = hass.states.get(entity_id)
assert state.name == "shutterBox-position"
assert entry.original_device_class == DEVICE_CLASS_SHUTTER
assert entry.original_device_class == CoverDeviceClass.SHUTTER
supported_features = state.attributes[ATTR_SUPPORTED_FEATURES]
assert supported_features & SUPPORT_OPEN
@ -166,7 +164,7 @@ async def test_init_gatebox(gatebox, hass, config):
state = hass.states.get(entity_id)
assert state.name == "gateBox-position"
assert state.attributes[ATTR_DEVICE_CLASS] == DEVICE_CLASS_DOOR
assert state.attributes[ATTR_DEVICE_CLASS] == CoverDeviceClass.DOOR
supported_features = state.attributes[ATTR_SUPPORTED_FEATURES]
assert supported_features & SUPPORT_OPEN

View file

@ -5,10 +5,10 @@ from unittest.mock import AsyncMock, PropertyMock
import blebox_uniapi
import pytest
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.const import (
ATTR_DEVICE_CLASS,
ATTR_UNIT_OF_MEASUREMENT,
DEVICE_CLASS_TEMPERATURE,
STATE_UNKNOWN,
TEMP_CELSIUS,
)
@ -45,7 +45,7 @@ async def test_init(tempsensor, hass, config):
state = hass.states.get(entity_id)
assert state.name == "tempSensor-0.temperature"
assert state.attributes[ATTR_DEVICE_CLASS] == DEVICE_CLASS_TEMPERATURE
assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.TEMPERATURE
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == TEMP_CELSIUS
assert state.state == STATE_UNKNOWN

View file

@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, PropertyMock
import blebox_uniapi
import pytest
from homeassistant.components.switch import DEVICE_CLASS_SWITCH
from homeassistant.components.switch import SwitchDeviceClass
from homeassistant.const import (
ATTR_DEVICE_CLASS,
SERVICE_TURN_OFF,
@ -54,7 +54,7 @@ async def test_switchbox_init(switchbox, hass, config):
state = hass.states.get(entity_id)
assert state.name == "switchBox-0.relay"
assert state.attributes[ATTR_DEVICE_CLASS] == DEVICE_CLASS_SWITCH
assert state.attributes[ATTR_DEVICE_CLASS] == SwitchDeviceClass.SWITCH
assert state.state == STATE_OFF
@ -201,7 +201,7 @@ async def test_switchbox_d_init(switchbox_d, hass, config):
state = hass.states.get(entity_ids[0])
assert state.name == "switchBoxD-0.relay"
assert state.attributes[ATTR_DEVICE_CLASS] == DEVICE_CLASS_SWITCH
assert state.attributes[ATTR_DEVICE_CLASS] == SwitchDeviceClass.SWITCH
assert state.state == STATE_OFF # NOTE: should instead be STATE_UNKNOWN?
device_registry = dr.async_get(hass)
@ -218,7 +218,7 @@ async def test_switchbox_d_init(switchbox_d, hass, config):
state = hass.states.get(entity_ids[1])
assert state.name == "switchBoxD-1.relay"
assert state.attributes[ATTR_DEVICE_CLASS] == DEVICE_CLASS_SWITCH
assert state.attributes[ATTR_DEVICE_CLASS] == SwitchDeviceClass.SWITCH
assert state.state == STATE_OFF # NOTE: should instead be STATE_UNKNOWN?
device_registry = dr.async_get(hass)