This commit is contained in:
Paulus Schoutsen 2019-07-31 12:25:30 -07:00
parent da05dfe708
commit 4de97abc3a
2676 changed files with 163166 additions and 140084 deletions

View file

@ -1,6 +1,5 @@
"""Basic checks for HomeKitSwitch."""
from tests.components.homekit_controller.common import (
setup_test_component)
from tests.components.homekit_controller.common import setup_test_component
async def test_switch_change_outlet_state(hass, utcnow):
@ -9,15 +8,15 @@ async def test_switch_change_outlet_state(hass, utcnow):
helper = await setup_test_component(hass, [OutletService()])
await hass.services.async_call('switch', 'turn_on', {
'entity_id': 'switch.testdevice',
}, blocking=True)
assert helper.characteristics[('outlet', 'on')].value == 1
await hass.services.async_call(
"switch", "turn_on", {"entity_id": "switch.testdevice"}, blocking=True
)
assert helper.characteristics[("outlet", "on")].value == 1
await hass.services.async_call('switch', 'turn_off', {
'entity_id': 'switch.testdevice',
}, blocking=True)
assert helper.characteristics[('outlet', 'on')].value == 0
await hass.services.async_call(
"switch", "turn_off", {"entity_id": "switch.testdevice"}, blocking=True
)
assert helper.characteristics[("outlet", "on")].value == 0
async def test_switch_read_outlet_state(hass, utcnow):
@ -28,22 +27,22 @@ async def test_switch_read_outlet_state(hass, utcnow):
# Initial state is that the switch is off and the outlet isn't in use
switch_1 = await helper.poll_and_get_state()
assert switch_1.state == 'off'
assert switch_1.attributes['outlet_in_use'] is False
assert switch_1.state == "off"
assert switch_1.attributes["outlet_in_use"] is False
# Simulate that someone switched on the device in the real world not via HA
helper.characteristics[('outlet', 'on')].set_value(True)
helper.characteristics[("outlet", "on")].set_value(True)
switch_1 = await helper.poll_and_get_state()
assert switch_1.state == 'on'
assert switch_1.attributes['outlet_in_use'] is False
assert switch_1.state == "on"
assert switch_1.attributes["outlet_in_use"] is False
# Simulate that device switched off in the real world not via HA
helper.characteristics[('outlet', 'on')].set_value(False)
helper.characteristics[("outlet", "on")].set_value(False)
switch_1 = await helper.poll_and_get_state()
assert switch_1.state == 'off'
assert switch_1.state == "off"
# Simulate that someone plugged something into the device
helper.characteristics[('outlet', 'outlet-in-use')].value = True
helper.characteristics[("outlet", "outlet-in-use")].value = True
switch_1 = await helper.poll_and_get_state()
assert switch_1.state == 'off'
assert switch_1.attributes['outlet_in_use'] is True
assert switch_1.state == "off"
assert switch_1.attributes["outlet_in_use"] is True