Deprecate hass.helpers (#114484)

* Deprecate hass.helpers

* Patch

* Patch _REPORTED_INTEGRATIONS set in test

* Fix test

* Update version
This commit is contained in:
Jan-Philipp Benecke 2024-03-31 11:44:11 +02:00 committed by GitHub
parent f2f24a5d35
commit d5da0a053b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 45 additions and 0 deletions

View file

@ -1779,3 +1779,34 @@ async def test_has_services(hass: HomeAssistant, enable_custom_integrations) ->
assert integration.has_services is False
integration = await loader.async_get_integration(hass, "test_with_services")
assert integration.has_services is True
async def test_hass_helpers_use_reported(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, mock_integration_frame: Mock
) -> None:
"""Test that use of hass.components is reported."""
integration_frame = frame.IntegrationFrame(
custom_integration=True,
_frame=mock_integration_frame,
integration="test_integration_frame",
module="custom_components.test_integration_frame",
relative_filename="custom_components/test_integration_frame/__init__.py",
)
with (
patch.object(frame, "_REPORTED_INTEGRATIONS", new=set()),
patch(
"homeassistant.helpers.frame.get_integration_frame",
return_value=integration_frame,
),
patch(
"homeassistant.helpers.aiohttp_client.async_get_clientsession",
return_value=None,
),
):
hass.helpers.aiohttp_client.async_get_clientsession()
assert (
"Detected that custom integration 'test_integration_frame' "
"accesses hass.helpers.aiohttp_client. This is deprecated"
) in caplog.text