From cd0c9e1c4f5f0545ab321464d6d551f6d664b245 Mon Sep 17 00:00:00 2001 From: Jan-Philipp Benecke Date: Fri, 22 Mar 2024 17:52:10 +0100 Subject: [PATCH] Remove deprecated `hass.components` from conversation tests and use light setup fixture (#114012) --- tests/components/conversation/test_init.py | 31 +++++++++------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/tests/components/conversation/test_init.py b/tests/components/conversation/test_init.py index fd48fe450dc..b2d05e976d6 100644 --- a/tests/components/conversation/test_init.py +++ b/tests/components/conversation/test_init.py @@ -25,6 +25,7 @@ from homeassistant.setup import async_setup_component from . import expose_entity, expose_new from tests.common import MockConfigEntry, MockUser, async_mock_service +from tests.components.light.common import MockLight, SetupLightPlatformCallable from tests.typing import ClientSessionGenerator, WebSocketGenerator AGENT_ID_OPTIONS = [None, conversation.HOME_ASSISTANT_AGENT] @@ -256,7 +257,7 @@ async def test_http_processing_intent_entity_renamed( hass_client: ClientSessionGenerator, hass_admin_user: MockUser, entity_registry: er.EntityRegistry, - enable_custom_integrations: None, + setup_light_platform: SetupLightPlatformCallable, snapshot: SnapshotAssertion, ) -> None: """Test processing intent via HTTP API with entities renamed later. @@ -264,13 +265,11 @@ async def test_http_processing_intent_entity_renamed( We want to ensure that renaming an entity later busts the cache so that the new name is used. """ - platform = getattr(hass.components, "test.light") - platform.init(empty=True) - - entity = platform.MockLight("kitchen light", "on") + entity = MockLight("kitchen light", "on") entity._attr_unique_id = "1234" entity.entity_id = "light.kitchen" - platform.ENTITIES.append(entity) + setup_light_platform(hass, [entity]) + assert await async_setup_component( hass, LIGHT_DOMAIN, @@ -347,7 +346,7 @@ async def test_http_processing_intent_entity_exposed( hass_client: ClientSessionGenerator, hass_admin_user: MockUser, entity_registry: er.EntityRegistry, - enable_custom_integrations: None, + setup_light_platform: SetupLightPlatformCallable, snapshot: SnapshotAssertion, ) -> None: """Test processing intent via HTTP API with manual expose. @@ -355,13 +354,11 @@ async def test_http_processing_intent_entity_exposed( We want to ensure that manually exposing an entity later busts the cache so that the new setting is used. """ - platform = getattr(hass.components, "test.light") - platform.init(empty=True) - - entity = platform.MockLight("kitchen light", "on") + entity = MockLight("kitchen light", "on") entity._attr_unique_id = "1234" entity.entity_id = "light.kitchen" - platform.ENTITIES.append(entity) + setup_light_platform(hass, [entity]) + assert await async_setup_component( hass, LIGHT_DOMAIN, @@ -452,20 +449,18 @@ async def test_http_processing_intent_conversion_not_expose_new( hass_client: ClientSessionGenerator, hass_admin_user: MockUser, entity_registry: er.EntityRegistry, - enable_custom_integrations: None, + setup_light_platform: SetupLightPlatformCallable, snapshot: SnapshotAssertion, ) -> None: """Test processing intent via HTTP API when not exposing new entities.""" # Disable exposing new entities to the default agent expose_new(hass, False) - platform = getattr(hass.components, "test.light") - platform.init(empty=True) - - entity = platform.MockLight("kitchen light", "on") + entity = MockLight("kitchen light", "on") entity._attr_unique_id = "1234" entity.entity_id = "light.kitchen" - platform.ENTITIES.append(entity) + setup_light_platform(hass, [entity]) + assert await async_setup_component( hass, LIGHT_DOMAIN,