mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Homekit test cleanup (#14416)
This commit is contained in:
parent
b371bf700f
commit
990f476ac9
@ -56,7 +56,11 @@ async def test_debounce(hass):
|
||||
|
||||
async def test_home_accessory(hass):
|
||||
"""Test HomeAccessory class."""
|
||||
acc = HomeAccessory(hass, 'Home Accessory', 'homekit.accessory', 2, None)
|
||||
entity_id = 'homekit.accessory'
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
acc = HomeAccessory(hass, 'Home Accessory', entity_id, 2, None)
|
||||
assert acc.hass == hass
|
||||
assert acc.display_name == 'Home Accessory'
|
||||
assert acc.aid == 2
|
||||
@ -76,7 +80,11 @@ async def test_home_accessory(hass):
|
||||
hass.states.async_set('homekit.accessory', 'off')
|
||||
await hass.async_block_till_done()
|
||||
|
||||
acc = HomeAccessory('hass', 'test_name', 'test_model.demo', 2, None)
|
||||
entity_id = 'test_model.demo'
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
acc = HomeAccessory('hass', 'test_name', entity_id, 2, None)
|
||||
assert acc.display_name == 'test_name'
|
||||
assert acc.aid == 2
|
||||
assert len(acc.services) == 1
|
||||
|
@ -1,5 +1,4 @@
|
||||
"""Package to test the get_accessory method."""
|
||||
import logging
|
||||
from unittest.mock import patch, Mock
|
||||
|
||||
import pytest
|
||||
@ -13,8 +12,6 @@ from homeassistant.const import (
|
||||
ATTR_CODE, ATTR_DEVICE_CLASS, ATTR_SUPPORTED_FEATURES,
|
||||
ATTR_UNIT_OF_MEASUREMENT, TEMP_CELSIUS, TEMP_FAHRENHEIT, CONF_NAME)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def test_not_supported(caplog):
|
||||
"""Test if none is returned if entity isn't supported."""
|
||||
|
@ -32,6 +32,8 @@ async def test_garage_door_open_close(hass, cls):
|
||||
"""Test if accessory and HA are updated accordingly."""
|
||||
entity_id = 'cover.garage_door'
|
||||
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
acc = cls.garage(hass, 'Garage Door', entity_id, 2, None)
|
||||
await hass.async_add_job(acc.run)
|
||||
|
||||
@ -87,6 +89,8 @@ async def test_window_set_cover_position(hass, cls):
|
||||
"""Test if accessory and HA are updated accordingly."""
|
||||
entity_id = 'cover.window'
|
||||
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
acc = cls.window(hass, 'Cover', entity_id, 2, None)
|
||||
await hass.async_add_job(acc.run)
|
||||
|
||||
|
@ -11,6 +11,8 @@ async def test_lock_unlock(hass):
|
||||
"""Test if accessory and HA are updated accordingly."""
|
||||
entity_id = 'lock.kitchen_door'
|
||||
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
acc = Lock(hass, 'Lock', entity_id, 2, None)
|
||||
await hass.async_add_job(acc.run)
|
||||
|
||||
|
@ -18,6 +18,8 @@ async def test_switch_set_state(hass):
|
||||
config = {ATTR_CODE: code}
|
||||
entity_id = 'alarm_control_panel.test'
|
||||
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
acc = SecuritySystem(hass, 'SecuritySystem', entity_id, 2, config)
|
||||
await hass.async_add_job(acc.run)
|
||||
|
||||
@ -97,6 +99,8 @@ async def test_no_alarm_code(hass, config):
|
||||
"""Test accessory if security_system doesn't require a alarm_code."""
|
||||
entity_id = 'alarm_control_panel.test'
|
||||
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
acc = SecuritySystem(hass, 'SecuritySystem', entity_id, 2, config)
|
||||
|
||||
# Set from HomeKit
|
||||
|
@ -12,6 +12,8 @@ async def test_temperature(hass):
|
||||
"""Test if accessory is updated after state change."""
|
||||
entity_id = 'sensor.temperature'
|
||||
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
acc = TemperatureSensor(hass, 'Temperature', entity_id, 2, None)
|
||||
await hass.async_add_job(acc.run)
|
||||
|
||||
@ -42,6 +44,8 @@ async def test_humidity(hass):
|
||||
"""Test if accessory is updated after state change."""
|
||||
entity_id = 'sensor.humidity'
|
||||
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
acc = HumiditySensor(hass, 'Humidity', entity_id, 2, None)
|
||||
await hass.async_add_job(acc.run)
|
||||
|
||||
@ -63,6 +67,8 @@ async def test_air_quality(hass):
|
||||
"""Test if accessory is updated after state change."""
|
||||
entity_id = 'sensor.air_quality'
|
||||
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
acc = AirQualitySensor(hass, 'Air Quality', entity_id, 2, None)
|
||||
await hass.async_add_job(acc.run)
|
||||
|
||||
@ -92,6 +98,8 @@ async def test_co2(hass):
|
||||
"""Test if accessory is updated after state change."""
|
||||
entity_id = 'sensor.co2'
|
||||
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
acc = CarbonDioxideSensor(hass, 'CO2', entity_id, 2, None)
|
||||
await hass.async_add_job(acc.run)
|
||||
|
||||
@ -125,6 +133,8 @@ async def test_light(hass):
|
||||
"""Test if accessory is updated after state change."""
|
||||
entity_id = 'sensor.light'
|
||||
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
acc = LightSensor(hass, 'Light', entity_id, 2, None)
|
||||
await hass.async_add_job(acc.run)
|
||||
|
||||
|
@ -14,6 +14,8 @@ async def test_switch_set_state(hass, entity_id):
|
||||
"""Test if accessory and HA are updated accordingly."""
|
||||
domain = split_entity_id(entity_id)[0]
|
||||
|
||||
hass.states.async_set(entity_id, None)
|
||||
await hass.async_block_till_done()
|
||||
acc = Switch(hass, 'Switch', entity_id, 2, None)
|
||||
await hass.async_add_job(acc.run)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user