mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Use DeviceClass Enums in blebox tests (#62109)
This commit is contained in:
parent
ccf8dcd14a
commit
f55668ff40
@ -8,9 +8,6 @@ import pytest
|
|||||||
from homeassistant.components.cover import (
|
from homeassistant.components.cover import (
|
||||||
ATTR_CURRENT_POSITION,
|
ATTR_CURRENT_POSITION,
|
||||||
ATTR_POSITION,
|
ATTR_POSITION,
|
||||||
DEVICE_CLASS_DOOR,
|
|
||||||
DEVICE_CLASS_GATE,
|
|
||||||
DEVICE_CLASS_SHUTTER,
|
|
||||||
STATE_CLOSED,
|
STATE_CLOSED,
|
||||||
STATE_CLOSING,
|
STATE_CLOSING,
|
||||||
STATE_OPEN,
|
STATE_OPEN,
|
||||||
@ -19,6 +16,7 @@ from homeassistant.components.cover import (
|
|||||||
SUPPORT_OPEN,
|
SUPPORT_OPEN,
|
||||||
SUPPORT_SET_POSITION,
|
SUPPORT_SET_POSITION,
|
||||||
SUPPORT_STOP,
|
SUPPORT_STOP,
|
||||||
|
CoverDeviceClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DEVICE_CLASS,
|
ATTR_DEVICE_CLASS,
|
||||||
@ -106,7 +104,7 @@ async def test_init_gatecontroller(gatecontroller, hass, config):
|
|||||||
|
|
||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state.name == "gateController-position"
|
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]
|
supported_features = state.attributes[ATTR_SUPPORTED_FEATURES]
|
||||||
assert supported_features & SUPPORT_OPEN
|
assert supported_features & SUPPORT_OPEN
|
||||||
@ -136,7 +134,7 @@ async def test_init_shutterbox(shutterbox, hass, config):
|
|||||||
|
|
||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state.name == "shutterBox-position"
|
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]
|
supported_features = state.attributes[ATTR_SUPPORTED_FEATURES]
|
||||||
assert supported_features & SUPPORT_OPEN
|
assert supported_features & SUPPORT_OPEN
|
||||||
@ -166,7 +164,7 @@ async def test_init_gatebox(gatebox, hass, config):
|
|||||||
|
|
||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state.name == "gateBox-position"
|
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]
|
supported_features = state.attributes[ATTR_SUPPORTED_FEATURES]
|
||||||
assert supported_features & SUPPORT_OPEN
|
assert supported_features & SUPPORT_OPEN
|
||||||
|
@ -5,10 +5,10 @@ from unittest.mock import AsyncMock, PropertyMock
|
|||||||
import blebox_uniapi
|
import blebox_uniapi
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import SensorDeviceClass
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DEVICE_CLASS,
|
ATTR_DEVICE_CLASS,
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
@ -45,7 +45,7 @@ async def test_init(tempsensor, hass, config):
|
|||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state.name == "tempSensor-0.temperature"
|
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.attributes[ATTR_UNIT_OF_MEASUREMENT] == TEMP_CELSIUS
|
||||||
assert state.state == STATE_UNKNOWN
|
assert state.state == STATE_UNKNOWN
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, PropertyMock
|
|||||||
import blebox_uniapi
|
import blebox_uniapi
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.switch import DEVICE_CLASS_SWITCH
|
from homeassistant.components.switch import SwitchDeviceClass
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DEVICE_CLASS,
|
ATTR_DEVICE_CLASS,
|
||||||
SERVICE_TURN_OFF,
|
SERVICE_TURN_OFF,
|
||||||
@ -54,7 +54,7 @@ async def test_switchbox_init(switchbox, hass, config):
|
|||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state.name == "switchBox-0.relay"
|
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
|
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])
|
state = hass.states.get(entity_ids[0])
|
||||||
assert state.name == "switchBoxD-0.relay"
|
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?
|
assert state.state == STATE_OFF # NOTE: should instead be STATE_UNKNOWN?
|
||||||
|
|
||||||
device_registry = dr.async_get(hass)
|
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])
|
state = hass.states.get(entity_ids[1])
|
||||||
assert state.name == "switchBoxD-1.relay"
|
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?
|
assert state.state == STATE_OFF # NOTE: should instead be STATE_UNKNOWN?
|
||||||
|
|
||||||
device_registry = dr.async_get(hass)
|
device_registry = dr.async_get(hass)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user