1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Raise error for entity services without a correct schema (#151165)

This commit is contained in:
G Johansson
2025-09-14 19:17:26 +02:00
committed by GitHub
parent 49e75c9cf8
commit af9717c1cd
4 changed files with 26 additions and 35 deletions

View File

@@ -560,11 +560,10 @@ async def test_register_entity_service(
async def test_register_entity_service_non_entity_service_schema(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
hass: HomeAssistant,
) -> None:
"""Test attempting to register a service with a non entity service schema."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
expected_message = "registers an entity service with a non entity service schema"
for idx, schema in enumerate(
(
@@ -573,9 +572,9 @@ async def test_register_entity_service_non_entity_service_schema(
vol.Any(vol.Schema({"some": str})),
)
):
component.async_register_entity_service(f"hello_{idx}", schema, Mock())
assert expected_message in caplog.text
caplog.clear()
expected_message = f"The test_domain.hello_{idx} service registers an entity service with a non entity service schema"
with pytest.raises(HomeAssistantError, match=expected_message):
component.async_register_entity_service(f"hello_{idx}", schema, Mock())
for idx, schema in enumerate(
(
@@ -585,7 +584,6 @@ async def test_register_entity_service_non_entity_service_schema(
)
):
component.async_register_entity_service(f"test_service_{idx}", schema, Mock())
assert expected_message not in caplog.text
async def test_register_entity_service_response_data(hass: HomeAssistant) -> None: