Ensure HA script and Python script services have a name (#47204)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Philip Allgaier
2021-03-31 15:09:45 +02:00
committed by GitHub
parent bee55a0494
commit 6fe04f40a2
6 changed files with 39 additions and 4 deletions

View File

@ -269,6 +269,7 @@ async def test_service_descriptions(hass):
descriptions = await async_get_all_descriptions(hass)
assert descriptions[DOMAIN]["test"]["name"] == "test"
assert descriptions[DOMAIN]["test"]["description"] == "test description"
assert not descriptions[DOMAIN]["test"]["fields"]
@ -303,6 +304,27 @@ async def test_service_descriptions(hass):
== "test_param example"
)
# Test 3: has "alias" that will be used as "name"
with patch(
"homeassistant.config.load_yaml_config_file",
return_value={
"script": {
"test_name": {
"alias": "ABC",
"sequence": [{"delay": {"seconds": 5}}],
}
}
},
):
await hass.services.async_call(DOMAIN, SERVICE_RELOAD, blocking=True)
descriptions = await async_get_all_descriptions(hass)
assert descriptions[DOMAIN]["test_name"]["name"] == "ABC"
# Test 4: verify that names from YAML are taken into account as well
assert descriptions[DOMAIN]["turn_on"]["name"] == "Turn on"
async def test_shared_context(hass):
"""Test that the shared context is passed down the chain."""