Skip to content
Snippets Groups Projects
Unverified Commit 491a50a2 authored by Robert Resch's avatar Robert Resch Committed by GitHub
Browse files

Deprecate deprecated lock constants (#106113)

parent 9dd1b9e2
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,11 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA_BASE,
make_entity_service_schema,
)
from homeassistant.helpers.deprecation import (
DeprecatedConstantEnum,
check_if_deprecated_constant,
dir_with_deprecated_constants,
)
from homeassistant.helpers.entity import Entity, EntityDescription
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import ConfigType, StateType
......@@ -57,7 +62,11 @@ class LockEntityFeature(IntFlag):
# The SUPPORT_OPEN constant is deprecated as of Home Assistant 2022.5.
# Please use the LockEntityFeature enum instead.
SUPPORT_OPEN = 1
_DEPRECATED_SUPPORT_OPEN = DeprecatedConstantEnum(LockEntityFeature.OPEN, "2025.1")
# Both can be removed if no deprecated constant are in this module anymore
__getattr__ = ft.partial(check_if_deprecated_constant, module_globals=globals())
__dir__ = ft.partial(dir_with_deprecated_constants, module_globals=globals())
PROP_TO_ATTR = {"changed_by": ATTR_CHANGED_BY, "code_format": ATTR_CODE_FORMAT}
......
......@@ -5,6 +5,7 @@ from typing import Any
import pytest
from homeassistant.components import lock
from homeassistant.components.lock import (
ATTR_CODE,
CONF_DEFAULT_CODE,
......@@ -25,6 +26,8 @@ from homeassistant.helpers.typing import UNDEFINED, UndefinedType
from .conftest import MockLock
from tests.common import import_and_test_deprecated_constant_enum
async def help_test_async_lock_service(
hass: HomeAssistant,
......@@ -353,3 +356,12 @@ async def test_lock_with_illegal_default_code(
await help_test_async_lock_service(
hass, mock_lock_entity.entity_id, SERVICE_UNLOCK
)
@pytest.mark.parametrize(("enum"), list(LockEntityFeature))
def test_deprecated_constants(
caplog: pytest.LogCaptureFixture,
enum: LockEntityFeature,
) -> None:
"""Test deprecated constants."""
import_and_test_deprecated_constant_enum(caplog, lock, enum, "SUPPORT_", "2025.1")
......@@ -2,7 +2,7 @@
Call init before using it in your tests to ensure clean test data.
"""
from homeassistant.components.lock import SUPPORT_OPEN, LockEntity
from homeassistant.components.lock import LockEntity, LockEntityFeature
from tests.common import MockEntity
......@@ -20,7 +20,7 @@ def init(empty=False):
"support_open": MockLock(
name="Support open Lock",
is_locked=True,
supported_features=SUPPORT_OPEN,
supported_features=LockEntityFeature.OPEN,
unique_id="unique_support_open",
),
"no_support_open": MockLock(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment