Add helper to report deprecated entity supported features magic numbers (#106602)
This commit is contained in:
parent
f93b0a4831
commit
a46fe94216
2 changed files with 55 additions and 1 deletions
|
@ -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
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue