mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Add helper to report deprecated entity supported features magic numbers (#106602)
This commit is contained in:
@@ -3,6 +3,7 @@ import asyncio
|
||||
from collections.abc import Iterable
|
||||
import dataclasses
|
||||
from datetime import timedelta
|
||||
from enum import IntFlag
|
||||
import logging
|
||||
import threading
|
||||
from typing import Any
|
||||
@@ -2025,3 +2026,28 @@ async def test_cached_entity_property_class_attribute(hass: HomeAssistant) -> No
|
||||
for ent in entities:
|
||||
assert getattr(ent[0], property) == values[1]
|
||||
assert getattr(ent[1], property) == values[0]
|
||||
|
||||
|
||||
async def test_entity_report_deprecated_supported_features_values(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test reporting deprecated supported feature values only happens once."""
|
||||
ent = entity.Entity()
|
||||
|
||||
class MockEntityFeatures(IntFlag):
|
||||
VALUE1 = 1
|
||||
VALUE2 = 2
|
||||
|
||||
ent._report_deprecated_supported_features_values(MockEntityFeatures(2))
|
||||
assert (
|
||||
"is using deprecated supported features values which will be removed"
|
||||
in caplog.text
|
||||
)
|
||||
assert "MockEntityFeatures.VALUE2" in caplog.text
|
||||
|
||||
caplog.clear()
|
||||
ent._report_deprecated_supported_features_values(MockEntityFeatures(2))
|
||||
assert (
|
||||
"is using deprecated supported features values which will be removed"
|
||||
not in caplog.text
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user