Fix mixed case service schema registration (#96448)
This commit is contained in:
parent
7009683226
commit
08af42b00e
3 changed files with 25 additions and 1 deletions
|
@ -762,6 +762,27 @@ async def test_async_get_all_descriptions_dynamically_created_services(
|
|||
}
|
||||
|
||||
|
||||
async def test_register_with_mixed_case(hass: HomeAssistant) -> None:
|
||||
"""Test registering a service with mixed case.
|
||||
|
||||
For backwards compatibility, we have historically allowed mixed case,
|
||||
and automatically converted it to lowercase.
|
||||
"""
|
||||
logger = hass.components.logger
|
||||
logger_config = {logger.DOMAIN: {}}
|
||||
await async_setup_component(hass, logger.DOMAIN, logger_config)
|
||||
logger_domain_mixed = "LoGgEr"
|
||||
hass.services.async_register(
|
||||
logger_domain_mixed, "NeW_SeRVICE", lambda x: None, None
|
||||
)
|
||||
service.async_set_service_schema(
|
||||
hass, logger_domain_mixed, "NeW_SeRVICE", {"description": "new service"}
|
||||
)
|
||||
descriptions = await service.async_get_all_descriptions(hass)
|
||||
assert "description" in descriptions[logger.DOMAIN]["new_service"]
|
||||
assert descriptions[logger.DOMAIN]["new_service"]["description"] == "new service"
|
||||
|
||||
|
||||
async def test_call_with_required_features(hass: HomeAssistant, mock_entities) -> None:
|
||||
"""Test service calls invoked only if entity has required features."""
|
||||
test_service_mock = AsyncMock(return_value=None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue