use isort to sort imports according to PEP8 for cloud (#29626)
This commit is contained in:
parent
e4e9cdce73
commit
fbd4cf1089
17 changed files with 71 additions and 71 deletions
|
@ -7,7 +7,7 @@ from hass_nabucasa import account_link
|
||||||
|
|
||||||
from homeassistant.const import MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION
|
from homeassistant.const import MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers import event, config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow, event
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
|
|
@ -7,24 +7,23 @@ import aiohttp
|
||||||
import async_timeout
|
import async_timeout
|
||||||
from hass_nabucasa import cloud_api
|
from hass_nabucasa import cloud_api
|
||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.components.alexa import (
|
||||||
|
config as alexa_config,
|
||||||
|
entities as alexa_entities,
|
||||||
|
errors as alexa_errors,
|
||||||
|
state_report as alexa_state_report,
|
||||||
|
)
|
||||||
from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES
|
from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES
|
||||||
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import entity_registry
|
from homeassistant.helpers import entity_registry
|
||||||
from homeassistant.helpers.event import async_call_later
|
from homeassistant.helpers.event import async_call_later
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
from homeassistant.components.alexa import (
|
|
||||||
config as alexa_config,
|
|
||||||
errors as alexa_errors,
|
|
||||||
entities as alexa_entities,
|
|
||||||
state_report as alexa_state_report,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_ENTITY_CONFIG,
|
CONF_ENTITY_CONFIG,
|
||||||
CONF_FILTER,
|
CONF_FILTER,
|
||||||
PREF_SHOULD_EXPOSE,
|
|
||||||
DEFAULT_SHOULD_EXPOSE,
|
DEFAULT_SHOULD_EXPOSE,
|
||||||
|
PREF_SHOULD_EXPOSE,
|
||||||
RequireRelink,
|
RequireRelink,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
|
||||||
from .const import DISPATCHER_REMOTE_UPDATE, DOMAIN
|
from .const import DISPATCHER_REMOTE_UPDATE, DOMAIN
|
||||||
|
|
||||||
|
|
||||||
WAIT_UNTIL_CHANGE = 3
|
WAIT_UNTIL_CHANGE = 3
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,26 @@
|
||||||
"""Interface implementation for cloud client."""
|
"""Interface implementation for cloud client."""
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
import logging
|
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from hass_nabucasa.client import CloudClient as Interface
|
from hass_nabucasa.client import CloudClient as Interface
|
||||||
|
|
||||||
from homeassistant.core import callback, Context
|
|
||||||
from homeassistant.components.google_assistant import smart_home as ga
|
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
|
||||||
from homeassistant.util.aiohttp import MockRequest
|
|
||||||
from homeassistant.components.alexa import (
|
from homeassistant.components.alexa import (
|
||||||
smart_home as alexa_sh,
|
|
||||||
errors as alexa_errors,
|
errors as alexa_errors,
|
||||||
|
smart_home as alexa_sh,
|
||||||
)
|
)
|
||||||
|
from homeassistant.components.google_assistant import smart_home as ga
|
||||||
|
from homeassistant.core import Context, callback
|
||||||
|
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||||
|
from homeassistant.helpers.typing import HomeAssistantType
|
||||||
|
from homeassistant.util.aiohttp import MockRequest
|
||||||
|
|
||||||
from . import utils, alexa_config, google_config
|
from . import alexa_config, google_config, utils
|
||||||
from .const import DISPATCHER_REMOTE_UPDATE
|
from .const import DISPATCHER_REMOTE_UPDATE
|
||||||
from .prefs import CloudPreferences
|
from .prefs import CloudPreferences
|
||||||
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,16 +5,16 @@ import logging
|
||||||
import async_timeout
|
import async_timeout
|
||||||
from hass_nabucasa.google_report_state import ErrorResponse
|
from hass_nabucasa.google_report_state import ErrorResponse
|
||||||
|
|
||||||
from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES
|
|
||||||
from homeassistant.components.google_assistant.helpers import AbstractConfig
|
from homeassistant.components.google_assistant.helpers import AbstractConfig
|
||||||
|
from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES
|
||||||
from homeassistant.helpers import entity_registry
|
from homeassistant.helpers import entity_registry
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
PREF_SHOULD_EXPOSE,
|
|
||||||
DEFAULT_SHOULD_EXPOSE,
|
|
||||||
CONF_ENTITY_CONFIG,
|
CONF_ENTITY_CONFIG,
|
||||||
PREF_DISABLE_2FA,
|
|
||||||
DEFAULT_DISABLE_2FA,
|
DEFAULT_DISABLE_2FA,
|
||||||
|
DEFAULT_SHOULD_EXPOSE,
|
||||||
|
PREF_DISABLE_2FA,
|
||||||
|
PREF_SHOULD_EXPOSE,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
|
@ -2,31 +2,31 @@
|
||||||
from ipaddress import ip_address
|
from ipaddress import ip_address
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from homeassistant.core import callback
|
|
||||||
from homeassistant.auth.models import User
|
|
||||||
from homeassistant.auth.const import GROUP_ID_ADMIN
|
from homeassistant.auth.const import GROUP_ID_ADMIN
|
||||||
|
from homeassistant.auth.models import User
|
||||||
|
from homeassistant.core import callback
|
||||||
from homeassistant.util.logging import async_create_catching_coro
|
from homeassistant.util.logging import async_create_catching_coro
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
|
DEFAULT_ALEXA_REPORT_STATE,
|
||||||
|
DEFAULT_GOOGLE_REPORT_STATE,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
PREF_ALEXA_ENTITY_CONFIGS,
|
||||||
|
PREF_ALEXA_REPORT_STATE,
|
||||||
|
PREF_ALIASES,
|
||||||
|
PREF_CLOUD_USER,
|
||||||
|
PREF_CLOUDHOOKS,
|
||||||
|
PREF_DISABLE_2FA,
|
||||||
PREF_ENABLE_ALEXA,
|
PREF_ENABLE_ALEXA,
|
||||||
PREF_ENABLE_GOOGLE,
|
PREF_ENABLE_GOOGLE,
|
||||||
PREF_ENABLE_REMOTE,
|
PREF_ENABLE_REMOTE,
|
||||||
PREF_GOOGLE_SECURE_DEVICES_PIN,
|
|
||||||
PREF_CLOUDHOOKS,
|
|
||||||
PREF_CLOUD_USER,
|
|
||||||
PREF_GOOGLE_ENTITY_CONFIGS,
|
PREF_GOOGLE_ENTITY_CONFIGS,
|
||||||
PREF_OVERRIDE_NAME,
|
|
||||||
PREF_DISABLE_2FA,
|
|
||||||
PREF_ALIASES,
|
|
||||||
PREF_SHOULD_EXPOSE,
|
|
||||||
PREF_ALEXA_ENTITY_CONFIGS,
|
|
||||||
PREF_ALEXA_REPORT_STATE,
|
|
||||||
PREF_USERNAME,
|
|
||||||
DEFAULT_ALEXA_REPORT_STATE,
|
|
||||||
PREF_GOOGLE_REPORT_STATE,
|
|
||||||
PREF_GOOGLE_LOCAL_WEBHOOK_ID,
|
PREF_GOOGLE_LOCAL_WEBHOOK_ID,
|
||||||
DEFAULT_GOOGLE_REPORT_STATE,
|
PREF_GOOGLE_REPORT_STATE,
|
||||||
|
PREF_GOOGLE_SECURE_DEVICES_PIN,
|
||||||
|
PREF_OVERRIDE_NAME,
|
||||||
|
PREF_SHOULD_EXPOSE,
|
||||||
|
PREF_USERNAME,
|
||||||
InvalidTrustedNetworks,
|
InvalidTrustedNetworks,
|
||||||
InvalidTrustedProxies,
|
InvalidTrustedProxies,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for the cloud for text to speech service."""
|
"""Support for the cloud for text to speech service."""
|
||||||
|
|
||||||
from hass_nabucasa.voice import VoiceError
|
|
||||||
from hass_nabucasa import Cloud
|
from hass_nabucasa import Cloud
|
||||||
|
from hass_nabucasa.voice import VoiceError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.tts import CONF_LANG, PLATFORM_SCHEMA, Provider
|
from homeassistant.components.tts import CONF_LANG, PLATFORM_SCHEMA, Provider
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Helper functions for cloud components."""
|
"""Helper functions for cloud components."""
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
from aiohttp import web, payload
|
from aiohttp import payload, web
|
||||||
|
|
||||||
|
|
||||||
def aiohttp_serialize_response(response: web.Response) -> Dict[str, Any]:
|
def aiohttp_serialize_response(response: web.Response) -> Dict[str, Any]:
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
"""Tests for the cloud component."""
|
"""Tests for the cloud component."""
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
from homeassistant.components import cloud
|
from homeassistant.components import cloud
|
||||||
from homeassistant.components.cloud import const
|
from homeassistant.components.cloud import const
|
||||||
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import mock_coro
|
from tests.common import mock_coro
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,12 @@ from unittest.mock import Mock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import data_entry_flow, config_entries
|
from homeassistant import config_entries, data_entry_flow
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
|
||||||
from homeassistant.components.cloud import account_link
|
from homeassistant.components.cloud import account_link
|
||||||
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.util.dt import utcnow
|
||||||
from tests.common import mock_coro, async_fire_time_changed, mock_platform
|
|
||||||
|
|
||||||
|
from tests.common import async_fire_time_changed, mock_coro, mock_platform
|
||||||
|
|
||||||
TEST_DOMAIN = "oauth2_test"
|
TEST_DOMAIN = "oauth2_test"
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
"""Test Alexa config."""
|
"""Test Alexa config."""
|
||||||
import contextlib
|
import contextlib
|
||||||
from unittest.mock import patch, Mock
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
from homeassistant.components.cloud import ALEXA_SCHEMA, alexa_config
|
from homeassistant.components.cloud import ALEXA_SCHEMA, alexa_config
|
||||||
from homeassistant.util.dt import utcnow
|
|
||||||
from homeassistant.helpers.entity_registry import EVENT_ENTITY_REGISTRY_UPDATED
|
from homeassistant.helpers.entity_registry import EVENT_ENTITY_REGISTRY_UPDATED
|
||||||
from tests.common import mock_coro, async_fire_time_changed
|
from homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
|
from tests.common import async_fire_time_changed, mock_coro
|
||||||
|
|
||||||
|
|
||||||
async def test_alexa_config_expose_entity_prefs(hass, cloud_prefs):
|
async def test_alexa_config_expose_entity_prefs(hass, cloud_prefs):
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
"""Tests for the cloud binary sensor."""
|
"""Tests for the cloud binary sensor."""
|
||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
|
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
from homeassistant.components.cloud.const import DISPATCHER_REMOTE_UPDATE
|
from homeassistant.components.cloud.const import DISPATCHER_REMOTE_UPDATE
|
||||||
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
|
|
||||||
async def test_remote_connection_sensor(hass):
|
async def test_remote_connection_sensor(hass):
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
"""Test the cloud.iot module."""
|
"""Test the cloud.iot module."""
|
||||||
from unittest.mock import patch, MagicMock
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.core import State
|
|
||||||
from homeassistant.setup import async_setup_component
|
|
||||||
from homeassistant.components.cloud import DOMAIN
|
from homeassistant.components.cloud import DOMAIN
|
||||||
from homeassistant.components.cloud.client import CloudClient
|
from homeassistant.components.cloud.client import CloudClient
|
||||||
from homeassistant.components.cloud.const import PREF_ENABLE_ALEXA, PREF_ENABLE_GOOGLE
|
from homeassistant.components.cloud.const import PREF_ENABLE_ALEXA, PREF_ENABLE_GOOGLE
|
||||||
from tests.components.alexa import test_smart_home as test_alexa
|
from homeassistant.core import State
|
||||||
from tests.common import mock_coro
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from . import mock_cloud_prefs, mock_cloud
|
from . import mock_cloud, mock_cloud_prefs
|
||||||
|
|
||||||
|
from tests.common import mock_coro
|
||||||
|
from tests.components.alexa import test_smart_home as test_alexa
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
"""Test the Cloud Google Config."""
|
"""Test the Cloud Google Config."""
|
||||||
from unittest.mock import patch, Mock
|
from unittest.mock import Mock, patch
|
||||||
|
|
||||||
from homeassistant.components.google_assistant import helpers as ga_helpers
|
|
||||||
from homeassistant.components.cloud import GACTIONS_SCHEMA
|
from homeassistant.components.cloud import GACTIONS_SCHEMA
|
||||||
from homeassistant.components.cloud.google_config import CloudGoogleConfig
|
from homeassistant.components.cloud.google_config import CloudGoogleConfig
|
||||||
from homeassistant.util.dt import utcnow
|
from homeassistant.components.google_assistant import helpers as ga_helpers
|
||||||
from homeassistant.helpers.entity_registry import EVENT_ENTITY_REGISTRY_UPDATED
|
from homeassistant.helpers.entity_registry import EVENT_ENTITY_REGISTRY_UPDATED
|
||||||
|
from homeassistant.util.dt import utcnow
|
||||||
|
|
||||||
from tests.common import mock_coro, async_fire_time_changed
|
from tests.common import async_fire_time_changed, mock_coro
|
||||||
|
|
||||||
|
|
||||||
async def test_google_update_report_state(hass, cloud_prefs):
|
async def test_google_update_report_state(hass, cloud_prefs):
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
"""Tests for the HTTP API for the cloud component."""
|
"""Tests for the HTTP API for the cloud component."""
|
||||||
import asyncio
|
import asyncio
|
||||||
from unittest.mock import patch, MagicMock
|
|
||||||
from ipaddress import ip_network
|
from ipaddress import ip_network
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
import pytest
|
from hass_nabucasa import thingtalk
|
||||||
from jose import jwt
|
|
||||||
from hass_nabucasa.auth import Unauthenticated, UnknownError
|
from hass_nabucasa.auth import Unauthenticated, UnknownError
|
||||||
from hass_nabucasa.const import STATE_CONNECTED
|
from hass_nabucasa.const import STATE_CONNECTED
|
||||||
from hass_nabucasa import thingtalk
|
from jose import jwt
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.core import State
|
|
||||||
from homeassistant.auth.providers import trusted_networks as tn_auth
|
from homeassistant.auth.providers import trusted_networks as tn_auth
|
||||||
|
from homeassistant.components.alexa import errors as alexa_errors
|
||||||
|
from homeassistant.components.alexa.entities import LightCapabilities
|
||||||
from homeassistant.components.cloud.const import DOMAIN, RequireRelink
|
from homeassistant.components.cloud.const import DOMAIN, RequireRelink
|
||||||
from homeassistant.components.google_assistant.helpers import GoogleEntity
|
from homeassistant.components.google_assistant.helpers import GoogleEntity
|
||||||
from homeassistant.components.alexa.entities import LightCapabilities
|
from homeassistant.core import State
|
||||||
from homeassistant.components.alexa import errors as alexa_errors
|
|
||||||
|
from . import mock_cloud, mock_cloud_prefs
|
||||||
|
|
||||||
from tests.common import mock_coro
|
from tests.common import mock_coro
|
||||||
from tests.components.google_assistant import MockConfig
|
from tests.components.google_assistant import MockConfig
|
||||||
|
|
||||||
from . import mock_cloud, mock_cloud_prefs
|
|
||||||
|
|
||||||
GOOGLE_ACTIONS_SYNC_URL = "https://api-test.hass.io/google_actions_sync"
|
GOOGLE_ACTIONS_SYNC_URL = "https://api-test.hass.io/google_actions_sync"
|
||||||
SUBSCRIPTION_INFO_URL = "https://api-test.hass.io/subscription_info"
|
SUBSCRIPTION_INFO_URL = "https://api-test.hass.io/subscription_info"
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,14 @@ from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.core import Context
|
|
||||||
from homeassistant.exceptions import Unauthorized
|
|
||||||
from homeassistant.components import cloud
|
from homeassistant.components import cloud
|
||||||
from homeassistant.components.cloud.const import DOMAIN
|
from homeassistant.components.cloud.const import DOMAIN
|
||||||
from homeassistant.components.cloud.prefs import STORAGE_KEY
|
from homeassistant.components.cloud.prefs import STORAGE_KEY
|
||||||
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
||||||
|
from homeassistant.core import Context
|
||||||
|
from homeassistant.exceptions import Unauthorized
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.common import mock_coro
|
from tests.common import mock_coro
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from homeassistant.auth.const import GROUP_ID_ADMIN
|
from homeassistant.auth.const import GROUP_ID_ADMIN
|
||||||
from homeassistant.components.cloud.prefs import CloudPreferences, STORAGE_KEY
|
from homeassistant.components.cloud.prefs import STORAGE_KEY, CloudPreferences
|
||||||
|
|
||||||
|
|
||||||
async def test_set_username(hass):
|
async def test_set_username(hass):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue