From 7f948594eb687294ae75ea0ee7454e2a1239df94 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Mon, 9 Dec 2019 20:00:14 +0100 Subject: [PATCH] Sort imports according to PEP8 for google_assistant (#29633) * sort imports and fix flake8 issue for google * add isort:skip to EVENT_SYNC_RECEIVED --- .../components/google_assistant/__init__.py | 3 +- tests/components/google_assistant/__init__.py | 1 + .../google_assistant/test_google_assistant.py | 10 ++--- .../google_assistant/test_helpers.py | 13 ++++-- .../components/google_assistant/test_http.py | 15 +++---- .../components/google_assistant/test_init.py | 2 +- .../google_assistant/test_report_state.py | 5 +-- .../google_assistant/test_smart_home.py | 41 ++++++++++--------- .../components/google_assistant/test_trait.py | 35 ++++++++-------- 9 files changed, 68 insertions(+), 57 deletions(-) diff --git a/homeassistant/components/google_assistant/__init__.py b/homeassistant/components/google_assistant/__init__.py index f34a8e342c4..107003db583 100644 --- a/homeassistant/components/google_assistant/__init__.py +++ b/homeassistant/components/google_assistant/__init__.py @@ -29,10 +29,11 @@ from .const import ( DOMAIN, SERVICE_REQUEST_SYNC, ) -from .const import EVENT_COMMAND_RECEIVED, EVENT_SYNC_RECEIVED # noqa: F401 from .const import EVENT_QUERY_RECEIVED # noqa: F401 from .http import GoogleAssistantView, GoogleConfig +from .const import EVENT_COMMAND_RECEIVED, EVENT_SYNC_RECEIVED # noqa: F401, isort:skip + _LOGGER = logging.getLogger(__name__) ENTITY_SCHEMA = vol.Schema( diff --git a/tests/components/google_assistant/__init__.py b/tests/components/google_assistant/__init__.py index 657bf930ed6..db3b2e68f20 100644 --- a/tests/components/google_assistant/__init__.py +++ b/tests/components/google_assistant/__init__.py @@ -1,5 +1,6 @@ """Tests for the Google Assistant integration.""" from asynctest.mock import MagicMock + from homeassistant.components.google_assistant import helpers diff --git a/tests/components/google_assistant/test_google_assistant.py b/tests/components/google_assistant/test_google_assistant.py index b43e913ab27..d1d58422884 100644 --- a/tests/components/google_assistant/test_google_assistant.py +++ b/tests/components/google_assistant/test_google_assistant.py @@ -6,19 +6,19 @@ import json from aiohttp.hdrs import AUTHORIZATION import pytest -from homeassistant import core, const, setup +from homeassistant import const, core, setup from homeassistant.components import ( - fan, + alarm_control_panel, cover, + fan, + google_assistant as ga, light, - switch, lock, media_player, - alarm_control_panel, + switch, ) from homeassistant.components.climate import const as climate from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES -from homeassistant.components import google_assistant as ga from . import DEMO_DEVICES diff --git a/tests/components/google_assistant/test_helpers.py b/tests/components/google_assistant/test_helpers.py index eb479a3b6b5..9c8a868e68d 100644 --- a/tests/components/google_assistant/test_helpers.py +++ b/tests/components/google_assistant/test_helpers.py @@ -1,17 +1,22 @@ """Test Google Assistant helpers.""" -from asynctest.mock import Mock, patch, call from datetime import timedelta + +from asynctest.mock import Mock, call, patch import pytest -from homeassistant.setup import async_setup_component + from homeassistant.components.google_assistant import helpers -from homeassistant.components.google_assistant.const import EVENT_COMMAND_RECEIVED +from homeassistant.components.google_assistant.const import ( # noqa: F401 + EVENT_COMMAND_RECEIVED, +) +from homeassistant.setup import async_setup_component from homeassistant.util import dt + from . import MockConfig from tests.common import ( async_capture_events, - async_mock_service, async_fire_time_changed, + async_mock_service, ) diff --git a/tests/components/google_assistant/test_http.py b/tests/components/google_assistant/test_http.py index 86ffcc87ac0..112935f0160 100644 --- a/tests/components/google_assistant/test_http.py +++ b/tests/components/google_assistant/test_http.py @@ -1,17 +1,18 @@ """Test Google http services.""" -from datetime import datetime, timezone, timedelta -from asynctest import patch, ANY +from datetime import datetime, timedelta, timezone +from asynctest import ANY, patch + +from homeassistant.components.google_assistant import GOOGLE_ASSISTANT_SCHEMA +from homeassistant.components.google_assistant.const import ( + HOMEGRAPH_TOKEN_URL, + REPORT_STATE_BASE_URL, +) from homeassistant.components.google_assistant.http import ( GoogleConfig, _get_homegraph_jwt, _get_homegraph_token, ) -from homeassistant.components.google_assistant import GOOGLE_ASSISTANT_SCHEMA -from homeassistant.components.google_assistant.const import ( - REPORT_STATE_BASE_URL, - HOMEGRAPH_TOKEN_URL, -) DUMMY_CONFIG = GOOGLE_ASSISTANT_SCHEMA( { diff --git a/tests/components/google_assistant/test_init.py b/tests/components/google_assistant/test_init.py index 9a8b9643cfe..7c5d14ae6d7 100644 --- a/tests/components/google_assistant/test_init.py +++ b/tests/components/google_assistant/test_init.py @@ -1,9 +1,9 @@ """The tests for google-assistant init.""" import asyncio +from homeassistant.components import google_assistant as ga from homeassistant.core import Context from homeassistant.setup import async_setup_component -from homeassistant.components import google_assistant as ga GA_API_KEY = "Agdgjsj399sdfkosd932ksd" diff --git a/tests/components/google_assistant/test_report_state.py b/tests/components/google_assistant/test_report_state.py index ce624c9ca95..fd9cad27ffa 100644 --- a/tests/components/google_assistant/test_report_state.py +++ b/tests/components/google_assistant/test_report_state.py @@ -1,13 +1,12 @@ """Test Google report state.""" from unittest.mock import patch -from homeassistant.components.google_assistant import report_state, error +from homeassistant.components.google_assistant import error, report_state from homeassistant.util.dt import utcnow from . import BASIC_CONFIG - -from tests.common import mock_coro, async_fire_time_changed +from tests.common import async_fire_time_changed, mock_coro async def test_report_state(hass, caplog): diff --git a/tests/components/google_assistant/test_smart_home.py b/tests/components/google_assistant/test_smart_home.py index c144ffee6de..7ffe9cda477 100644 --- a/tests/components/google_assistant/test_smart_home.py +++ b/tests/components/google_assistant/test_smart_home.py @@ -1,40 +1,41 @@ """Test Google Smart Home.""" -from unittest.mock import patch, Mock +from unittest.mock import Mock, patch + import pytest -from homeassistant.core import State, EVENT_CALL_SERVICE -from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, TEMP_CELSIUS, __version__ -from homeassistant.setup import async_setup_component from homeassistant.components import camera from homeassistant.components.climate.const import ( - ATTR_MIN_TEMP, ATTR_MAX_TEMP, + ATTR_MIN_TEMP, HVAC_MODE_HEAT, ) -from homeassistant.components.google_assistant import ( - const, - trait, - smart_home as sh, - EVENT_COMMAND_RECEIVED, - EVENT_QUERY_RECEIVED, - EVENT_SYNC_RECEIVED, -) from homeassistant.components.demo.binary_sensor import DemoBinarySensor from homeassistant.components.demo.cover import DemoCover from homeassistant.components.demo.light import DemoLight from homeassistant.components.demo.media_player import AbstractDemoPlayer from homeassistant.components.demo.switch import DemoSwitch - -from homeassistant.helpers import device_registry -from tests.common import ( - mock_device_registry, - mock_registry, - mock_area_registry, - mock_coro, +from homeassistant.components.google_assistant import ( + EVENT_COMMAND_RECEIVED, + EVENT_QUERY_RECEIVED, + EVENT_SYNC_RECEIVED, + const, + smart_home as sh, + trait, ) +from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, TEMP_CELSIUS, __version__ +from homeassistant.core import EVENT_CALL_SERVICE, State +from homeassistant.helpers import device_registry +from homeassistant.setup import async_setup_component from . import BASIC_CONFIG, MockConfig +from tests.common import ( + mock_area_registry, + mock_coro, + mock_device_registry, + mock_registry, +) + REQ_ID = "ff36a3cc-ec34-11e6-b1a0-64510650abcf" diff --git a/tests/components/google_assistant/test_trait.py b/tests/components/google_assistant/test_trait.py index 6d24aa0942f..8a1d7384729 100644 --- a/tests/components/google_assistant/test_trait.py +++ b/tests/components/google_assistant/test_trait.py @@ -1,13 +1,16 @@ """Tests for the Google Assistant traits.""" -from unittest.mock import patch, Mock import logging +from unittest.mock import Mock, patch + import pytest from homeassistant.components import ( + alarm_control_panel, binary_sensor, camera, cover, fan, + group, input_boolean, light, lock, @@ -17,33 +20,33 @@ from homeassistant.components import ( sensor, switch, vacuum, - group, - alarm_control_panel, ) from homeassistant.components.climate import const as climate -from homeassistant.components.google_assistant import trait, helpers, const, error +from homeassistant.components.google_assistant import const, error, helpers, trait from homeassistant.const import ( - STATE_ON, - STATE_OFF, + ATTR_ASSUMED_STATE, + ATTR_DEVICE_CLASS, + ATTR_ENTITY_ID, + ATTR_SUPPORTED_FEATURES, + ATTR_TEMPERATURE, + SERVICE_TURN_OFF, + SERVICE_TURN_ON, STATE_ALARM_ARMED_AWAY, STATE_ALARM_DISARMED, STATE_ALARM_PENDING, - ATTR_ENTITY_ID, - SERVICE_TURN_ON, - SERVICE_TURN_OFF, + STATE_OFF, + STATE_ON, + STATE_UNKNOWN, TEMP_CELSIUS, TEMP_FAHRENHEIT, - ATTR_SUPPORTED_FEATURES, - ATTR_TEMPERATURE, - ATTR_DEVICE_CLASS, - ATTR_ASSUMED_STATE, - STATE_UNKNOWN, ) -from homeassistant.core import State, DOMAIN as HA_DOMAIN, EVENT_CALL_SERVICE +from homeassistant.core import DOMAIN as HA_DOMAIN, EVENT_CALL_SERVICE, State from homeassistant.util import color -from tests.common import async_mock_service, mock_coro + from . import BASIC_CONFIG, MockConfig +from tests.common import async_mock_service, mock_coro + _LOGGER = logging.getLogger(__name__) REQ_ID = "ff36a3cc-ec34-11e6-b1a0-64510650abcf"