Deprecate deprecated sensor constants (#106120)

This commit is contained in:
Robert Resch 2023-12-21 00:02:20 +01:00 committed by GitHub
parent 494a897568
commit d47ec91231
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 6 deletions

View file

@ -4,10 +4,12 @@ from __future__ import annotations
from collections.abc import Generator
from datetime import UTC, date, datetime
from decimal import Decimal
from types import ModuleType
from typing import Any
import pytest
from homeassistant.components import sensor
from homeassistant.components.number import NumberDeviceClass
from homeassistant.components.sensor import (
DEVICE_CLASS_STATE_CLASSES,
@ -50,6 +52,7 @@ from tests.common import (
MockModule,
MockPlatform,
async_mock_restore_state_shutdown_restart,
import_and_test_deprecated_constant_enum,
mock_config_flow,
mock_integration,
mock_platform,
@ -2519,3 +2522,16 @@ async def test_entity_category_config_raises_error(
)
assert not hass.states.get("sensor.test")
@pytest.mark.parametrize(("enum"), list(sensor.SensorStateClass))
@pytest.mark.parametrize(("module"), [sensor, sensor.const])
def test_deprecated_constants(
caplog: pytest.LogCaptureFixture,
enum: sensor.SensorStateClass,
module: ModuleType,
) -> None:
"""Test deprecated constants."""
import_and_test_deprecated_constant_enum(
caplog, module, enum, "STATE_CLASS_", "2025.1"
)