Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tests/components/homekit/test_accessories.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ def demo_func(*args):

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
Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions tests/components/homekit/test_get_accessories.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Package to test the get_accessory method."""
import logging
from unittest.mock import patch, Mock

import pytest
Expand All @@ -13,8 +12,6 @@
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."""
Expand Down
4 changes: 4 additions & 0 deletions tests/components/homekit/test_type_covers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions tests/components/homekit/test_type_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions tests/components/homekit/test_type_security_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/components/homekit/test_type_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions tests/components/homekit/test_type_switches.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down