Ensure entity platform in google_assistant tests (#135719)

This commit is contained in:
G Johansson 2025-01-17 09:14:25 +01:00 committed by GitHub
parent d62a66eaf2
commit 21256cab85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,7 +51,7 @@ from homeassistant.setup import async_setup_component
from . import BASIC_CONFIG, MockConfig
from tests.common import MockConfigEntry, async_capture_events
from tests.common import MockConfigEntry, MockEntityPlatform, async_capture_events
REQ_ID = "ff36a3cc-ec34-11e6-b1a0-64510650abcf"
@ -156,6 +156,7 @@ async def test_sync_message(hass: HomeAssistant, registries) -> None:
effect=LIGHT_EFFECT_LIST[0],
)
light.hass = hass
light.platform = MockEntityPlatform(hass)
light.entity_id = "light.demo_light"
light._attr_device_info = None
light._attr_name = "Demo Light"
@ -301,6 +302,7 @@ async def test_sync_in_area(area_on_device, hass: HomeAssistant, registries) ->
effect=LIGHT_EFFECT_LIST[0],
)
light.hass = hass
light.platform = MockEntityPlatform(hass)
light.entity_id = entity.entity_id
light._attr_device_info = None
light._attr_name = "Demo Light"
@ -396,6 +398,7 @@ async def test_query_message(hass: HomeAssistant) -> None:
effect=LIGHT_EFFECT_LIST[0],
)
light.hass = hass
light.platform = MockEntityPlatform(hass)
light.entity_id = "light.demo_light"
light._attr_device_info = None
light._attr_name = "Demo Light"
@ -405,6 +408,7 @@ async def test_query_message(hass: HomeAssistant) -> None:
None, "Another Light", state=True, hs_color=(180, 75), ct=2500, brightness=78
)
light2.hass = hass
light2.platform = MockEntityPlatform(hass)
light2.entity_id = "light.another_light"
light2._attr_device_info = None
light2._attr_name = "Another Light"
@ -412,6 +416,7 @@ async def test_query_message(hass: HomeAssistant) -> None:
light3 = DemoLight(None, "Color temp Light", state=True, ct=2500, brightness=200)
light3.hass = hass
light3.platform = MockEntityPlatform(hass)
light3.entity_id = "light.color_temp_light"
light3._attr_device_info = None
light3._attr_name = "Color temp Light"
@ -899,6 +904,7 @@ async def test_unavailable_state_does_sync(hass: HomeAssistant) -> None:
effect=LIGHT_EFFECT_LIST[0],
)
light.hass = hass
light.platform = MockEntityPlatform(hass)
light.entity_id = "light.demo_light"
light._available = False
light._attr_device_info = None
@ -996,6 +1002,7 @@ async def test_device_class_switch(
device_class=device_class,
)
sensor.hass = hass
sensor.platform = MockEntityPlatform(hass)
sensor.entity_id = "switch.demo_sensor"
sensor._attr_device_info = None
sensor._attr_name = "Demo Sensor"
@ -1046,6 +1053,7 @@ async def test_device_class_binary_sensor(
None, "Demo Sensor", state=False, device_class=device_class
)
sensor.hass = hass
sensor.platform = MockEntityPlatform(hass)
sensor.entity_id = "binary_sensor.demo_sensor"
sensor._attr_device_info = None
sensor._attr_name = "Demo Sensor"
@ -1100,6 +1108,7 @@ async def test_device_class_cover(
"""Test that a cover entity syncs to the correct device type."""
sensor = DemoCover(None, hass, "Demo Sensor", device_class=device_class)
sensor.hass = hass
sensor.platform = MockEntityPlatform(hass)
sensor.entity_id = "cover.demo_sensor"
sensor._attr_device_info = None
sensor._attr_name = "Demo Sensor"
@ -1150,6 +1159,7 @@ async def test_device_media_player(
"""Test that a binary entity syncs to the correct device type."""
sensor = AbstractDemoPlayer("Demo", device_class=device_class)
sensor.hass = hass
sensor.platform = MockEntityPlatform(hass)
sensor.entity_id = "media_player.demo"
sensor.async_write_ha_state()
@ -1441,6 +1451,7 @@ async def test_sync_message_recovery(
hs_color=(180, 75),
)
light.hass = hass
light.platform = MockEntityPlatform(hass)
light.entity_id = "light.demo_light"
light._attr_device_info = None
light._attr_name = "Demo Light"