Use DeviceClass Enums in homekit_controller tests (#62219)

This commit is contained in:
Dave T 2021-12-19 05:56:59 +00:00 committed by GitHub
parent a4c101b021
commit afdc570d70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 24 deletions

View File

@ -2,14 +2,7 @@
from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import ServicesTypes
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_GAS,
DEVICE_CLASS_MOISTURE,
DEVICE_CLASS_MOTION,
DEVICE_CLASS_OCCUPANCY,
DEVICE_CLASS_OPENING,
DEVICE_CLASS_SMOKE,
)
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
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()
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):
@ -64,7 +57,7 @@ async def test_contact_sensor_read_state(hass, utcnow):
state = await helper.poll_and_get_state()
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):
@ -87,7 +80,7 @@ async def test_smoke_sensor_read_state(hass, utcnow):
state = await helper.poll_and_get_state()
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):
@ -110,7 +103,7 @@ async def test_carbon_monoxide_sensor_read_state(hass, utcnow):
state = await helper.poll_and_get_state()
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):
@ -133,7 +126,7 @@ async def test_occupancy_sensor_read_state(hass, utcnow):
state = await helper.poll_and_get_state()
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):
@ -156,4 +149,4 @@ async def test_leak_sensor_read_state(hass, utcnow):
state = await helper.poll_and_get_state()
assert state.state == "on"
assert state.attributes["device_class"] == DEVICE_CLASS_MOISTURE
assert state.attributes["device_class"] == BinarySensorDeviceClass.MOISTURE

View File

@ -3,12 +3,7 @@ from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import ServicesTypes
from aiohomekit.protocol.statuscodes import HapStatusCode
from homeassistant.const import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_ILLUMINANCE,
DEVICE_CLASS_TEMPERATURE,
)
from homeassistant.components.sensor import SensorDeviceClass
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()
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):
@ -111,7 +106,7 @@ async def test_humidity_sensor_read_state(hass, utcnow):
state = await helper.poll_and_get_state()
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):
@ -128,7 +123,7 @@ async def test_light_level_sensor_read_state(hass, utcnow):
state = await helper.poll_and_get_state()
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):
@ -162,7 +157,7 @@ async def test_battery_level_sensor(hass, utcnow):
assert state.state == "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):