From 8def0326dd326ccdd6a117d20ccc895c46c8290d Mon Sep 17 00:00:00 2001 From: springstan <46536646+springstan@users.noreply.github.com> Date: Fri, 6 Dec 2019 06:08:08 +0100 Subject: [PATCH] Move imports to top for izone (#29508) * Move imports to top for izone * Isorted all imports, fixed tests for config_flow --- homeassistant/components/izone/__init__.py | 2 +- homeassistant/components/izone/climate.py | 26 +++++++++---------- homeassistant/components/izone/config_flow.py | 7 +++-- homeassistant/components/izone/discovery.py | 5 ++-- tests/components/izone/test_config_flow.py | 6 ++--- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/homeassistant/components/izone/__init__.py b/homeassistant/components/izone/__init__.py index 6fecbc1f3a6..0e5dcddbc48 100644 --- a/homeassistant/components/izone/__init__.py +++ b/homeassistant/components/izone/__init__.py @@ -13,7 +13,7 @@ from homeassistant.const import CONF_EXCLUDE import homeassistant.helpers.config_validation as cv from homeassistant.helpers.typing import ConfigType, HomeAssistantType -from .const import IZONE, DATA_CONFIG +from .const import DATA_CONFIG, IZONE from .discovery import async_start_discovery_service, async_stop_discovery_service _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/izone/climate.py b/homeassistant/components/izone/climate.py index c932c66627b..b80dfc2542f 100644 --- a/homeassistant/components/izone/climate.py +++ b/homeassistant/components/izone/climate.py @@ -1,22 +1,21 @@ """Support for the iZone HVAC.""" import logging -from typing import Optional, List +from typing import List, Optional -from pizone import Zone, Controller +from pizone import Controller, Zone -from homeassistant.core import callback from homeassistant.components.climate import ClimateDevice from homeassistant.components.climate.const import ( - HVAC_MODE_HEAT_COOL, + FAN_AUTO, + FAN_HIGH, + FAN_LOW, + FAN_MEDIUM, HVAC_MODE_COOL, HVAC_MODE_DRY, HVAC_MODE_FAN_ONLY, HVAC_MODE_HEAT, + HVAC_MODE_HEAT_COOL, HVAC_MODE_OFF, - FAN_LOW, - FAN_MEDIUM, - FAN_HIGH, - FAN_AUTO, PRESET_ECO, PRESET_NONE, SUPPORT_FAN_MODE, @@ -25,23 +24,24 @@ from homeassistant.components.climate.const import ( ) from homeassistant.const import ( ATTR_TEMPERATURE, + CONF_EXCLUDE, PRECISION_HALVES, TEMP_CELSIUS, - CONF_EXCLUDE, ) +from homeassistant.core import callback +from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.temperature import display_temp as show_temp from homeassistant.helpers.typing import ConfigType, HomeAssistantType -from homeassistant.helpers.dispatcher import async_dispatcher_connect from .const import ( + DATA_CONFIG, DATA_DISCOVERY_SERVICE, - IZONE, - DISPATCH_CONTROLLER_DISCOVERED, DISPATCH_CONTROLLER_DISCONNECTED, + DISPATCH_CONTROLLER_DISCOVERED, DISPATCH_CONTROLLER_RECONNECTED, DISPATCH_CONTROLLER_UPDATE, DISPATCH_ZONE_UPDATE, - DATA_CONFIG, + IZONE, ) _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/izone/config_flow.py b/homeassistant/components/izone/config_flow.py index eb57a36a2bb..add1bb47a54 100644 --- a/homeassistant/components/izone/config_flow.py +++ b/homeassistant/components/izone/config_flow.py @@ -1,7 +1,7 @@ """Config flow for izone.""" -import logging import asyncio +import logging from async_timeout import timeout @@ -9,14 +9,13 @@ from homeassistant import config_entries from homeassistant.helpers import config_entry_flow from homeassistant.helpers.dispatcher import async_dispatcher_connect -from .const import IZONE, TIMEOUT_DISCOVERY, DISPATCH_CONTROLLER_DISCOVERED - +from .const import DISPATCH_CONTROLLER_DISCOVERED, IZONE, TIMEOUT_DISCOVERY +from .discovery import async_start_discovery_service, async_stop_discovery_service _LOGGER = logging.getLogger(__name__) async def _async_has_devices(hass): - from .discovery import async_start_discovery_service, async_stop_discovery_service controller_ready = asyncio.Event() async_dispatcher_connect( diff --git a/homeassistant/components/izone/discovery.py b/homeassistant/components/izone/discovery.py index 3630c28605b..c49144f1db9 100644 --- a/homeassistant/components/izone/discovery.py +++ b/homeassistant/components/izone/discovery.py @@ -1,17 +1,18 @@ """Internal discovery service for iZone AC.""" import logging + import pizone from homeassistant.const import EVENT_HOMEASSISTANT_STOP from homeassistant.helpers import aiohttp_client -from homeassistant.helpers.typing import HomeAssistantType from homeassistant.helpers.dispatcher import async_dispatcher_send +from homeassistant.helpers.typing import HomeAssistantType from .const import ( DATA_DISCOVERY_SERVICE, - DISPATCH_CONTROLLER_DISCOVERED, DISPATCH_CONTROLLER_DISCONNECTED, + DISPATCH_CONTROLLER_DISCOVERED, DISPATCH_CONTROLLER_RECONNECTED, DISPATCH_CONTROLLER_UPDATE, DISPATCH_ZONE_UPDATE, diff --git a/tests/components/izone/test_config_flow.py b/tests/components/izone/test_config_flow.py index faa920271e3..b5f9aa41c80 100644 --- a/tests/components/izone/test_config_flow.py +++ b/tests/components/izone/test_config_flow.py @@ -33,9 +33,9 @@ async def test_not_found(hass, mock_disco): """Test not finding iZone controller.""" with patch( - "homeassistant.components.izone.discovery.async_start_discovery_service" + "homeassistant.components.izone.config_flow.async_start_discovery_service" ) as start_disco, patch( - "homeassistant.components.izone.discovery.async_stop_discovery_service", + "homeassistant.components.izone.config_flow.async_stop_discovery_service", return_value=mock_coro(), ) as stop_disco: start_disco.side_effect = _mock_start_discovery(hass, mock_disco) @@ -62,7 +62,7 @@ async def test_found(hass, mock_disco): "homeassistant.components.izone.climate.async_setup_entry", return_value=mock_coro(True), ) as mock_setup, patch( - "homeassistant.components.izone.discovery.async_start_discovery_service" + "homeassistant.components.izone.config_flow.async_start_discovery_service" ) as start_disco, patch( "homeassistant.components.izone.async_start_discovery_service", return_value=mock_coro(),