mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Add missing exclude_integrations in lovelace compatibility code (#136618)
Add missing exclude_integrations in lovelace
This commit is contained in:
parent
6015c936b0
commit
111906f54e
@ -109,6 +109,7 @@ class LovelaceData:
|
|||||||
report_usage(
|
report_usage(
|
||||||
f"accessed lovelace_data['{name}'] instead of lovelace_data.{name}",
|
f"accessed lovelace_data['{name}'] instead of lovelace_data.{name}",
|
||||||
breaks_in_ha_version="2026.2",
|
breaks_in_ha_version="2026.2",
|
||||||
|
exclude_integrations={DOMAIN},
|
||||||
)
|
)
|
||||||
return getattr(self, name)
|
return getattr(self, name)
|
||||||
|
|
||||||
@ -121,6 +122,7 @@ class LovelaceData:
|
|||||||
report_usage(
|
report_usage(
|
||||||
f"accessed lovelace_data.get('{name}') instead of lovelace_data.{name}",
|
f"accessed lovelace_data.get('{name}') instead of lovelace_data.{name}",
|
||||||
breaks_in_ha_version="2026.2",
|
breaks_in_ha_version="2026.2",
|
||||||
|
exclude_integrations={DOMAIN},
|
||||||
)
|
)
|
||||||
if hasattr(self, name):
|
if hasattr(self, name):
|
||||||
return getattr(self, name)
|
return getattr(self, name)
|
||||||
|
@ -7,6 +7,7 @@ from unittest.mock import MagicMock, patch
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers import frame
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
from tests.typing import WebSocketGenerator
|
from tests.typing import WebSocketGenerator
|
||||||
@ -40,6 +41,8 @@ async def test_create_dashboards_when_onboarded(
|
|||||||
assert response["result"] == []
|
assert response["result"] == []
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("integration_frame_path", ["custom_components/my_integration"])
|
||||||
|
@pytest.mark.usefixtures("mock_integration_frame")
|
||||||
async def test_hass_data_compatibility(
|
async def test_hass_data_compatibility(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
caplog: pytest.LogCaptureFixture,
|
caplog: pytest.LogCaptureFixture,
|
||||||
@ -50,32 +53,24 @@ async def test_hass_data_compatibility(
|
|||||||
https://github.com/hacs/integration/blob/4a820e8b1b066bc54a1c9c61102038af6c030603
|
https://github.com/hacs/integration/blob/4a820e8b1b066bc54a1c9c61102038af6c030603
|
||||||
/custom_components/hacs/repositories/plugin.py#L173
|
/custom_components/hacs/repositories/plugin.py#L173
|
||||||
"""
|
"""
|
||||||
expected = (
|
expected_prefix = (
|
||||||
"Detected that integration 'lovelace' accessed lovelace_data.get('resources')"
|
"Detected that custom integration 'my_integration' accessed lovelace_data"
|
||||||
" instead of lovelace_data.resources at"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
assert await async_setup_component(hass, "lovelace", {})
|
assert await async_setup_component(hass, "lovelace", {})
|
||||||
|
|
||||||
assert (lovelace_data := hass.data.get("lovelace")) is not None
|
assert (lovelace_data := hass.data.get("lovelace")) is not None
|
||||||
assert expected not in caplog.text
|
|
||||||
|
|
||||||
# Direct access to resources is fine
|
# Direct access to resources is fine
|
||||||
assert lovelace_data.resources is not None
|
assert lovelace_data.resources is not None
|
||||||
assert (
|
assert expected_prefix not in caplog.text
|
||||||
"Detected that integration 'lovelace' accessed lovelace_data" not in caplog.text
|
|
||||||
)
|
|
||||||
|
|
||||||
# Dict compatibility logs warning
|
# Dict compatibility logs warning
|
||||||
assert lovelace_data["resources"] is not None
|
with patch.object(frame, "_REPORTED_INTEGRATIONS", set()):
|
||||||
assert (
|
assert lovelace_data["resources"] is not None
|
||||||
"Detected that integration 'lovelace' accessed lovelace_data['resources']"
|
assert f"{expected_prefix}['resources']" in caplog.text
|
||||||
in caplog.text
|
|
||||||
)
|
|
||||||
|
|
||||||
# Dict get compatibility logs warning
|
# Dict get compatibility logs warning
|
||||||
assert lovelace_data.get("resources") is not None
|
with patch.object(frame, "_REPORTED_INTEGRATIONS", set()):
|
||||||
assert (
|
assert lovelace_data.get("resources") is not None
|
||||||
"Detected that integration 'lovelace' accessed lovelace_data.get('resources')"
|
assert f"{expected_prefix}.get('resources')" in caplog.text
|
||||||
in caplog.text
|
|
||||||
)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user