mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Use DeviceClass Enums in homekit_controller tests (#62219)
This commit is contained in:
parent
a4c101b021
commit
afdc570d70
@ -2,14 +2,7 @@
|
|||||||
from aiohomekit.model.characteristics import CharacteristicsTypes
|
from aiohomekit.model.characteristics import CharacteristicsTypes
|
||||||
from aiohomekit.model.services import ServicesTypes
|
from aiohomekit.model.services import ServicesTypes
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
||||||
DEVICE_CLASS_GAS,
|
|
||||||
DEVICE_CLASS_MOISTURE,
|
|
||||||
DEVICE_CLASS_MOTION,
|
|
||||||
DEVICE_CLASS_OCCUPANCY,
|
|
||||||
DEVICE_CLASS_OPENING,
|
|
||||||
DEVICE_CLASS_SMOKE,
|
|
||||||
)
|
|
||||||
|
|
||||||
from tests.components.homekit_controller.common import setup_test_component
|
from tests.components.homekit_controller.common import setup_test_component
|
||||||
|
|
||||||
@ -41,7 +34,7 @@ async def test_motion_sensor_read_state(hass, utcnow):
|
|||||||
state = await helper.poll_and_get_state()
|
state = await helper.poll_and_get_state()
|
||||||
assert state.state == "on"
|
assert state.state == "on"
|
||||||
|
|
||||||
assert state.attributes["device_class"] == DEVICE_CLASS_MOTION
|
assert state.attributes["device_class"] == BinarySensorDeviceClass.MOTION
|
||||||
|
|
||||||
|
|
||||||
def create_contact_sensor_service(accessory):
|
def create_contact_sensor_service(accessory):
|
||||||
@ -64,7 +57,7 @@ async def test_contact_sensor_read_state(hass, utcnow):
|
|||||||
state = await helper.poll_and_get_state()
|
state = await helper.poll_and_get_state()
|
||||||
assert state.state == "on"
|
assert state.state == "on"
|
||||||
|
|
||||||
assert state.attributes["device_class"] == DEVICE_CLASS_OPENING
|
assert state.attributes["device_class"] == BinarySensorDeviceClass.OPENING
|
||||||
|
|
||||||
|
|
||||||
def create_smoke_sensor_service(accessory):
|
def create_smoke_sensor_service(accessory):
|
||||||
@ -87,7 +80,7 @@ async def test_smoke_sensor_read_state(hass, utcnow):
|
|||||||
state = await helper.poll_and_get_state()
|
state = await helper.poll_and_get_state()
|
||||||
assert state.state == "on"
|
assert state.state == "on"
|
||||||
|
|
||||||
assert state.attributes["device_class"] == DEVICE_CLASS_SMOKE
|
assert state.attributes["device_class"] == BinarySensorDeviceClass.SMOKE
|
||||||
|
|
||||||
|
|
||||||
def create_carbon_monoxide_sensor_service(accessory):
|
def create_carbon_monoxide_sensor_service(accessory):
|
||||||
@ -110,7 +103,7 @@ async def test_carbon_monoxide_sensor_read_state(hass, utcnow):
|
|||||||
state = await helper.poll_and_get_state()
|
state = await helper.poll_and_get_state()
|
||||||
assert state.state == "on"
|
assert state.state == "on"
|
||||||
|
|
||||||
assert state.attributes["device_class"] == DEVICE_CLASS_GAS
|
assert state.attributes["device_class"] == BinarySensorDeviceClass.GAS
|
||||||
|
|
||||||
|
|
||||||
def create_occupancy_sensor_service(accessory):
|
def create_occupancy_sensor_service(accessory):
|
||||||
@ -133,7 +126,7 @@ async def test_occupancy_sensor_read_state(hass, utcnow):
|
|||||||
state = await helper.poll_and_get_state()
|
state = await helper.poll_and_get_state()
|
||||||
assert state.state == "on"
|
assert state.state == "on"
|
||||||
|
|
||||||
assert state.attributes["device_class"] == DEVICE_CLASS_OCCUPANCY
|
assert state.attributes["device_class"] == BinarySensorDeviceClass.OCCUPANCY
|
||||||
|
|
||||||
|
|
||||||
def create_leak_sensor_service(accessory):
|
def create_leak_sensor_service(accessory):
|
||||||
@ -156,4 +149,4 @@ async def test_leak_sensor_read_state(hass, utcnow):
|
|||||||
state = await helper.poll_and_get_state()
|
state = await helper.poll_and_get_state()
|
||||||
assert state.state == "on"
|
assert state.state == "on"
|
||||||
|
|
||||||
assert state.attributes["device_class"] == DEVICE_CLASS_MOISTURE
|
assert state.attributes["device_class"] == BinarySensorDeviceClass.MOISTURE
|
||||||
|
@ -3,12 +3,7 @@ from aiohomekit.model.characteristics import CharacteristicsTypes
|
|||||||
from aiohomekit.model.services import ServicesTypes
|
from aiohomekit.model.services import ServicesTypes
|
||||||
from aiohomekit.protocol.statuscodes import HapStatusCode
|
from aiohomekit.protocol.statuscodes import HapStatusCode
|
||||||
|
|
||||||
from homeassistant.const import (
|
from homeassistant.components.sensor import SensorDeviceClass
|
||||||
DEVICE_CLASS_BATTERY,
|
|
||||||
DEVICE_CLASS_HUMIDITY,
|
|
||||||
DEVICE_CLASS_ILLUMINANCE,
|
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
)
|
|
||||||
|
|
||||||
from tests.components.homekit_controller.common import Helper, setup_test_component
|
from tests.components.homekit_controller.common import Helper, setup_test_component
|
||||||
|
|
||||||
@ -84,7 +79,7 @@ async def test_temperature_sensor_read_state(hass, utcnow):
|
|||||||
state = await helper.poll_and_get_state()
|
state = await helper.poll_and_get_state()
|
||||||
assert state.state == "20"
|
assert state.state == "20"
|
||||||
|
|
||||||
assert state.attributes["device_class"] == DEVICE_CLASS_TEMPERATURE
|
assert state.attributes["device_class"] == SensorDeviceClass.TEMPERATURE
|
||||||
|
|
||||||
|
|
||||||
async def test_temperature_sensor_not_added_twice(hass, utcnow):
|
async def test_temperature_sensor_not_added_twice(hass, utcnow):
|
||||||
@ -111,7 +106,7 @@ async def test_humidity_sensor_read_state(hass, utcnow):
|
|||||||
state = await helper.poll_and_get_state()
|
state = await helper.poll_and_get_state()
|
||||||
assert state.state == "20"
|
assert state.state == "20"
|
||||||
|
|
||||||
assert state.attributes["device_class"] == DEVICE_CLASS_HUMIDITY
|
assert state.attributes["device_class"] == SensorDeviceClass.HUMIDITY
|
||||||
|
|
||||||
|
|
||||||
async def test_light_level_sensor_read_state(hass, utcnow):
|
async def test_light_level_sensor_read_state(hass, utcnow):
|
||||||
@ -128,7 +123,7 @@ async def test_light_level_sensor_read_state(hass, utcnow):
|
|||||||
state = await helper.poll_and_get_state()
|
state = await helper.poll_and_get_state()
|
||||||
assert state.state == "20"
|
assert state.state == "20"
|
||||||
|
|
||||||
assert state.attributes["device_class"] == DEVICE_CLASS_ILLUMINANCE
|
assert state.attributes["device_class"] == SensorDeviceClass.ILLUMINANCE
|
||||||
|
|
||||||
|
|
||||||
async def test_carbon_dioxide_level_sensor_read_state(hass, utcnow):
|
async def test_carbon_dioxide_level_sensor_read_state(hass, utcnow):
|
||||||
@ -162,7 +157,7 @@ async def test_battery_level_sensor(hass, utcnow):
|
|||||||
assert state.state == "20"
|
assert state.state == "20"
|
||||||
assert state.attributes["icon"] == "mdi:battery-20"
|
assert state.attributes["icon"] == "mdi:battery-20"
|
||||||
|
|
||||||
assert state.attributes["device_class"] == DEVICE_CLASS_BATTERY
|
assert state.attributes["device_class"] == SensorDeviceClass.BATTERY
|
||||||
|
|
||||||
|
|
||||||
async def test_battery_charging(hass, utcnow):
|
async def test_battery_charging(hass, utcnow):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user