Remove deprecated camera constants (#131796)

pull/131818/head
Robert Resch 2024-11-28 11:05:45 +01:00 committed by GitHub
parent 717f2ee206
commit 28ec8272ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 2 additions and 68 deletions

View File

@ -67,9 +67,7 @@ from homeassistant.helpers.template import Template
from homeassistant.helpers.typing import ConfigType, VolDictType from homeassistant.helpers.typing import ConfigType, VolDictType
from homeassistant.loader import bind_hass from homeassistant.loader import bind_hass
from .const import ( # noqa: F401 from .const import (
_DEPRECATED_STREAM_TYPE_HLS,
_DEPRECATED_STREAM_TYPE_WEB_RTC,
CAMERA_IMAGE_TIMEOUT, CAMERA_IMAGE_TIMEOUT,
CAMERA_STREAM_SOURCE_TIMEOUT, CAMERA_STREAM_SOURCE_TIMEOUT,
CONF_DURATION, CONF_DURATION,
@ -135,16 +133,6 @@ class CameraEntityFeature(IntFlag):
STREAM = 2 STREAM = 2
# These SUPPORT_* constants are deprecated as of Home Assistant 2022.5.
# Pleease use the CameraEntityFeature enum instead.
_DEPRECATED_SUPPORT_ON_OFF: Final = DeprecatedConstantEnum(
CameraEntityFeature.ON_OFF, "2025.1"
)
_DEPRECATED_SUPPORT_STREAM: Final = DeprecatedConstantEnum(
CameraEntityFeature.STREAM, "2025.1"
)
DEFAULT_CONTENT_TYPE: Final = "image/jpeg" DEFAULT_CONTENT_TYPE: Final = "image/jpeg"
ENTITY_IMAGE_URL: Final = "/api/camera_proxy/{0}?token={1}" ENTITY_IMAGE_URL: Final = "/api/camera_proxy/{0}?token={1}"

View File

@ -3,15 +3,8 @@
from __future__ import annotations from __future__ import annotations
from enum import StrEnum from enum import StrEnum
from functools import partial
from typing import TYPE_CHECKING, Final from typing import TYPE_CHECKING, Final
from homeassistant.helpers.deprecation import (
DeprecatedConstantEnum,
all_with_deprecated_constants,
check_if_deprecated_constant,
dir_with_deprecated_constants,
)
from homeassistant.util.hass_dict import HassKey from homeassistant.util.hass_dict import HassKey
if TYPE_CHECKING: if TYPE_CHECKING:
@ -58,17 +51,3 @@ class StreamType(StrEnum):
HLS = "hls" HLS = "hls"
WEB_RTC = "web_rtc" WEB_RTC = "web_rtc"
# These constants are deprecated as of Home Assistant 2022.5
# Please use the StreamType enum instead.
_DEPRECATED_STREAM_TYPE_HLS = DeprecatedConstantEnum(StreamType.HLS, "2025.1")
_DEPRECATED_STREAM_TYPE_WEB_RTC = DeprecatedConstantEnum(StreamType.WEB_RTC, "2025.1")
# These can be removed if no deprecated constant are in this module anymore
__getattr__ = partial(check_if_deprecated_constant, module_globals=globals())
__dir__ = partial(
dir_with_deprecated_constants, module_globals_keys=[*globals().keys()]
)
__all__ = all_with_deprecated_constants(globals())

View File

@ -802,32 +802,13 @@ async def test_use_stream_for_stills(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"module", "module",
[camera, camera.const], [camera],
) )
def test_all(module: ModuleType) -> None: def test_all(module: ModuleType) -> None:
"""Test module.__all__ is correctly set.""" """Test module.__all__ is correctly set."""
help_test_all(module) help_test_all(module)
@pytest.mark.parametrize(
"enum",
list(camera.const.StreamType),
)
@pytest.mark.parametrize(
"module",
[camera, camera.const],
)
def test_deprecated_stream_type_constants(
caplog: pytest.LogCaptureFixture,
enum: camera.const.StreamType,
module: ModuleType,
) -> None:
"""Test deprecated stream type constants."""
import_and_test_deprecated_constant_enum(
caplog, module, enum, "STREAM_TYPE_", "2025.1"
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"enum", "enum",
list(camera.const.CameraState), list(camera.const.CameraState),
@ -845,20 +826,6 @@ def test_deprecated_state_constants(
import_and_test_deprecated_constant_enum(caplog, module, enum, "STATE_", "2025.10") import_and_test_deprecated_constant_enum(caplog, module, enum, "STATE_", "2025.10")
@pytest.mark.parametrize(
"entity_feature",
list(camera.CameraEntityFeature),
)
def test_deprecated_support_constants(
caplog: pytest.LogCaptureFixture,
entity_feature: camera.CameraEntityFeature,
) -> None:
"""Test deprecated support constants."""
import_and_test_deprecated_constant_enum(
caplog, camera, entity_feature, "SUPPORT_", "2025.1"
)
def test_deprecated_supported_features_ints(caplog: pytest.LogCaptureFixture) -> None: def test_deprecated_supported_features_ints(caplog: pytest.LogCaptureFixture) -> None:
"""Test deprecated supported features ints.""" """Test deprecated supported features ints."""