Remove deprecated hass.components from conversation tests and use light setup fixture (#114012)

This commit is contained in:
Jan-Philipp Benecke 2024-03-22 17:52:10 +01:00 committed by GitHub
parent 01acbc8bba
commit cd0c9e1c4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,