Sort imports according to PEP8 for 'tests' (#29791)
This commit is contained in:
committed by
Franck Nijhof
parent
67c56c860d
commit
f60125b5c9
@@ -6,8 +6,8 @@ import aiohttp
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import EVENT_HOMEASSISTANT_CLOSE
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.helpers.aiohttp_client as client
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.async_ import run_callback_threadsafe
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
|
||||
@@ -6,7 +6,8 @@ import pytest
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import area_registry
|
||||
from tests.common import mock_area_registry, flush_store
|
||||
|
||||
from tests.common import flush_store, mock_area_registry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
import logging
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.helpers.check_config import (
|
||||
async_check_ha_config_file,
|
||||
CheckConfigError,
|
||||
)
|
||||
from homeassistant.config import YAML_CONFIG_FILE
|
||||
from homeassistant.helpers.check_config import (
|
||||
CheckConfigError,
|
||||
async_check_ha_config_file,
|
||||
)
|
||||
|
||||
from tests.common import patch_yaml_files
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
"""Tests for the Config Entry Flow helper."""
|
||||
from unittest.mock import patch, Mock
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow, setup
|
||||
from homeassistant.helpers import config_entry_flow
|
||||
|
||||
from tests.common import (
|
||||
MockConfigEntry,
|
||||
MockModule,
|
||||
mock_coro,
|
||||
mock_integration,
|
||||
mock_entity_platform,
|
||||
mock_integration,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
"""Tests for the Somfy config flow."""
|
||||
import asyncio
|
||||
import logging
|
||||
from unittest.mock import patch
|
||||
import time
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant import data_entry_flow, setup, config_entries
|
||||
from homeassistant import config_entries, data_entry_flow, setup
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from tests.common import mock_platform, MockConfigEntry
|
||||
from tests.common import MockConfigEntry, mock_platform
|
||||
|
||||
TEST_DOMAIN = "oauth2_test"
|
||||
CLIENT_SECRET = "5678"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Test deprecation helpers."""
|
||||
from homeassistant.helpers.deprecation import deprecated_substitute, get_deprecated
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from unittest.mock import patch, MagicMock
|
||||
from homeassistant.helpers.deprecation import deprecated_substitute, get_deprecated
|
||||
|
||||
|
||||
class MockBaseClass:
|
||||
|
||||
@@ -7,7 +7,8 @@ import pytest
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import device_registry
|
||||
from tests.common import mock_device_registry, flush_store
|
||||
|
||||
from tests.common import flush_store, mock_device_registry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -9,12 +9,12 @@ from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import discovery
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant,
|
||||
MockModule,
|
||||
MockPlatform,
|
||||
get_test_home_assistant,
|
||||
mock_coro,
|
||||
mock_integration,
|
||||
mock_entity_platform,
|
||||
mock_integration,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import asyncio
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import (
|
||||
async_dispatcher_connect,
|
||||
dispatcher_send,
|
||||
dispatcher_connect,
|
||||
dispatcher_send,
|
||||
)
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
"""Test the entity helper."""
|
||||
# pylint: disable=protected-access
|
||||
import asyncio
|
||||
import threading
|
||||
from datetime import timedelta
|
||||
from unittest.mock import MagicMock, patch, PropertyMock
|
||||
import threading
|
||||
from unittest.mock import MagicMock, PropertyMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.helpers import entity, entity_registry
|
||||
from homeassistant.core import Context
|
||||
from homeassistant.const import ATTR_HIDDEN, ATTR_DEVICE_CLASS, STATE_UNAVAILABLE
|
||||
from homeassistant.config import DATA_CUSTOMIZE
|
||||
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_HIDDEN, STATE_UNAVAILABLE
|
||||
from homeassistant.core import Context
|
||||
from homeassistant.helpers import entity, entity_registry
|
||||
from homeassistant.helpers.entity_values import EntityValues
|
||||
|
||||
from tests.common import get_test_home_assistant, mock_registry
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
"""The tests for the Entity component helper."""
|
||||
# pylint: disable=protected-access
|
||||
from collections import OrderedDict
|
||||
import logging
|
||||
from unittest.mock import patch, Mock
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import asynctest
|
||||
import pytest
|
||||
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.const import ENTITY_MATCH_ALL
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
from homeassistant.components import group
|
||||
from homeassistant.const import ENTITY_MATCH_ALL
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
from homeassistant.helpers import discovery
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from homeassistant.helpers import discovery
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import (
|
||||
MockPlatform,
|
||||
MockModule,
|
||||
mock_coro,
|
||||
async_fire_time_changed,
|
||||
MockEntity,
|
||||
MockConfigEntry,
|
||||
MockEntity,
|
||||
MockModule,
|
||||
MockPlatform,
|
||||
async_fire_time_changed,
|
||||
mock_coro,
|
||||
mock_entity_platform,
|
||||
mock_integration,
|
||||
)
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
"""Tests for the EntityPlatform helper."""
|
||||
import asyncio
|
||||
import logging
|
||||
from unittest.mock import patch, Mock, MagicMock
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from unittest.mock import MagicMock, Mock, patch
|
||||
|
||||
import asynctest
|
||||
import pytest
|
||||
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
from homeassistant.helpers import entity_platform, entity_registry
|
||||
from homeassistant.helpers.entity import async_generate_entity_id
|
||||
from homeassistant.helpers.entity_component import (
|
||||
EntityComponent,
|
||||
DEFAULT_SCAN_INTERVAL,
|
||||
EntityComponent,
|
||||
)
|
||||
from homeassistant.helpers import entity_platform, entity_registry
|
||||
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import (
|
||||
MockPlatform,
|
||||
async_fire_time_changed,
|
||||
mock_registry,
|
||||
MockConfigEntry,
|
||||
MockEntity,
|
||||
MockEntityPlatform,
|
||||
MockConfigEntry,
|
||||
MockPlatform,
|
||||
async_fire_time_changed,
|
||||
mock_entity_platform,
|
||||
mock_registry,
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -5,11 +5,10 @@ from unittest.mock import patch
|
||||
import asynctest
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import valid_entity_id, callback
|
||||
from homeassistant.core import callback, valid_entity_id
|
||||
from homeassistant.helpers import entity_registry
|
||||
|
||||
from tests.common import MockConfigEntry, mock_registry, flush_store
|
||||
|
||||
from tests.common import MockConfigEntry, flush_store, mock_registry
|
||||
|
||||
YAML__OPEN_PATH = "homeassistant.util.yaml.loader.open"
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""Test the entity values helper."""
|
||||
from collections import OrderedDict
|
||||
|
||||
from homeassistant.helpers.entity_values import EntityValues as EV
|
||||
|
||||
ent = "test.test"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""The tests for the EntityFilter component."""
|
||||
from homeassistant.helpers.entityfilter import generate_filter, FILTER_SCHEMA
|
||||
from homeassistant.helpers.entityfilter import FILTER_SCHEMA, generate_filter
|
||||
|
||||
|
||||
def test_no_filters_case_1():
|
||||
|
||||
@@ -7,10 +7,10 @@ from unittest.mock import patch
|
||||
from astral import Astral
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.components import sun
|
||||
from homeassistant.const import MATCH_ALL
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.event import (
|
||||
async_call_later,
|
||||
async_track_point_in_time,
|
||||
@@ -25,7 +25,7 @@ from homeassistant.helpers.event import (
|
||||
async_track_utc_time_change,
|
||||
)
|
||||
from homeassistant.helpers.template import Template
|
||||
from homeassistant.components import sun
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
"""Tests for the intent helpers."""
|
||||
|
||||
import pytest
|
||||
import voluptuous as vol
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import State
|
||||
from homeassistant.helpers import intent, config_validation as cv
|
||||
from homeassistant.helpers import config_validation as cv, intent
|
||||
|
||||
|
||||
class MockIntentHandler(intent.IntentHandler):
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Test network helper."""
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from homeassistant.helpers import network
|
||||
from homeassistant.components import cloud
|
||||
from homeassistant.helpers import network
|
||||
|
||||
|
||||
async def test_get_external_url(hass):
|
||||
|
||||
@@ -8,15 +8,14 @@ from homeassistant.core import CoreState, State
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.restore_state import (
|
||||
RestoreStateData,
|
||||
RestoreEntity,
|
||||
StoredState,
|
||||
DATA_RESTORE_STATE_TASK,
|
||||
STORAGE_KEY,
|
||||
RestoreEntity,
|
||||
RestoreStateData,
|
||||
StoredState,
|
||||
)
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
|
||||
from tests.common import mock_coro
|
||||
|
||||
|
||||
|
||||
@@ -6,21 +6,19 @@ from unittest import mock
|
||||
|
||||
import asynctest
|
||||
import jinja2
|
||||
import voluptuous as vol
|
||||
import pytest
|
||||
|
||||
import homeassistant.components.scene as scene
|
||||
from homeassistant import exceptions
|
||||
from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_ON
|
||||
from homeassistant.core import Context, callback
|
||||
import voluptuous as vol
|
||||
|
||||
# Otherwise can't test just this file (import order issue)
|
||||
from homeassistant import exceptions
|
||||
import homeassistant.components.scene as scene
|
||||
from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_ON
|
||||
from homeassistant.core import Context, callback
|
||||
from homeassistant.helpers import config_validation as cv, script
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.helpers import script, config_validation as cv
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
|
||||
ENTITY_ID = "script.test"
|
||||
|
||||
|
||||
|
||||
@@ -5,28 +5,29 @@ from copy import deepcopy
|
||||
import unittest
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import voluptuous as vol
|
||||
import pytest
|
||||
import voluptuous as vol
|
||||
|
||||
# To prevent circular import when running just this file
|
||||
import homeassistant.components # noqa: F401
|
||||
from homeassistant import core as ha, exceptions
|
||||
from homeassistant.const import STATE_ON, STATE_OFF, ATTR_ENTITY_ID, ENTITY_MATCH_ALL
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.auth.permissions import PolicyPermissions
|
||||
import homeassistant.components # noqa: F401
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ENTITY_MATCH_ALL, STATE_OFF, STATE_ON
|
||||
from homeassistant.helpers import (
|
||||
service,
|
||||
template,
|
||||
device_registry as dev_reg,
|
||||
entity_registry as ent_reg,
|
||||
service,
|
||||
template,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant,
|
||||
mock_service,
|
||||
mock_coro,
|
||||
mock_registry,
|
||||
mock_device_registry,
|
||||
mock_registry,
|
||||
mock_service,
|
||||
)
|
||||
|
||||
|
||||
|
||||
+15
-14
@@ -5,21 +5,22 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.const import SERVICE_TURN_ON, SERVICE_TURN_OFF
|
||||
from homeassistant.util import dt as dt_util
|
||||
from homeassistant.helpers import state
|
||||
from homeassistant.const import (
|
||||
STATE_OPEN,
|
||||
STATE_CLOSED,
|
||||
STATE_LOCKED,
|
||||
STATE_UNLOCKED,
|
||||
STATE_ON,
|
||||
STATE_OFF,
|
||||
STATE_HOME,
|
||||
STATE_NOT_HOME,
|
||||
)
|
||||
from homeassistant.components.sun import STATE_ABOVE_HORIZON, STATE_BELOW_HORIZON
|
||||
from homeassistant.const import (
|
||||
SERVICE_TURN_OFF,
|
||||
SERVICE_TURN_ON,
|
||||
STATE_CLOSED,
|
||||
STATE_HOME,
|
||||
STATE_LOCKED,
|
||||
STATE_NOT_HOME,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
STATE_OPEN,
|
||||
STATE_UNLOCKED,
|
||||
)
|
||||
import homeassistant.core as ha
|
||||
from homeassistant.helpers import state
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from tests.common import async_mock_service
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import asyncio
|
||||
from datetime import timedelta
|
||||
import json
|
||||
from unittest.mock import patch, Mock
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -12,7 +12,6 @@ from homeassistant.util import dt
|
||||
|
||||
from tests.common import async_fire_time_changed, mock_coro
|
||||
|
||||
|
||||
MOCK_VERSION = 1
|
||||
MOCK_KEY = "storage-test"
|
||||
MOCK_DATA = {"hello": "world"}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"""The tests for the Sun helpers."""
|
||||
# pylint: disable=protected-access
|
||||
from datetime import datetime, timedelta
|
||||
from unittest.mock import patch
|
||||
from datetime import timedelta, datetime
|
||||
|
||||
from homeassistant.const import SUN_EVENT_SUNRISE, SUN_EVENT_SUNSET
|
||||
import homeassistant.util.dt as dt_util
|
||||
import homeassistant.helpers.sun as sun
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
|
||||
def test_next_events(hass):
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
import pytest
|
||||
|
||||
from homeassistant.const import (
|
||||
TEMP_CELSIUS,
|
||||
PRECISION_WHOLE,
|
||||
TEMP_FAHRENHEIT,
|
||||
PRECISION_HALVES,
|
||||
PRECISION_TENTHS,
|
||||
PRECISION_WHOLE,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
)
|
||||
from homeassistant.helpers.temperature import display_temp
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
"""Test Home Assistant template helper methods."""
|
||||
from datetime import datetime
|
||||
import math
|
||||
import random
|
||||
from datetime import datetime
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
import pytz
|
||||
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.components import group
|
||||
from homeassistant.const import (
|
||||
LENGTH_METERS,
|
||||
@@ -19,6 +18,7 @@ from homeassistant.const import (
|
||||
)
|
||||
from homeassistant.exceptions import TemplateError
|
||||
from homeassistant.helpers import template
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.util.unit_system import UnitSystem
|
||||
|
||||
|
||||
|
||||
@@ -5,9 +5,10 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.generated import config_flows
|
||||
import homeassistant.helpers.translation as translation
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.generated import config_flows
|
||||
|
||||
from tests.common import mock_coro
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user