mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 10:59:40 +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
@@ -1,6 +1,7 @@
|
||||
"""Test selectors."""
|
||||
|
||||
from enum import Enum
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
import voluptuous as vol
|
||||
@@ -1107,6 +1108,13 @@ def test_condition_selector_schema(
|
||||
(
|
||||
{},
|
||||
(
|
||||
[
|
||||
{
|
||||
"platform": "numeric_state",
|
||||
"entity_id": ["sensor.temperature"],
|
||||
"below": 20,
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"platform": "numeric_state",
|
||||
@@ -1122,7 +1130,24 @@ def test_condition_selector_schema(
|
||||
)
|
||||
def test_trigger_selector_schema(schema, valid_selections, invalid_selections) -> None:
|
||||
"""Test trigger sequence selector."""
|
||||
_test_selector("trigger", schema, valid_selections, invalid_selections)
|
||||
|
||||
def _custom_trigger_serializer(
|
||||
triggers: list[dict[str, Any]],
|
||||
) -> list[dict[str, Any]]:
|
||||
res = []
|
||||
for trigger in triggers:
|
||||
if "trigger" in trigger:
|
||||
trigger["platform"] = trigger.pop("trigger")
|
||||
res.append(trigger)
|
||||
return res
|
||||
|
||||
_test_selector(
|
||||
"trigger",
|
||||
schema,
|
||||
valid_selections,
|
||||
invalid_selections,
|
||||
_custom_trigger_serializer,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
Reference in New Issue
Block a user