mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Remove deprecated support feature values in cover (#146987)
This commit is contained in:
parent
308c89af4a
commit
0926b16095
@ -300,10 +300,6 @@ class CoverEntity(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
|
|||||||
def supported_features(self) -> CoverEntityFeature:
|
def supported_features(self) -> CoverEntityFeature:
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
if (features := self._attr_supported_features) is not None:
|
if (features := self._attr_supported_features) is not None:
|
||||||
if type(features) is int:
|
|
||||||
new_features = CoverEntityFeature(features)
|
|
||||||
self._report_deprecated_supported_features_values(new_features)
|
|
||||||
return new_features
|
|
||||||
return features
|
return features
|
||||||
|
|
||||||
supported_features = (
|
supported_features = (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from homeassistant.components import cover
|
from homeassistant.components import cover
|
||||||
from homeassistant.components.cover import CoverState
|
from homeassistant.components.cover import CoverState
|
||||||
from homeassistant.const import ATTR_ENTITY_ID, CONF_PLATFORM, SERVICE_TOGGLE
|
from homeassistant.const import ATTR_ENTITY_ID, CONF_PLATFORM, SERVICE_TOGGLE
|
||||||
@ -13,11 +11,7 @@ from homeassistant.setup import async_setup_component
|
|||||||
|
|
||||||
from .common import MockCover
|
from .common import MockCover
|
||||||
|
|
||||||
from tests.common import (
|
from tests.common import help_test_all, setup_test_component_platform
|
||||||
MockEntityPlatform,
|
|
||||||
help_test_all,
|
|
||||||
setup_test_component_platform,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def test_services(
|
async def test_services(
|
||||||
@ -159,24 +153,3 @@ def _create_tuples(enum: type[Enum], constant_prefix: str) -> list[tuple[Enum, s
|
|||||||
def test_all() -> None:
|
def test_all() -> None:
|
||||||
"""Test module.__all__ is correctly set."""
|
"""Test module.__all__ is correctly set."""
|
||||||
help_test_all(cover)
|
help_test_all(cover)
|
||||||
|
|
||||||
|
|
||||||
def test_deprecated_supported_features_ints(
|
|
||||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
|
||||||
) -> None:
|
|
||||||
"""Test deprecated supported features ints."""
|
|
||||||
|
|
||||||
class MockCoverEntity(cover.CoverEntity):
|
|
||||||
_attr_supported_features = 1
|
|
||||||
|
|
||||||
entity = MockCoverEntity()
|
|
||||||
entity.hass = hass
|
|
||||||
entity.platform = MockEntityPlatform(hass)
|
|
||||||
assert entity.supported_features is cover.CoverEntityFeature(1)
|
|
||||||
assert "MockCoverEntity" in caplog.text
|
|
||||||
assert "is using deprecated supported features values" in caplog.text
|
|
||||||
assert "Instead it should use" in caplog.text
|
|
||||||
assert "CoverEntityFeature.OPEN" in caplog.text
|
|
||||||
caplog.clear()
|
|
||||||
assert entity.supported_features is cover.CoverEntityFeature(1)
|
|
||||||
assert "is using deprecated supported features values" not in caplog.text
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user