mirror of
https://github.com/home-assistant/core.git
synced 2025-11-10 03:19:34 +00:00
Change trigger platform key to trigger (#124357)
* fix * Fix * Fix * Update homeassistant/helpers/config_validation.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Fix * Fix * Fix * Fix * Add more tests * Fix * Fix tests * Add tests * Let's see what the CI does * It fails on the code that tested the thing ofc * It fails on the code that tested the thing ofc * Revert test thingy * Now the test works again, lovely * Another one * Fix websocket thingy * Only copy when needed * Improve comment * Remove test * Fix docstring * I think this now also work since this transforms trigger to platform * Add comment * Update homeassistant/helpers/config_validation.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/helpers/config_validation.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/helpers/config_validation.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Check for mapping * Add test * Update homeassistant/helpers/config_validation.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update test to also test for trigger keys --------- Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
committed by
GitHub
parent
9d29307532
commit
a1906b434f
@@ -1841,7 +1841,7 @@ async def test_nested_trigger_list() -> None:
|
||||
"event_type": "trigger_3",
|
||||
},
|
||||
{
|
||||
"platform": "event",
|
||||
"trigger": "event",
|
||||
"event_type": "trigger_4",
|
||||
},
|
||||
],
|
||||
@@ -1891,7 +1891,36 @@ async def test_nested_trigger_list_extra() -> None:
|
||||
|
||||
validated_triggers = TRIGGER_SCHEMA(trigger_config)
|
||||
|
||||
assert validated_triggers == trigger_config
|
||||
assert validated_triggers == [
|
||||
{
|
||||
"platform": "other",
|
||||
"triggers": [
|
||||
{
|
||||
"platform": "event",
|
||||
"event_type": "trigger_1",
|
||||
},
|
||||
{
|
||||
"platform": "event",
|
||||
"event_type": "trigger_2",
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
async def test_trigger_backwards_compatibility() -> None:
|
||||
"""Test triggers with backwards compatibility."""
|
||||
|
||||
assert cv._backward_compat_trigger_schema("str") == "str"
|
||||
assert cv._backward_compat_trigger_schema({"platform": "abc"}) == {
|
||||
"platform": "abc"
|
||||
}
|
||||
assert cv._backward_compat_trigger_schema({"trigger": "abc"}) == {"platform": "abc"}
|
||||
with pytest.raises(
|
||||
vol.Invalid,
|
||||
match="Cannot specify both 'platform' and 'trigger'. Please use 'trigger' only.",
|
||||
):
|
||||
cv._backward_compat_trigger_schema({"trigger": "abc", "platform": "def"})
|
||||
|
||||
|
||||
async def test_is_entity_service_schema(
|
||||
|
||||
Reference in New Issue
Block a user