Deprecate deprecated remote constants (#106116)
This commit is contained in:
parent
93c800c4e8
commit
58759ff6b7
2 changed files with 31 additions and 4 deletions
|
@ -25,6 +25,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 ToggleEntity, ToggleEntityDescription
|
from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
@ -70,9 +75,20 @@ class RemoteEntityFeature(IntFlag):
|
||||||
|
|
||||||
# These SUPPORT_* constants are deprecated as of Home Assistant 2022.5.
|
# These SUPPORT_* constants are deprecated as of Home Assistant 2022.5.
|
||||||
# Please use the RemoteEntityFeature enum instead.
|
# Please use the RemoteEntityFeature enum instead.
|
||||||
SUPPORT_LEARN_COMMAND = 1
|
_DEPRECATED_SUPPORT_LEARN_COMMAND = DeprecatedConstantEnum(
|
||||||
SUPPORT_DELETE_COMMAND = 2
|
RemoteEntityFeature.LEARN_COMMAND, "2025.1"
|
||||||
SUPPORT_ACTIVITY = 4
|
)
|
||||||
|
_DEPRECATED_SUPPORT_DELETE_COMMAND = DeprecatedConstantEnum(
|
||||||
|
RemoteEntityFeature.DELETE_COMMAND, "2025.1"
|
||||||
|
)
|
||||||
|
_DEPRECATED_SUPPORT_ACTIVITY = DeprecatedConstantEnum(
|
||||||
|
RemoteEntityFeature.ACTIVITY, "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())
|
||||||
|
|
||||||
REMOTE_SERVICE_ACTIVITY_SCHEMA = make_entity_service_schema(
|
REMOTE_SERVICE_ACTIVITY_SCHEMA = make_entity_service_schema(
|
||||||
{vol.Optional(ATTR_ACTIVITY): cv.string}
|
{vol.Optional(ATTR_ACTIVITY): cv.string}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""The tests for the Remote component, adapted from Light Test."""
|
"""The tests for the Remote component, adapted from Light Test."""
|
||||||
|
import pytest
|
||||||
|
|
||||||
import homeassistant.components.remote as remote
|
import homeassistant.components.remote as remote
|
||||||
from homeassistant.components.remote import (
|
from homeassistant.components.remote import (
|
||||||
ATTR_ALTERNATIVE,
|
ATTR_ALTERNATIVE,
|
||||||
|
@ -20,7 +22,7 @@ from homeassistant.const import (
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from tests.common import async_mock_service
|
from tests.common import async_mock_service, import_and_test_deprecated_constant_enum
|
||||||
|
|
||||||
TEST_PLATFORM = {DOMAIN: {CONF_PLATFORM: "test"}}
|
TEST_PLATFORM = {DOMAIN: {CONF_PLATFORM: "test"}}
|
||||||
SERVICE_SEND_COMMAND = "send_command"
|
SERVICE_SEND_COMMAND = "send_command"
|
||||||
|
@ -139,3 +141,12 @@ async def test_delete_command(hass: HomeAssistant) -> None:
|
||||||
assert call.domain == remote.DOMAIN
|
assert call.domain == remote.DOMAIN
|
||||||
assert call.service == SERVICE_DELETE_COMMAND
|
assert call.service == SERVICE_DELETE_COMMAND
|
||||||
assert call.data[ATTR_ENTITY_ID] == ENTITY_ID
|
assert call.data[ATTR_ENTITY_ID] == ENTITY_ID
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(("enum"), list(remote.RemoteEntityFeature))
|
||||||
|
def test_deprecated_constants(
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
enum: remote.RemoteEntityFeature,
|
||||||
|
) -> None:
|
||||||
|
"""Test deprecated constants."""
|
||||||
|
import_and_test_deprecated_constant_enum(caplog, remote, enum, "SUPPORT_", "2025.1")
|
||||||
|
|
Loading…
Add table
Reference in a new issue