From a809e18559ab345733e127c6a6624dc0437e3350 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 19 Sep 2022 09:31:57 +0200 Subject: [PATCH] Apply hass-relative-import to tests (d-h) (#78730) --- tests/components/dexcom/test_config_flow.py | 3 ++- tests/components/dexcom/test_init.py | 3 ++- tests/components/dexcom/test_sensor.py | 2 +- tests/components/directv/test_config_flow.py | 3 ++- tests/components/directv/test_init.py | 3 ++- tests/components/directv/test_media_player.py | 3 ++- tests/components/directv/test_remote.py | 3 ++- tests/components/elmax/conftest.py | 3 ++- tests/components/elmax/test_config_flow.py | 5 +++-- tests/components/freedompro/conftest.py | 3 ++- tests/components/freedompro/test_binary_sensor.py | 3 ++- tests/components/freedompro/test_climate.py | 3 ++- tests/components/freedompro/test_config_flow.py | 2 +- tests/components/freedompro/test_cover.py | 3 ++- tests/components/freedompro/test_fan.py | 3 ++- tests/components/freedompro/test_lock.py | 3 ++- tests/components/freedompro/test_sensor.py | 3 ++- tests/components/freedompro/test_switch.py | 3 ++- tests/components/gdacs/test_geo_location.py | 3 ++- tests/components/gdacs/test_sensor.py | 3 ++- tests/components/geonetnz_quakes/test_geo_location.py | 3 ++- tests/components/geonetnz_quakes/test_sensor.py | 3 ++- tests/components/geonetnz_volcano/test_sensor.py | 3 ++- tests/components/gios/test_config_flow.py | 3 ++- tests/components/gios/test_diagnostics.py | 3 ++- tests/components/gios/test_init.py | 3 +-- tests/components/gios/test_sensor.py | 3 ++- tests/components/google_travel_time/test_config_flow.py | 2 +- tests/components/group/test_init.py | 3 ++- tests/components/home_plus_control/test_config_flow.py | 7 ++----- tests/components/home_plus_control/test_init.py | 6 +----- tests/components/home_plus_control/test_switch.py | 7 ++----- tests/components/huisbaasje/test_init.py | 3 ++- tests/components/huisbaasje/test_sensor.py | 6 ++---- 34 files changed, 64 insertions(+), 51 deletions(-) diff --git a/tests/components/dexcom/test_config_flow.py b/tests/components/dexcom/test_config_flow.py index b20321277fb..471c71acaba 100644 --- a/tests/components/dexcom/test_config_flow.py +++ b/tests/components/dexcom/test_config_flow.py @@ -7,8 +7,9 @@ from homeassistant import config_entries, data_entry_flow from homeassistant.components.dexcom.const import DOMAIN, MG_DL, MMOL_L from homeassistant.const import CONF_UNIT_OF_MEASUREMENT, CONF_USERNAME +from . import CONFIG + from tests.common import MockConfigEntry -from tests.components.dexcom import CONFIG async def test_form(hass): diff --git a/tests/components/dexcom/test_init.py b/tests/components/dexcom/test_init.py index 2509ba25f33..79727f79ff6 100644 --- a/tests/components/dexcom/test_init.py +++ b/tests/components/dexcom/test_init.py @@ -6,8 +6,9 @@ from pydexcom import AccountError, SessionError from homeassistant.components.dexcom.const import DOMAIN from homeassistant.config_entries import ConfigEntryState +from . import CONFIG, init_integration + from tests.common import MockConfigEntry -from tests.components.dexcom import CONFIG, init_integration async def test_setup_entry_account_error(hass): diff --git a/tests/components/dexcom/test_sensor.py b/tests/components/dexcom/test_sensor.py index ff1256a9bc0..95d3b2f51a5 100644 --- a/tests/components/dexcom/test_sensor.py +++ b/tests/components/dexcom/test_sensor.py @@ -12,7 +12,7 @@ from homeassistant.const import ( ) from homeassistant.helpers.entity_component import async_update_entity -from tests.components.dexcom import GLUCOSE_READING, init_integration +from . import GLUCOSE_READING, init_integration async def test_sensors(hass): diff --git a/tests/components/directv/test_config_flow.py b/tests/components/directv/test_config_flow.py index 7ef6bdde69d..8017dc290c9 100644 --- a/tests/components/directv/test_config_flow.py +++ b/tests/components/directv/test_config_flow.py @@ -11,7 +11,7 @@ from homeassistant.const import CONF_HOST, CONF_NAME, CONF_SOURCE from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType -from tests.components.directv import ( +from . import ( HOST, MOCK_SSDP_DISCOVERY_INFO, MOCK_USER_INPUT, @@ -20,6 +20,7 @@ from tests.components.directv import ( mock_connection, setup_integration, ) + from tests.test_util.aiohttp import AiohttpClientMocker diff --git a/tests/components/directv/test_init.py b/tests/components/directv/test_init.py index 3ef151f4257..cdfc9b1bcad 100644 --- a/tests/components/directv/test_init.py +++ b/tests/components/directv/test_init.py @@ -3,7 +3,8 @@ from homeassistant.components.directv.const import DOMAIN from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant -from tests.components.directv import setup_integration +from . import setup_integration + from tests.test_util.aiohttp import AiohttpClientMocker # pylint: disable=redefined-outer-name diff --git a/tests/components/directv/test_media_player.py b/tests/components/directv/test_media_player.py index cfade8bc4e7..1c03758af72 100644 --- a/tests/components/directv/test_media_player.py +++ b/tests/components/directv/test_media_player.py @@ -58,7 +58,8 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er from homeassistant.util import dt as dt_util -from tests.components.directv import setup_integration +from . import setup_integration + from tests.test_util.aiohttp import AiohttpClientMocker ATTR_UNIQUE_ID = "unique_id" diff --git a/tests/components/directv/test_remote.py b/tests/components/directv/test_remote.py index 37eec1324c0..1dcd6c88047 100644 --- a/tests/components/directv/test_remote.py +++ b/tests/components/directv/test_remote.py @@ -10,7 +10,8 @@ from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_OFF, SERVICE_TURN_O from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er -from tests.components.directv import setup_integration +from . import setup_integration + from tests.test_util.aiohttp import AiohttpClientMocker ATTR_UNIQUE_ID = "unique_id" diff --git a/tests/components/elmax/conftest.py b/tests/components/elmax/conftest.py index 17ad58b6292..70e3af76702 100644 --- a/tests/components/elmax/conftest.py +++ b/tests/components/elmax/conftest.py @@ -11,8 +11,9 @@ from httpx import Response import pytest import respx +from . import MOCK_PANEL_ID, MOCK_PANEL_PIN + from tests.common import load_fixture -from tests.components.elmax import MOCK_PANEL_ID, MOCK_PANEL_PIN @pytest.fixture(autouse=True) diff --git a/tests/components/elmax/test_config_flow.py b/tests/components/elmax/test_config_flow.py index e4e9889aadd..c2c91bc5a35 100644 --- a/tests/components/elmax/test_config_flow.py +++ b/tests/components/elmax/test_config_flow.py @@ -14,8 +14,7 @@ from homeassistant.components.elmax.const import ( ) from homeassistant.config_entries import SOURCE_REAUTH -from tests.common import MockConfigEntry -from tests.components.elmax import ( +from . import ( MOCK_PANEL_ID, MOCK_PANEL_NAME, MOCK_PANEL_PIN, @@ -23,6 +22,8 @@ from tests.components.elmax import ( MOCK_USERNAME, ) +from tests.common import MockConfigEntry + CONF_POLLING = "polling" diff --git a/tests/components/freedompro/conftest.py b/tests/components/freedompro/conftest.py index 804dc6d1933..bc3d7311058 100644 --- a/tests/components/freedompro/conftest.py +++ b/tests/components/freedompro/conftest.py @@ -9,8 +9,9 @@ import pytest from homeassistant.components.freedompro.const import DOMAIN +from .const import DEVICES, DEVICES_STATE + from tests.common import MockConfigEntry -from tests.components.freedompro.const import DEVICES, DEVICES_STATE @pytest.fixture(autouse=True) diff --git a/tests/components/freedompro/test_binary_sensor.py b/tests/components/freedompro/test_binary_sensor.py index 459484dbc45..f43857038ef 100644 --- a/tests/components/freedompro/test_binary_sensor.py +++ b/tests/components/freedompro/test_binary_sensor.py @@ -8,8 +8,9 @@ from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.util.dt import utcnow +from .conftest import get_states_response_for_uid + from tests.common import async_fire_time_changed -from tests.components.freedompro.conftest import get_states_response_for_uid @pytest.mark.parametrize( diff --git a/tests/components/freedompro/test_climate.py b/tests/components/freedompro/test_climate.py index 40e68f1e03b..da65abffeed 100644 --- a/tests/components/freedompro/test_climate.py +++ b/tests/components/freedompro/test_climate.py @@ -20,8 +20,9 @@ from homeassistant.const import ATTR_ENTITY_ID from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.util.dt import utcnow +from .conftest import get_states_response_for_uid + from tests.common import async_fire_time_changed -from tests.components.freedompro.conftest import get_states_response_for_uid uid = "3WRRJR6RCZQZSND8VP0YTO3YXCSOFPKBMW8T51TU-LQ*TWMYQKL3UVED4HSIIB9GXJWJZBQCXG-9VE-N2IUAIWI" diff --git a/tests/components/freedompro/test_config_flow.py b/tests/components/freedompro/test_config_flow.py index d1804437a59..d80bd22736c 100644 --- a/tests/components/freedompro/test_config_flow.py +++ b/tests/components/freedompro/test_config_flow.py @@ -6,7 +6,7 @@ from homeassistant.components.freedompro.const import DOMAIN from homeassistant.config_entries import SOURCE_USER from homeassistant.const import CONF_API_KEY -from tests.components.freedompro.const import DEVICES +from .const import DEVICES VALID_CONFIG = { CONF_API_KEY: "ksdjfgslkjdfksjdfksjgfksjd", diff --git a/tests/components/freedompro/test_cover.py b/tests/components/freedompro/test_cover.py index ed14da90789..ecec83cd411 100644 --- a/tests/components/freedompro/test_cover.py +++ b/tests/components/freedompro/test_cover.py @@ -17,8 +17,9 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers.entity_component import async_update_entity from homeassistant.util.dt import utcnow +from .conftest import get_states_response_for_uid + from tests.common import async_fire_time_changed -from tests.components.freedompro.conftest import get_states_response_for_uid @pytest.mark.parametrize( diff --git a/tests/components/freedompro/test_fan.py b/tests/components/freedompro/test_fan.py index 3192398a323..75b798ea13a 100644 --- a/tests/components/freedompro/test_fan.py +++ b/tests/components/freedompro/test_fan.py @@ -13,8 +13,9 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers.entity_component import async_update_entity from homeassistant.util.dt import utcnow +from .conftest import get_states_response_for_uid + from tests.common import async_fire_time_changed -from tests.components.freedompro.conftest import get_states_response_for_uid uid = "3WRRJR6RCZQZSND8VP0YTO3YXCSOFPKBMW8T51TU-LQ*ILYH1E3DWZOVMNEUIMDYMNLOW-LFRQFDPWWJOVHVDOS" diff --git a/tests/components/freedompro/test_lock.py b/tests/components/freedompro/test_lock.py index 44811faffe8..1680b7f4f35 100644 --- a/tests/components/freedompro/test_lock.py +++ b/tests/components/freedompro/test_lock.py @@ -12,8 +12,9 @@ from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers.entity_component import async_update_entity from homeassistant.util.dt import utcnow +from .conftest import get_states_response_for_uid + from tests.common import async_fire_time_changed -from tests.components.freedompro.conftest import get_states_response_for_uid uid = "2WRRJR6RCZQZSND8VP0YTO3YXCSOFPKBMW8T51TU-LQ*2VAS3HTWINNZ5N6HVEIPDJ6NX85P2-AM-GSYWUCNPU0" diff --git a/tests/components/freedompro/test_sensor.py b/tests/components/freedompro/test_sensor.py index d73506e2c6f..0405c5393ce 100644 --- a/tests/components/freedompro/test_sensor.py +++ b/tests/components/freedompro/test_sensor.py @@ -7,8 +7,9 @@ import pytest from homeassistant.helpers import entity_registry as er from homeassistant.util.dt import utcnow +from .conftest import get_states_response_for_uid + from tests.common import async_fire_time_changed -from tests.components.freedompro.conftest import get_states_response_for_uid @pytest.mark.parametrize( diff --git a/tests/components/freedompro/test_switch.py b/tests/components/freedompro/test_switch.py index f71ec4b896f..3e26276282a 100644 --- a/tests/components/freedompro/test_switch.py +++ b/tests/components/freedompro/test_switch.py @@ -8,8 +8,9 @@ from homeassistant.helpers import entity_registry as er from homeassistant.helpers.entity_component import async_update_entity from homeassistant.util.dt import utcnow +from .conftest import get_states_response_for_uid + from tests.common import async_fire_time_changed -from tests.components.freedompro.conftest import get_states_response_for_uid uid = "3WRRJR6RCZQZSND8VP0YTO3YXCSOFPKBMW8T51TU-LQ*1JKU1MVWHQL-Z9SCUS85VFXMRGNDCDNDDUVVDKBU31W" diff --git a/tests/components/gdacs/test_geo_location.py b/tests/components/gdacs/test_geo_location.py index 8fcd5db24a6..d55141ebe56 100644 --- a/tests/components/gdacs/test_geo_location.py +++ b/tests/components/gdacs/test_geo_location.py @@ -36,8 +36,9 @@ from homeassistant.setup import async_setup_component import homeassistant.util.dt as dt_util from homeassistant.util.unit_system import IMPERIAL_SYSTEM +from . import _generate_mock_feed_entry + from tests.common import async_fire_time_changed -from tests.components.gdacs import _generate_mock_feed_entry CONFIG = {gdacs.DOMAIN: {CONF_RADIUS: 200}} diff --git a/tests/components/gdacs/test_sensor.py b/tests/components/gdacs/test_sensor.py index 11898d79877..8aafbcf864e 100644 --- a/tests/components/gdacs/test_sensor.py +++ b/tests/components/gdacs/test_sensor.py @@ -22,8 +22,9 @@ from homeassistant.const import ( from homeassistant.setup import async_setup_component import homeassistant.util.dt as dt_util +from . import _generate_mock_feed_entry + from tests.common import async_fire_time_changed -from tests.components.gdacs import _generate_mock_feed_entry CONFIG = {gdacs.DOMAIN: {CONF_RADIUS: 200}} diff --git a/tests/components/geonetnz_quakes/test_geo_location.py b/tests/components/geonetnz_quakes/test_geo_location.py index 0690da5bf7b..130964b4eeb 100644 --- a/tests/components/geonetnz_quakes/test_geo_location.py +++ b/tests/components/geonetnz_quakes/test_geo_location.py @@ -30,8 +30,9 @@ from homeassistant.setup import async_setup_component import homeassistant.util.dt as dt_util from homeassistant.util.unit_system import IMPERIAL_SYSTEM +from . import _generate_mock_feed_entry + from tests.common import async_fire_time_changed -from tests.components.geonetnz_quakes import _generate_mock_feed_entry CONFIG = {geonetnz_quakes.DOMAIN: {CONF_RADIUS: 200}} diff --git a/tests/components/geonetnz_quakes/test_sensor.py b/tests/components/geonetnz_quakes/test_sensor.py index a88a878a03c..9221c2fe848 100644 --- a/tests/components/geonetnz_quakes/test_sensor.py +++ b/tests/components/geonetnz_quakes/test_sensor.py @@ -23,8 +23,9 @@ from homeassistant.const import ( from homeassistant.setup import async_setup_component import homeassistant.util.dt as dt_util +from . import _generate_mock_feed_entry + from tests.common import async_fire_time_changed -from tests.components.geonetnz_quakes import _generate_mock_feed_entry CONFIG = {geonetnz_quakes.DOMAIN: {CONF_RADIUS: 200}} diff --git a/tests/components/geonetnz_volcano/test_sensor.py b/tests/components/geonetnz_volcano/test_sensor.py index d3d2d5dcc2e..dbb6834c596 100644 --- a/tests/components/geonetnz_volcano/test_sensor.py +++ b/tests/components/geonetnz_volcano/test_sensor.py @@ -25,8 +25,9 @@ from homeassistant.setup import async_setup_component import homeassistant.util.dt as dt_util from homeassistant.util.unit_system import IMPERIAL_SYSTEM +from . import _generate_mock_feed_entry + from tests.common import async_fire_time_changed -from tests.components.geonetnz_volcano import _generate_mock_feed_entry CONFIG = {geonetnz_volcano.DOMAIN: {CONF_RADIUS: 200}} diff --git a/tests/components/gios/test_config_flow.py b/tests/components/gios/test_config_flow.py index 8ebb514a4d3..3a0d57ce0d4 100644 --- a/tests/components/gios/test_config_flow.py +++ b/tests/components/gios/test_config_flow.py @@ -9,8 +9,9 @@ from homeassistant.components.gios import config_flow from homeassistant.components.gios.const import CONF_STATION_ID from homeassistant.const import CONF_NAME +from . import STATIONS + from tests.common import load_fixture -from tests.components.gios import STATIONS CONFIG = { CONF_NAME: "Foo", diff --git a/tests/components/gios/test_diagnostics.py b/tests/components/gios/test_diagnostics.py index e72880feed7..2168457f628 100644 --- a/tests/components/gios/test_diagnostics.py +++ b/tests/components/gios/test_diagnostics.py @@ -1,9 +1,10 @@ """Test GIOS diagnostics.""" import json +from . import init_integration + from tests.common import load_fixture from tests.components.diagnostics import get_diagnostics_for_config_entry -from tests.components.gios import init_integration async def test_entry_diagnostics(hass, hass_client): diff --git a/tests/components/gios/test_init.py b/tests/components/gios/test_init.py index f0b3f660e8d..f3a628160f0 100644 --- a/tests/components/gios/test_init.py +++ b/tests/components/gios/test_init.py @@ -8,10 +8,9 @@ from homeassistant.config_entries import ConfigEntryState from homeassistant.const import STATE_UNAVAILABLE from homeassistant.helpers import entity_registry as er -from . import STATIONS +from . import STATIONS, init_integration from tests.common import MockConfigEntry, load_fixture, mock_device_registry -from tests.components.gios import init_integration async def test_async_setup_entry(hass): diff --git a/tests/components/gios/test_sensor.py b/tests/components/gios/test_sensor.py index 6603f67e359..4cdb7208dd3 100644 --- a/tests/components/gios/test_sensor.py +++ b/tests/components/gios/test_sensor.py @@ -28,8 +28,9 @@ from homeassistant.const import ( from homeassistant.helpers import entity_registry as er from homeassistant.util.dt import utcnow +from . import init_integration + from tests.common import async_fire_time_changed, load_fixture -from tests.components.gios import init_integration async def test_sensor(hass): diff --git a/tests/components/google_travel_time/test_config_flow.py b/tests/components/google_travel_time/test_config_flow.py index 7f6371c1446..4fe5f797d45 100644 --- a/tests/components/google_travel_time/test_config_flow.py +++ b/tests/components/google_travel_time/test_config_flow.py @@ -27,7 +27,7 @@ from homeassistant.const import ( CONF_UNIT_SYSTEM_IMPERIAL, ) -from tests.components.google_travel_time.const import MOCK_CONFIG +from .const import MOCK_CONFIG @pytest.mark.usefixtures("validate_config_entry", "bypass_setup") diff --git a/tests/components/group/test_init.py b/tests/components/group/test_init.py index 945f6555789..ec5732503e8 100644 --- a/tests/components/group/test_init.py +++ b/tests/components/group/test_init.py @@ -26,8 +26,9 @@ from homeassistant.helpers import entity_registry as er from homeassistant.helpers.event import TRACK_STATE_CHANGE_CALLBACKS from homeassistant.setup import async_setup_component +from . import common + from tests.common import MockConfigEntry, assert_setup_component -from tests.components.group import common async def test_setup_group_with_mixed_groupable_states(hass): diff --git a/tests/components/home_plus_control/test_config_flow.py b/tests/components/home_plus_control/test_config_flow.py index e86362c3e11..f4f7e1143a5 100644 --- a/tests/components/home_plus_control/test_config_flow.py +++ b/tests/components/home_plus_control/test_config_flow.py @@ -12,12 +12,9 @@ from homeassistant.components.home_plus_control.const import ( from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET from homeassistant.helpers import config_entry_oauth2_flow +from .conftest import CLIENT_ID, CLIENT_SECRET, SUBSCRIPTION_KEY + from tests.common import MockConfigEntry -from tests.components.home_plus_control.conftest import ( - CLIENT_ID, - CLIENT_SECRET, - SUBSCRIPTION_KEY, -) async def test_full_flow( diff --git a/tests/components/home_plus_control/test_init.py b/tests/components/home_plus_control/test_init.py index 4da913047a2..bed3dcdce18 100644 --- a/tests/components/home_plus_control/test_init.py +++ b/tests/components/home_plus_control/test_init.py @@ -8,11 +8,7 @@ from homeassistant.components.home_plus_control.const import ( ) from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET -from tests.components.home_plus_control.conftest import ( - CLIENT_ID, - CLIENT_SECRET, - SUBSCRIPTION_KEY, -) +from .conftest import CLIENT_ID, CLIENT_SECRET, SUBSCRIPTION_KEY async def test_loading(hass, mock_config_entry): diff --git a/tests/components/home_plus_control/test_switch.py b/tests/components/home_plus_control/test_switch.py index 44a969392bf..f788e7fa4b4 100644 --- a/tests/components/home_plus_control/test_switch.py +++ b/tests/components/home_plus_control/test_switch.py @@ -18,12 +18,9 @@ from homeassistant.const import ( ) from homeassistant.helpers import device_registry as dr, entity_registry as er +from .conftest import CLIENT_ID, CLIENT_SECRET, SUBSCRIPTION_KEY + from tests.common import async_fire_time_changed -from tests.components.home_plus_control.conftest import ( - CLIENT_ID, - CLIENT_SECRET, - SUBSCRIPTION_KEY, -) def entity_assertions( diff --git a/tests/components/huisbaasje/test_init.py b/tests/components/huisbaasje/test_init.py index ba2022f7583..859cfc4df83 100644 --- a/tests/components/huisbaasje/test_init.py +++ b/tests/components/huisbaasje/test_init.py @@ -9,8 +9,9 @@ from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME, STATE_UNA from homeassistant.core import HomeAssistant from homeassistant.setup import async_setup_component +from .test_data import MOCK_CURRENT_MEASUREMENTS + from tests.common import MockConfigEntry -from tests.components.huisbaasje.test_data import MOCK_CURRENT_MEASUREMENTS async def test_setup(hass: HomeAssistant): diff --git a/tests/components/huisbaasje/test_sensor.py b/tests/components/huisbaasje/test_sensor.py index 4418127a0d1..84e1f71071c 100644 --- a/tests/components/huisbaasje/test_sensor.py +++ b/tests/components/huisbaasje/test_sensor.py @@ -21,11 +21,9 @@ from homeassistant.const import ( ) from homeassistant.core import HomeAssistant +from .test_data import MOCK_CURRENT_MEASUREMENTS, MOCK_LIMITED_CURRENT_MEASUREMENTS + from tests.common import MockConfigEntry -from tests.components.huisbaasje.test_data import ( - MOCK_CURRENT_MEASUREMENTS, - MOCK_LIMITED_CURRENT_MEASUREMENTS, -) async def test_setup_entry(hass: HomeAssistant):