mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Deprecate deprecated lock constants (#106113)
This commit is contained in:
parent
9dd1b9e268
commit
491a50a2f1
@ -30,6 +30,11 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
|
|||||||
PLATFORM_SCHEMA_BASE,
|
PLATFORM_SCHEMA_BASE,
|
||||||
make_entity_service_schema,
|
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 import Entity, EntityDescription
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.typing import ConfigType, StateType
|
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.
|
# The SUPPORT_OPEN constant is deprecated as of Home Assistant 2022.5.
|
||||||
# Please use the LockEntityFeature enum instead.
|
# 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}
|
PROP_TO_ATTR = {"changed_by": ATTR_CHANGED_BY, "code_format": ATTR_CODE_FORMAT}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ from typing import Any
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant.components import lock
|
||||||
from homeassistant.components.lock import (
|
from homeassistant.components.lock import (
|
||||||
ATTR_CODE,
|
ATTR_CODE,
|
||||||
CONF_DEFAULT_CODE,
|
CONF_DEFAULT_CODE,
|
||||||
@ -25,6 +26,8 @@ from homeassistant.helpers.typing import UNDEFINED, UndefinedType
|
|||||||
|
|
||||||
from .conftest import MockLock
|
from .conftest import MockLock
|
||||||
|
|
||||||
|
from tests.common import import_and_test_deprecated_constant_enum
|
||||||
|
|
||||||
|
|
||||||
async def help_test_async_lock_service(
|
async def help_test_async_lock_service(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -353,3 +356,12 @@ async def test_lock_with_illegal_default_code(
|
|||||||
await help_test_async_lock_service(
|
await help_test_async_lock_service(
|
||||||
hass, mock_lock_entity.entity_id, SERVICE_UNLOCK
|
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.
|
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
|
from tests.common import MockEntity
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ def init(empty=False):
|
|||||||
"support_open": MockLock(
|
"support_open": MockLock(
|
||||||
name="Support open Lock",
|
name="Support open Lock",
|
||||||
is_locked=True,
|
is_locked=True,
|
||||||
supported_features=SUPPORT_OPEN,
|
supported_features=LockEntityFeature.OPEN,
|
||||||
unique_id="unique_support_open",
|
unique_id="unique_support_open",
|
||||||
),
|
),
|
||||||
"no_support_open": MockLock(
|
"no_support_open": MockLock(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user