From 2b1b47bfdd81840f5e33849fc0d9c6146f8f5742 Mon Sep 17 00:00:00 2001 From: Jc2k Date: Tue, 12 Mar 2019 20:54:08 +0000 Subject: [PATCH] homekit_controller: Bump homekit to 0.13.0 (#21965) * Bump homekit to 0.13.0 * Update gen_requirements_all.py * Escape values used in TESTS_REQUIREMENTS --- .../components/homekit_controller/__init__.py | 6 +++--- .../components/homekit_controller/config_flow.py | 4 ++-- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- script/gen_requirements_all.py | 6 +++--- .../homekit_controller/test_config_flow.py | 16 ++++++++++++---- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/homekit_controller/__init__.py b/homeassistant/components/homekit_controller/__init__.py index 072e323ecd1..4b73aa26455 100644 --- a/homeassistant/components/homekit_controller/__init__.py +++ b/homeassistant/components/homekit_controller/__init__.py @@ -15,7 +15,7 @@ from .const import ( ) -REQUIREMENTS = ['homekit==0.12.2'] +REQUIREMENTS = ['homekit[IP]==0.13.0'] HOMEKIT_DIR = '.homekit' @@ -314,7 +314,7 @@ def setup(hass, config): """Set up for Homekit devices.""" # pylint: disable=import-error import homekit - from homekit.controller import Pairing + from homekit.controller.ip_implementation import IpPairing hass.data[CONTROLLER] = controller = homekit.Controller() @@ -335,7 +335,7 @@ def setup(hass, config): continue with open(os.path.join(data_dir, device)) as pairing_data_fp: pairing_data = json.load(pairing_data_fp) - controller.pairings[alias] = Pairing(pairing_data) + controller.pairings[alias] = IpPairing(pairing_data) controller.save_data(pairing_file) def discovery_dispatch(service, discovery_info): diff --git a/homeassistant/components/homekit_controller/config_flow.py b/homeassistant/components/homekit_controller/config_flow.py index 52768097aec..1cd66896fe2 100644 --- a/homeassistant/components/homekit_controller/config_flow.py +++ b/homeassistant/components/homekit_controller/config_flow.py @@ -189,7 +189,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow): async def async_import_legacy_pairing(self, discovery_props, pairing_data): """Migrate a legacy pairing to config entries.""" - from homekit.controller import Pairing + from homekit.controller.ip_implementation import IpPairing hkid = discovery_props['id'] @@ -204,7 +204,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow): ("Legacy configuration %s for homekit" "accessory migrated to config entries"), hkid) - pairing = Pairing(pairing_data) + pairing = IpPairing(pairing_data) return await self._entry_from_accessory(pairing) diff --git a/requirements_all.txt b/requirements_all.txt index b5c614d4576..3af20b32975 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -560,7 +560,7 @@ home-assistant-frontend==20190312.0 homeassistant-pyozw==0.1.2 # homeassistant.components.homekit_controller -homekit==0.12.2 +homekit[IP]==0.13.0 # homeassistant.components.homematicip_cloud homematicip==0.10.6 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 30bd295dcd0..c2018eb92a9 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -129,7 +129,7 @@ holidays==0.9.9 home-assistant-frontend==20190312.0 # homeassistant.components.homekit_controller -homekit==0.12.2 +homekit[IP]==0.13.0 # homeassistant.components.homematicip_cloud homematicip==0.10.6 diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py index bb242d1e7ba..ada84d2bbcd 100755 --- a/script/gen_requirements_all.py +++ b/script/gen_requirements_all.py @@ -69,7 +69,7 @@ TEST_REQUIREMENTS = ( 'hdate', 'holidays', 'home-assistant-frontend', - 'homekit', + 'homekit[IP]', 'homematicip', 'influxdb', 'jsonpath', @@ -106,7 +106,7 @@ TEST_REQUIREMENTS = ( 'python-forecastio', 'python-nest', 'python_awair', - 'pytradfri\\[async\\]', + 'pytradfri[async]', 'pyunifi', 'pyupnp-async', 'pywebpush', @@ -291,7 +291,7 @@ def requirements_test_output(reqs): output.append('\n') filtered = {key: value for key, value in reqs.items() if any( - re.search(r'(^|#){}($|[=><])'.format(ign), + re.search(r'(^|#){}($|[=><])'.format(re.escape(ign)), key) is not None for ign in TEST_REQUIREMENTS)} output.append(generate_requirements_list(filtered)) diff --git a/tests/components/homekit_controller/test_config_flow.py b/tests/components/homekit_controller/test_config_flow.py index cf4da597b12..62c741b4eaa 100644 --- a/tests/components/homekit_controller/test_config_flow.py +++ b/tests/components/homekit_controller/test_config_flow.py @@ -471,7 +471,9 @@ async def test_import_works(hass): flow = config_flow.HomekitControllerFlowHandler() flow.hass = hass - with mock.patch('homekit.controller.Pairing') as pairing_cls: + pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing" + + with mock.patch(pairing_cls_imp) as pairing_cls: pairing_cls.return_value = pairing result = await flow.async_import_legacy_pairing( discovery_info['properties'], import_info) @@ -649,7 +651,9 @@ async def test_parse_new_homekit_json(hass): flow = config_flow.HomekitControllerFlowHandler() flow.hass = hass - with mock.patch('homekit.controller.Pairing') as pairing_cls: + pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing" + + with mock.patch(pairing_cls_imp) as pairing_cls: pairing_cls.return_value = pairing with mock.patch('builtins.open', mock_open): with mock.patch('os.path', mock_path): @@ -703,7 +707,9 @@ async def test_parse_old_homekit_json(hass): flow = config_flow.HomekitControllerFlowHandler() flow.hass = hass - with mock.patch('homekit.controller.Pairing') as pairing_cls: + pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing" + + with mock.patch(pairing_cls_imp) as pairing_cls: pairing_cls.return_value = pairing with mock.patch('builtins.open', mock_open): with mock.patch('os.path', mock_path): @@ -769,7 +775,9 @@ async def test_parse_overlapping_homekit_json(hass): flow = config_flow.HomekitControllerFlowHandler() flow.hass = hass - with mock.patch('homekit.controller.Pairing') as pairing_cls: + pairing_cls_imp = "homekit.controller.ip_implementation.IpPairing" + + with mock.patch(pairing_cls_imp) as pairing_cls: pairing_cls.return_value = pairing with mock.patch('builtins.open', side_effect=side_effects): with mock.patch('os.path', mock_path):