Remove deprecated imports in config tests (#119393)

This commit is contained in:
epenet 2024-06-11 16:11:10 +02:00 committed by GitHub
parent fce4fc663e
commit bdf69c2e5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 29 deletions

View File

@ -9,11 +9,6 @@ from homeassistant.bootstrap import async_setup_component
from homeassistant.components import config from homeassistant.components import config
from homeassistant.components.config import core from homeassistant.components.config import core
from homeassistant.components.websocket_api import TYPE_RESULT from homeassistant.components.websocket_api import TYPE_RESULT
from homeassistant.const import (
CONF_UNIT_SYSTEM,
CONF_UNIT_SYSTEM_IMPERIAL,
CONF_UNIT_SYSTEM_METRIC,
)
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.util import dt as dt_util, location from homeassistant.util import dt as dt_util, location
from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
@ -140,7 +135,7 @@ async def test_websocket_core_update(hass: HomeAssistant, client) -> None:
"longitude": 50, "longitude": 50,
"elevation": 25, "elevation": 25,
"location_name": "Huis", "location_name": "Huis",
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_IMPERIAL, "unit_system": "imperial",
"time_zone": "America/New_York", "time_zone": "America/New_York",
"external_url": "https://www.example.com", "external_url": "https://www.example.com",
"internal_url": "http://example.local", "internal_url": "http://example.local",
@ -181,7 +176,7 @@ async def test_websocket_core_update(hass: HomeAssistant, client) -> None:
{ {
"id": 6, "id": 6,
"type": "config/core/update", "type": "config/core/update",
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_METRIC, "unit_system": "metric",
"update_units": True, "update_units": True,
} }
) )

View File

@ -16,7 +16,7 @@ import voluptuous as vol
from voluptuous import Invalid, MultipleInvalid from voluptuous import Invalid, MultipleInvalid
import yaml import yaml
from homeassistant import config, loader from homeassistant import loader
import homeassistant.config as config_util import homeassistant.config as config_util
from homeassistant.const import ( from homeassistant.const import (
ATTR_ASSUMED_STATE, ATTR_ASSUMED_STATE,
@ -27,9 +27,6 @@ from homeassistant.const import (
CONF_LATITUDE, CONF_LATITUDE,
CONF_LONGITUDE, CONF_LONGITUDE,
CONF_NAME, CONF_NAME,
CONF_UNIT_SYSTEM,
CONF_UNIT_SYSTEM_IMPERIAL,
CONF_UNIT_SYSTEM_METRIC,
__version__, __version__,
) )
from homeassistant.core import ( from homeassistant.core import (
@ -49,7 +46,6 @@ from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import Integration, async_get_integration from homeassistant.loader import Integration, async_get_integration
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from homeassistant.util.unit_system import ( from homeassistant.util.unit_system import (
_CONF_UNIT_SYSTEM_US_CUSTOMARY,
METRIC_SYSTEM, METRIC_SYSTEM,
US_CUSTOMARY_SYSTEM, US_CUSTOMARY_SYSTEM,
UnitSystem, UnitSystem,
@ -511,7 +507,7 @@ async def test_create_default_config_returns_none_if_write_error(
def test_core_config_schema() -> None: def test_core_config_schema() -> None:
"""Test core config schema.""" """Test core config schema."""
for value in ( for value in (
{CONF_UNIT_SYSTEM: "K"}, {"unit_system": "K"},
{"time_zone": "non-exist"}, {"time_zone": "non-exist"},
{"latitude": "91"}, {"latitude": "91"},
{"longitude": -181}, {"longitude": -181},
@ -534,7 +530,7 @@ def test_core_config_schema() -> None:
"longitude": "123.45", "longitude": "123.45",
"external_url": "https://www.example.com", "external_url": "https://www.example.com",
"internal_url": "http://example.local", "internal_url": "http://example.local",
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_METRIC, "unit_system": "metric",
"currency": "USD", "currency": "USD",
"customize": {"sensor.temperature": {"hidden": True}}, "customize": {"sensor.temperature": {"hidden": True}},
"country": "SE", "country": "SE",
@ -850,7 +846,7 @@ async def test_loading_configuration(hass: HomeAssistant) -> None:
"longitude": 50, "longitude": 50,
"elevation": 25, "elevation": 25,
"name": "Huis", "name": "Huis",
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_IMPERIAL, "unit_system": "imperial",
"time_zone": "America/New_York", "time_zone": "America/New_York",
"allowlist_external_dirs": "/etc", "allowlist_external_dirs": "/etc",
"external_url": "https://www.example.com", "external_url": "https://www.example.com",
@ -982,7 +978,7 @@ async def test_loading_configuration_from_packages(hass: HomeAssistant) -> None:
"longitude": -1, "longitude": -1,
"elevation": 500, "elevation": 500,
"name": "Huis", "name": "Huis",
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_METRIC, "unit_system": "metric",
"time_zone": "Europe/Madrid", "time_zone": "Europe/Madrid",
"external_url": "https://www.example.com", "external_url": "https://www.example.com",
"internal_url": "http://example.local", "internal_url": "http://example.local",
@ -1006,7 +1002,7 @@ async def test_loading_configuration_from_packages(hass: HomeAssistant) -> None:
"longitude": -1, "longitude": -1,
"elevation": 500, "elevation": 500,
"name": "Huis", "name": "Huis",
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_METRIC, "unit_system": "metric",
"time_zone": "Europe/Madrid", "time_zone": "Europe/Madrid",
"packages": {"empty_package": None}, "packages": {"empty_package": None},
}, },
@ -1016,9 +1012,9 @@ async def test_loading_configuration_from_packages(hass: HomeAssistant) -> None:
@pytest.mark.parametrize( @pytest.mark.parametrize(
("unit_system_name", "expected_unit_system"), ("unit_system_name", "expected_unit_system"),
[ [
(CONF_UNIT_SYSTEM_METRIC, METRIC_SYSTEM), ("metric", METRIC_SYSTEM),
(CONF_UNIT_SYSTEM_IMPERIAL, US_CUSTOMARY_SYSTEM), ("imperial", US_CUSTOMARY_SYSTEM),
(_CONF_UNIT_SYSTEM_US_CUSTOMARY, US_CUSTOMARY_SYSTEM), ("us_customary", US_CUSTOMARY_SYSTEM),
], ],
) )
async def test_loading_configuration_unit_system( async def test_loading_configuration_unit_system(
@ -1295,7 +1291,7 @@ async def test_merge_customize(hass: HomeAssistant) -> None:
"longitude": 50, "longitude": 50,
"elevation": 25, "elevation": 25,
"name": "Huis", "name": "Huis",
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_IMPERIAL, "unit_system": "imperial",
"time_zone": "GMT", "time_zone": "GMT",
"customize": {"a.a": {"friendly_name": "A"}}, "customize": {"a.a": {"friendly_name": "A"}},
"packages": { "packages": {
@ -1314,7 +1310,7 @@ async def test_auth_provider_config(hass: HomeAssistant) -> None:
"longitude": 50, "longitude": 50,
"elevation": 25, "elevation": 25,
"name": "Huis", "name": "Huis",
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_IMPERIAL, "unit_system": "imperial",
"time_zone": "GMT", "time_zone": "GMT",
CONF_AUTH_PROVIDERS: [ CONF_AUTH_PROVIDERS: [
{"type": "homeassistant"}, {"type": "homeassistant"},
@ -1341,7 +1337,7 @@ async def test_auth_provider_config_default(hass: HomeAssistant) -> None:
"longitude": 50, "longitude": 50,
"elevation": 25, "elevation": 25,
"name": "Huis", "name": "Huis",
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_IMPERIAL, "unit_system": "imperial",
"time_zone": "GMT", "time_zone": "GMT",
} }
if hasattr(hass, "auth"): if hasattr(hass, "auth"):
@ -1361,7 +1357,7 @@ async def test_disallowed_auth_provider_config(hass: HomeAssistant) -> None:
"longitude": 50, "longitude": 50,
"elevation": 25, "elevation": 25,
"name": "Huis", "name": "Huis",
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_IMPERIAL, "unit_system": "imperial",
"time_zone": "GMT", "time_zone": "GMT",
CONF_AUTH_PROVIDERS: [ CONF_AUTH_PROVIDERS: [
{ {
@ -1387,7 +1383,7 @@ async def test_disallowed_duplicated_auth_provider_config(hass: HomeAssistant) -
"longitude": 50, "longitude": 50,
"elevation": 25, "elevation": 25,
"name": "Huis", "name": "Huis",
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_IMPERIAL, "unit_system": "imperial",
"time_zone": "GMT", "time_zone": "GMT",
CONF_AUTH_PROVIDERS: [{"type": "homeassistant"}, {"type": "homeassistant"}], CONF_AUTH_PROVIDERS: [{"type": "homeassistant"}, {"type": "homeassistant"}],
} }
@ -1402,7 +1398,7 @@ async def test_disallowed_auth_mfa_module_config(hass: HomeAssistant) -> None:
"longitude": 50, "longitude": 50,
"elevation": 25, "elevation": 25,
"name": "Huis", "name": "Huis",
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_IMPERIAL, "unit_system": "imperial",
"time_zone": "GMT", "time_zone": "GMT",
CONF_AUTH_MFA_MODULES: [ CONF_AUTH_MFA_MODULES: [
{ {
@ -1424,7 +1420,7 @@ async def test_disallowed_duplicated_auth_mfa_module_config(
"longitude": 50, "longitude": 50,
"elevation": 25, "elevation": 25,
"name": "Huis", "name": "Huis",
CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_IMPERIAL, "unit_system": "imperial",
"time_zone": "GMT", "time_zone": "GMT",
CONF_AUTH_MFA_MODULES: [{"type": "totp"}, {"type": "totp"}], CONF_AUTH_MFA_MODULES: [{"type": "totp"}, {"type": "totp"}],
} }
@ -2459,7 +2455,7 @@ async def test_loading_platforms_gathers(hass: HomeAssistant) -> None:
_load_platform, _load_platform,
): ):
light_task = hass.async_create_task( light_task = hass.async_create_task(
config.async_process_component_config( config_util.async_process_component_config(
hass, hass,
{ {
"light": [ "light": [
@ -2472,7 +2468,7 @@ async def test_loading_platforms_gathers(hass: HomeAssistant) -> None:
eager_start=True, eager_start=True,
) )
sensor_task = hass.async_create_task( sensor_task = hass.async_create_task(
config.async_process_component_config( config_util.async_process_component_config(
hass, hass,
{ {
"sensor": [ "sensor": [