mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Set placeholders in homekit config flow title (#23311)
This commit is contained in:
parent
ee88433fb1
commit
baeb3cddc6
@ -130,6 +130,11 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow):
|
|||||||
status_flags = int(properties['sf'])
|
status_flags = int(properties['sf'])
|
||||||
paired = not status_flags & 0x01
|
paired = not status_flags & 0x01
|
||||||
|
|
||||||
|
# pylint: disable=unsupported-assignment-operation
|
||||||
|
self.context['title_placeholders'] = {
|
||||||
|
'name': discovery_info['name'],
|
||||||
|
}
|
||||||
|
|
||||||
# The configuration number increases every time the characteristic map
|
# The configuration number increases every time the characteristic map
|
||||||
# needs updating. Some devices use a slightly off-spec name so handle
|
# needs updating. Some devices use a slightly off-spec name so handle
|
||||||
# both cases.
|
# both cases.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
"title": "HomeKit Accessory",
|
"title": "HomeKit Accessory",
|
||||||
|
"flow_title": "HomeKit Accessory: {name}",
|
||||||
"step": {
|
"step": {
|
||||||
"user": {
|
"user": {
|
||||||
"title": "Pair with HomeKit Accessory",
|
"title": "Pair with HomeKit Accessory",
|
||||||
|
@ -12,9 +12,17 @@ from tests.components.homekit_controller.common import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _setup_flow_handler(hass):
|
||||||
|
flow = config_flow.HomekitControllerFlowHandler()
|
||||||
|
flow.hass = hass
|
||||||
|
flow.context = {}
|
||||||
|
return flow
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_works(hass):
|
async def test_discovery_works(hass):
|
||||||
"""Test a device being discovered."""
|
"""Test a device being discovered."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -25,12 +33,12 @@ async def test_discovery_works(hass):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await flow.async_step_discovery(discovery_info)
|
result = await flow.async_step_discovery(discovery_info)
|
||||||
assert result['type'] == 'form'
|
assert result['type'] == 'form'
|
||||||
assert result['step_id'] == 'pair'
|
assert result['step_id'] == 'pair'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
pairing = mock.Mock(pairing_data={
|
pairing = mock.Mock(pairing_data={
|
||||||
'AccessoryPairingID': '00:00:00:00:00:00',
|
'AccessoryPairingID': '00:00:00:00:00:00',
|
||||||
@ -66,6 +74,7 @@ async def test_discovery_works(hass):
|
|||||||
async def test_discovery_works_upper_case(hass):
|
async def test_discovery_works_upper_case(hass):
|
||||||
"""Test a device being discovered."""
|
"""Test a device being discovered."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -76,12 +85,12 @@ async def test_discovery_works_upper_case(hass):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await flow.async_step_discovery(discovery_info)
|
result = await flow.async_step_discovery(discovery_info)
|
||||||
assert result['type'] == 'form'
|
assert result['type'] == 'form'
|
||||||
assert result['step_id'] == 'pair'
|
assert result['step_id'] == 'pair'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
pairing = mock.Mock(pairing_data={
|
pairing = mock.Mock(pairing_data={
|
||||||
'AccessoryPairingID': '00:00:00:00:00:00',
|
'AccessoryPairingID': '00:00:00:00:00:00',
|
||||||
@ -117,6 +126,7 @@ async def test_discovery_works_upper_case(hass):
|
|||||||
async def test_discovery_works_missing_csharp(hass):
|
async def test_discovery_works_missing_csharp(hass):
|
||||||
"""Test a device being discovered that has missing mdns attrs."""
|
"""Test a device being discovered that has missing mdns attrs."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -126,12 +136,12 @@ async def test_discovery_works_missing_csharp(hass):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await flow.async_step_discovery(discovery_info)
|
result = await flow.async_step_discovery(discovery_info)
|
||||||
assert result['type'] == 'form'
|
assert result['type'] == 'form'
|
||||||
assert result['step_id'] == 'pair'
|
assert result['step_id'] == 'pair'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
pairing = mock.Mock(pairing_data={
|
pairing = mock.Mock(pairing_data={
|
||||||
'AccessoryPairingID': '00:00:00:00:00:00',
|
'AccessoryPairingID': '00:00:00:00:00:00',
|
||||||
@ -167,6 +177,7 @@ async def test_discovery_works_missing_csharp(hass):
|
|||||||
async def test_pair_already_paired_1(hass):
|
async def test_pair_already_paired_1(hass):
|
||||||
"""Already paired."""
|
"""Already paired."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -177,17 +188,18 @@ async def test_pair_already_paired_1(hass):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await flow.async_step_discovery(discovery_info)
|
result = await flow.async_step_discovery(discovery_info)
|
||||||
assert result['type'] == 'abort'
|
assert result['type'] == 'abort'
|
||||||
assert result['reason'] == 'already_paired'
|
assert result['reason'] == 'already_paired'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_ignored_model(hass):
|
async def test_discovery_ignored_model(hass):
|
||||||
"""Already paired."""
|
"""Already paired."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -198,12 +210,12 @@ async def test_discovery_ignored_model(hass):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await flow.async_step_discovery(discovery_info)
|
result = await flow.async_step_discovery(discovery_info)
|
||||||
assert result['type'] == 'abort'
|
assert result['type'] == 'abort'
|
||||||
assert result['reason'] == 'ignored_model'
|
assert result['reason'] == 'ignored_model'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
|
|
||||||
async def test_discovery_invalid_config_entry(hass):
|
async def test_discovery_invalid_config_entry(hass):
|
||||||
@ -216,6 +228,7 @@ async def test_discovery_invalid_config_entry(hass):
|
|||||||
assert len(hass.config_entries.async_entries()) == 1
|
assert len(hass.config_entries.async_entries()) == 1
|
||||||
|
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -226,12 +239,12 @@ async def test_discovery_invalid_config_entry(hass):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await flow.async_step_discovery(discovery_info)
|
result = await flow.async_step_discovery(discovery_info)
|
||||||
assert result['type'] == 'form'
|
assert result['type'] == 'form'
|
||||||
assert result['step_id'] == 'pair'
|
assert result['step_id'] == 'pair'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
# Discovery of a HKID that is in a pairable state but for which there is
|
# Discovery of a HKID that is in a pairable state but for which there is
|
||||||
# already a config entry - in that case the stale config entry is
|
# already a config entry - in that case the stale config entry is
|
||||||
@ -243,6 +256,7 @@ async def test_discovery_invalid_config_entry(hass):
|
|||||||
async def test_discovery_already_configured(hass):
|
async def test_discovery_already_configured(hass):
|
||||||
"""Already configured."""
|
"""Already configured."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -259,12 +273,12 @@ async def test_discovery_already_configured(hass):
|
|||||||
conn.config_num = 1
|
conn.config_num = 1
|
||||||
hass.data[KNOWN_DEVICES]['00:00:00:00:00:00'] = conn
|
hass.data[KNOWN_DEVICES]['00:00:00:00:00:00'] = conn
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await flow.async_step_discovery(discovery_info)
|
result = await flow.async_step_discovery(discovery_info)
|
||||||
assert result['type'] == 'abort'
|
assert result['type'] == 'abort'
|
||||||
assert result['reason'] == 'already_configured'
|
assert result['reason'] == 'already_configured'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
assert conn.async_config_num_changed.call_count == 0
|
assert conn.async_config_num_changed.call_count == 0
|
||||||
|
|
||||||
@ -272,6 +286,7 @@ async def test_discovery_already_configured(hass):
|
|||||||
async def test_discovery_already_configured_config_change(hass):
|
async def test_discovery_already_configured_config_change(hass):
|
||||||
"""Already configured."""
|
"""Already configured."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -288,12 +303,12 @@ async def test_discovery_already_configured_config_change(hass):
|
|||||||
conn.config_num = 1
|
conn.config_num = 1
|
||||||
hass.data[KNOWN_DEVICES]['00:00:00:00:00:00'] = conn
|
hass.data[KNOWN_DEVICES]['00:00:00:00:00:00'] = conn
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await flow.async_step_discovery(discovery_info)
|
result = await flow.async_step_discovery(discovery_info)
|
||||||
assert result['type'] == 'abort'
|
assert result['type'] == 'abort'
|
||||||
assert result['reason'] == 'already_configured'
|
assert result['reason'] == 'already_configured'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
assert conn.async_refresh_entity_map.call_args == mock.call(2)
|
assert conn.async_refresh_entity_map.call_args == mock.call(2)
|
||||||
|
|
||||||
@ -301,6 +316,7 @@ async def test_discovery_already_configured_config_change(hass):
|
|||||||
async def test_pair_unable_to_pair(hass):
|
async def test_pair_unable_to_pair(hass):
|
||||||
"""Pairing completed without exception, but didn't create a pairing."""
|
"""Pairing completed without exception, but didn't create a pairing."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -311,12 +327,12 @@ async def test_pair_unable_to_pair(hass):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await flow.async_step_discovery(discovery_info)
|
result = await flow.async_step_discovery(discovery_info)
|
||||||
assert result['type'] == 'form'
|
assert result['type'] == 'form'
|
||||||
assert result['step_id'] == 'pair'
|
assert result['step_id'] == 'pair'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
controller = mock.Mock()
|
controller = mock.Mock()
|
||||||
controller.pairings = {}
|
controller.pairings = {}
|
||||||
@ -334,6 +350,7 @@ async def test_pair_unable_to_pair(hass):
|
|||||||
async def test_pair_authentication_error(hass):
|
async def test_pair_authentication_error(hass):
|
||||||
"""Pairing code is incorrect."""
|
"""Pairing code is incorrect."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -344,12 +361,12 @@ async def test_pair_authentication_error(hass):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await flow.async_step_discovery(discovery_info)
|
result = await flow.async_step_discovery(discovery_info)
|
||||||
assert result['type'] == 'form'
|
assert result['type'] == 'form'
|
||||||
assert result['step_id'] == 'pair'
|
assert result['step_id'] == 'pair'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
controller = mock.Mock()
|
controller = mock.Mock()
|
||||||
controller.pairings = {}
|
controller.pairings = {}
|
||||||
@ -369,6 +386,7 @@ async def test_pair_authentication_error(hass):
|
|||||||
async def test_pair_unknown_error(hass):
|
async def test_pair_unknown_error(hass):
|
||||||
"""Pairing failed for an unknown rason."""
|
"""Pairing failed for an unknown rason."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -379,12 +397,12 @@ async def test_pair_unknown_error(hass):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await flow.async_step_discovery(discovery_info)
|
result = await flow.async_step_discovery(discovery_info)
|
||||||
assert result['type'] == 'form'
|
assert result['type'] == 'form'
|
||||||
assert result['step_id'] == 'pair'
|
assert result['step_id'] == 'pair'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
controller = mock.Mock()
|
controller = mock.Mock()
|
||||||
controller.pairings = {}
|
controller.pairings = {}
|
||||||
@ -404,6 +422,7 @@ async def test_pair_unknown_error(hass):
|
|||||||
async def test_pair_already_paired(hass):
|
async def test_pair_already_paired(hass):
|
||||||
"""Device is already paired."""
|
"""Device is already paired."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -414,12 +433,12 @@ async def test_pair_already_paired(hass):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await flow.async_step_discovery(discovery_info)
|
result = await flow.async_step_discovery(discovery_info)
|
||||||
assert result['type'] == 'form'
|
assert result['type'] == 'form'
|
||||||
assert result['step_id'] == 'pair'
|
assert result['step_id'] == 'pair'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
controller = mock.Mock()
|
controller = mock.Mock()
|
||||||
controller.pairings = {}
|
controller.pairings = {}
|
||||||
@ -439,6 +458,7 @@ async def test_pair_already_paired(hass):
|
|||||||
async def test_import_works(hass):
|
async def test_import_works(hass):
|
||||||
"""Test a device being discovered."""
|
"""Test a device being discovered."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -468,8 +488,7 @@ async def test_import_works(hass):
|
|||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing"
|
pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing"
|
||||||
|
|
||||||
@ -486,6 +505,7 @@ async def test_import_works(hass):
|
|||||||
async def test_import_already_configured(hass):
|
async def test_import_already_configured(hass):
|
||||||
"""Test importing a device from .homekit that is already a ConfigEntry."""
|
"""Test importing a device from .homekit that is already a ConfigEntry."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -502,12 +522,11 @@ async def test_import_already_configured(hass):
|
|||||||
|
|
||||||
config_entry = MockConfigEntry(
|
config_entry = MockConfigEntry(
|
||||||
domain='homekit_controller',
|
domain='homekit_controller',
|
||||||
data=import_info
|
data=import_info,
|
||||||
)
|
)
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await flow.async_import_legacy_pairing(
|
result = await flow.async_import_legacy_pairing(
|
||||||
discovery_info['properties'], import_info)
|
discovery_info['properties'], import_info)
|
||||||
@ -518,6 +537,7 @@ async def test_import_already_configured(hass):
|
|||||||
async def test_user_works(hass):
|
async def test_user_works(hass):
|
||||||
"""Test user initiated disovers devices."""
|
"""Test user initiated disovers devices."""
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -550,8 +570,7 @@ async def test_user_works(hass):
|
|||||||
discovery_info,
|
discovery_info,
|
||||||
]
|
]
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
with mock.patch('homekit.Controller') as controller_cls:
|
with mock.patch('homekit.Controller') as controller_cls:
|
||||||
controller_cls.return_value = controller
|
controller_cls.return_value = controller
|
||||||
@ -577,8 +596,7 @@ async def test_user_works(hass):
|
|||||||
|
|
||||||
async def test_user_no_devices(hass):
|
async def test_user_no_devices(hass):
|
||||||
"""Test user initiated pairing where no devices discovered."""
|
"""Test user initiated pairing where no devices discovered."""
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
with mock.patch('homekit.Controller') as controller_cls:
|
with mock.patch('homekit.Controller') as controller_cls:
|
||||||
controller_cls.return_value.discover.return_value = []
|
controller_cls.return_value.discover.return_value = []
|
||||||
@ -590,10 +608,10 @@ async def test_user_no_devices(hass):
|
|||||||
|
|
||||||
async def test_user_no_unpaired_devices(hass):
|
async def test_user_no_unpaired_devices(hass):
|
||||||
"""Test user initiated pairing where no unpaired devices discovered."""
|
"""Test user initiated pairing where no unpaired devices discovered."""
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -638,6 +656,7 @@ async def test_parse_new_homekit_json(hass):
|
|||||||
mock_open = mock.mock_open(read_data=json.dumps(read_data))
|
mock_open = mock.mock_open(read_data=json.dumps(read_data))
|
||||||
|
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -648,8 +667,7 @@ async def test_parse_new_homekit_json(hass):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing"
|
pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing"
|
||||||
|
|
||||||
@ -662,6 +680,7 @@ async def test_parse_new_homekit_json(hass):
|
|||||||
assert result['type'] == 'create_entry'
|
assert result['type'] == 'create_entry'
|
||||||
assert result['title'] == 'TestDevice'
|
assert result['title'] == 'TestDevice'
|
||||||
assert result['data']['AccessoryPairingID'] == '00:00:00:00:00:00'
|
assert result['data']['AccessoryPairingID'] == '00:00:00:00:00:00'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
|
|
||||||
async def test_parse_old_homekit_json(hass):
|
async def test_parse_old_homekit_json(hass):
|
||||||
@ -694,6 +713,7 @@ async def test_parse_old_homekit_json(hass):
|
|||||||
mock_open = mock.mock_open(read_data=json.dumps(read_data))
|
mock_open = mock.mock_open(read_data=json.dumps(read_data))
|
||||||
|
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -704,8 +724,7 @@ async def test_parse_old_homekit_json(hass):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing"
|
pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing"
|
||||||
|
|
||||||
@ -719,6 +738,7 @@ async def test_parse_old_homekit_json(hass):
|
|||||||
assert result['type'] == 'create_entry'
|
assert result['type'] == 'create_entry'
|
||||||
assert result['title'] == 'TestDevice'
|
assert result['title'] == 'TestDevice'
|
||||||
assert result['data']['AccessoryPairingID'] == '00:00:00:00:00:00'
|
assert result['data']['AccessoryPairingID'] == '00:00:00:00:00:00'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
|
||||||
|
|
||||||
async def test_parse_overlapping_homekit_json(hass):
|
async def test_parse_overlapping_homekit_json(hass):
|
||||||
@ -762,6 +782,7 @@ async def test_parse_overlapping_homekit_json(hass):
|
|||||||
side_effects = [mock_open_1.return_value, mock_open_2.return_value]
|
side_effects = [mock_open_1.return_value, mock_open_2.return_value]
|
||||||
|
|
||||||
discovery_info = {
|
discovery_info = {
|
||||||
|
'name': 'TestDevice',
|
||||||
'host': '127.0.0.1',
|
'host': '127.0.0.1',
|
||||||
'port': 8080,
|
'port': 8080,
|
||||||
'properties': {
|
'properties': {
|
||||||
@ -772,8 +793,7 @@ async def test_parse_overlapping_homekit_json(hass):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flow = config_flow.HomekitControllerFlowHandler()
|
flow = _setup_flow_handler(hass)
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing"
|
pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing"
|
||||||
|
|
||||||
@ -789,3 +809,4 @@ async def test_parse_overlapping_homekit_json(hass):
|
|||||||
assert result['type'] == 'create_entry'
|
assert result['type'] == 'create_entry'
|
||||||
assert result['title'] == 'TestDevice'
|
assert result['title'] == 'TestDevice'
|
||||||
assert result['data']['AccessoryPairingID'] == '00:00:00:00:00:00'
|
assert result['data']['AccessoryPairingID'] == '00:00:00:00:00:00'
|
||||||
|
assert flow.context == {'title_placeholders': {'name': 'TestDevice'}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user