mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 19:09:32 +00:00
Don't raise when registering entity service with invalid schema (#125057)
* Don't raise when registering entity service with invalid schema * Update homeassistant/helpers/service.py Co-authored-by: Robert Resch <robert@resch.dev> --------- Co-authored-by: Robert Resch <robert@resch.dev>
This commit is contained in:
@@ -557,21 +557,22 @@ async def test_register_entity_service(
|
||||
|
||||
|
||||
async def test_register_entity_service_non_entity_service_schema(
|
||||
hass: HomeAssistant,
|
||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||
) -> 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 schema in (
|
||||
vol.Schema({"some": str}),
|
||||
vol.All(vol.Schema({"some": str})),
|
||||
vol.Any(vol.Schema({"some": str})),
|
||||
for idx, schema in enumerate(
|
||||
(
|
||||
vol.Schema({"some": str}),
|
||||
vol.All(vol.Schema({"some": str})),
|
||||
vol.Any(vol.Schema({"some": str})),
|
||||
)
|
||||
):
|
||||
with pytest.raises(
|
||||
HomeAssistantError,
|
||||
match=("The schema is not an entity service schema"),
|
||||
):
|
||||
component.async_register_entity_service("hello", schema, Mock())
|
||||
component.async_register_entity_service(f"hello_{idx}", schema, Mock())
|
||||
assert expected_message in caplog.text
|
||||
caplog.clear()
|
||||
|
||||
for idx, schema in enumerate(
|
||||
(
|
||||
@@ -581,6 +582,7 @@ 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:
|
||||
|
||||
Reference in New Issue
Block a user