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:
parent
fbfd8c48aa
commit
114e254aa6
3 changed files with 34 additions and 21 deletions
|
@ -1811,23 +1811,24 @@ async def test_register_entity_service_none_schema(
|
|||
|
||||
|
||||
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."""
|
||||
entity_platform = MockEntityPlatform(
|
||||
hass, domain="mock_integration", platform_name="mock_platform", platform=None
|
||||
)
|
||||
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",
|
||||
):
|
||||
entity_platform.async_register_entity_service("hello", schema, Mock())
|
||||
entity_platform.async_register_entity_service(f"hello_{idx}", schema, Mock())
|
||||
assert expected_message in caplog.text
|
||||
caplog.clear()
|
||||
|
||||
for idx, schema in enumerate(
|
||||
(
|
||||
|
@ -1839,6 +1840,7 @@ async def test_register_entity_service_non_entity_service_schema(
|
|||
entity_platform.async_register_entity_service(
|
||||
f"test_service_{idx}", schema, Mock()
|
||||
)
|
||||
assert expected_message not in caplog.text
|
||||
|
||||
|
||||
@pytest.mark.parametrize("update_before_add", [True, False])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue