Files
esphome/tests/component_tests/template/test_template_cover.py
T
01b29dbf53 [cover] Add stop tilt support (#20248)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2026-10-21 15:49:07 -10:00

26 lines
904 B
Python

"""Tests for template cover config validation."""
import pytest
from esphome import config_validation as cv
from esphome.components.template.cover import CONF_STOP_TILT_ACTION, CONFIG_SCHEMA
from esphome.const import CONF_ID, CONF_NAME, CONF_TILT_ACTION
from esphome.types import ConfigType
def _cover_config(**extra: object) -> ConfigType:
return {CONF_ID: "test_cover", CONF_NAME: "Test Cover", **extra}
def test_stop_tilt_action_with_tilt_action_allowed() -> None:
config = CONFIG_SCHEMA(
_cover_config(**{CONF_TILT_ACTION: [], CONF_STOP_TILT_ACTION: []})
)
assert CONF_STOP_TILT_ACTION in config
def test_stop_tilt_action_without_tilt_action_rejected() -> None:
with pytest.raises(cv.Invalid, match="requires 'tilt_action'") as exc_info:
CONFIG_SCHEMA(_cover_config(**{CONF_STOP_TILT_ACTION: []}))
assert exc_info.value.path == [CONF_STOP_TILT_ACTION]