mirror of
https://github.com/home-assistant/core.git
synced 2025-08-19 10:20:07 +00:00
Implement new state property for alarm_control_panel which is using an enum (#126283)
* Alarm state from enum * Fixes * Set final * Fix rebase * Test const * Fix breaking version * Fix other for alarm_control_panel * Fix integrations * More * More * More * More * Fix zha * Replace _attr_state * Fix alarm_control_panel * Fix tests * Fixes * Mods * Change some * More * More * More * Tests * Last tests * Return enum * Fix zha * Remove not needed check * Fix wording * Fix homekit * Mod prometheus * Fix mypy * Fix homekit * Fix ifttt
This commit is contained in:
@@ -8,7 +8,7 @@ from unittest.mock import Mock, patch
|
||||
import pytest
|
||||
|
||||
from homeassistant import const
|
||||
from homeassistant.components import lock, sensor
|
||||
from homeassistant.components import alarm_control_panel, lock, sensor
|
||||
|
||||
from .common import (
|
||||
extract_stack_to_frame,
|
||||
@@ -218,6 +218,38 @@ def test_deprecated_constants_lock(
|
||||
)
|
||||
|
||||
|
||||
def _create_tuples_alarm_states(
|
||||
enum: type[Enum], constant_prefix: str, remove_in_version: str
|
||||
) -> list[tuple[Enum, str]]:
|
||||
return [
|
||||
(enum_field, constant_prefix, remove_in_version)
|
||||
for enum_field in enum
|
||||
if enum_field
|
||||
not in [
|
||||
lock.LockState.OPEN,
|
||||
lock.LockState.OPENING,
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("enum", "constant_prefix", "remove_in_version"),
|
||||
_create_tuples_lock_states(
|
||||
alarm_control_panel.AlarmControlPanelState, "STATE_ALARM_", "2025.11"
|
||||
),
|
||||
)
|
||||
def test_deprecated_constants_alarm(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
enum: Enum,
|
||||
constant_prefix: str,
|
||||
remove_in_version: str,
|
||||
) -> None:
|
||||
"""Test deprecated constants."""
|
||||
import_and_test_deprecated_constant_enum(
|
||||
caplog, const, enum, constant_prefix, remove_in_version
|
||||
)
|
||||
|
||||
|
||||
def test_deprecated_unit_of_conductivity_alias() -> None:
|
||||
"""Test UnitOfConductivity deprecation."""
|
||||
|
||||
|
Reference in New Issue
Block a user