1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 09:38:58 +01:00

Remove deprecated hass.components (#141947)

This commit is contained in:
Jan-Philipp Benecke
2025-04-23 14:04:36 +02:00
committed by GitHub
parent 3cb301214f
commit f22eca3d9e
5 changed files with 2 additions and 172 deletions
+2 -65
View File
@@ -12,13 +12,13 @@ from awesomeversion import AwesomeVersion
import pytest
from homeassistant import loader
from homeassistant.components import http, hue
from homeassistant.components import hue
from homeassistant.components.hue import light as hue_light
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.json import json_dumps
from homeassistant.util.json import json_loads
from .common import MockModule, async_get_persistent_notifications, mock_integration
from .common import MockModule, mock_integration
async def test_circular_component_dependencies(hass: HomeAssistant) -> None:
@@ -114,29 +114,6 @@ async def test_nonexistent_component_dependencies(hass: HomeAssistant) -> None:
assert result == {}
def test_component_loader(hass: HomeAssistant) -> None:
"""Test loading components."""
components = loader.Components(hass)
assert components.http.CONFIG_SCHEMA is http.CONFIG_SCHEMA
assert hass.components.http.CONFIG_SCHEMA is http.CONFIG_SCHEMA
def test_component_loader_non_existing(hass: HomeAssistant) -> None:
"""Test loading components."""
components = loader.Components(hass)
with pytest.raises(ImportError):
_ = components.non_existing
async def test_component_wrapper(hass: HomeAssistant) -> None:
"""Test component wrapper."""
components = loader.Components(hass)
components.persistent_notification.async_create("message")
notifications = async_get_persistent_notifications(hass)
assert len(notifications)
async def test_helpers_wrapper(hass: HomeAssistant) -> None:
"""Test helpers wrapper."""
helpers = loader.Helpers(hass)
@@ -168,10 +145,6 @@ async def test_custom_component_name(hass: HomeAssistant) -> None:
assert int_comp.__name__ == "custom_components.test_package"
assert int_comp.__package__ == "custom_components.test_package"
comp = hass.components.test_package
assert comp.__name__ == "custom_components.test_package"
assert comp.__package__ == "custom_components.test_package"
integration = await loader.async_get_integration(hass, "test")
platform = integration.get_platform("light")
assert integration.get_platform_cached("light") is platform
@@ -1349,42 +1322,6 @@ async def test_config_folder_not_in_path() -> None:
import tests.testing_config.check_config_not_in_path # noqa: F401
@pytest.mark.parametrize(
("integration_frame_path", "expected"),
[
pytest.param(
"custom_components/test_integration_frame", True, id="custom integration"
),
pytest.param(
"homeassistant/components/test_integration_frame",
False,
id="core integration",
),
pytest.param("homeassistant/test_integration_frame", False, id="core"),
],
)
@pytest.mark.usefixtures("mock_integration_frame")
async def test_hass_components_use_reported(
hass: HomeAssistant,
caplog: pytest.LogCaptureFixture,
expected: bool,
) -> None:
"""Test whether use of hass.components is reported."""
with (
patch(
"homeassistant.components.http.start_http_server_and_save_config",
return_value=None,
),
):
await hass.components.http.start_http_server_and_save_config(hass, [], None)
reported = (
"Detected that custom integration 'test_integration_frame'"
" accesses hass.components.http, which should be updated"
) in caplog.text
assert reported == expected
async def test_async_get_component_preloads_config_and_config_flow(
hass: HomeAssistant,
) -> None: