mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Remove deprecated conductivity constants (#153942)
This commit is contained in:
@@ -1,19 +1,12 @@
|
||||
"""Test const module."""
|
||||
|
||||
from enum import Enum
|
||||
import logging
|
||||
import sys
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant import const
|
||||
|
||||
from .common import (
|
||||
extract_stack_to_frame,
|
||||
help_test_all,
|
||||
import_and_test_deprecated_constant,
|
||||
)
|
||||
from .common import help_test_all, import_and_test_deprecated_constant
|
||||
|
||||
|
||||
def _create_tuples(
|
||||
@@ -48,78 +41,3 @@ def test_deprecated_constant_name_changes(
|
||||
replacement,
|
||||
breaks_in_version,
|
||||
)
|
||||
|
||||
|
||||
def test_deprecated_unit_of_conductivity_alias() -> None:
|
||||
"""Test UnitOfConductivity deprecation."""
|
||||
|
||||
# Test the deprecated members are aliases
|
||||
assert set(const.UnitOfConductivity) == {"S/cm", "μS/cm", "mS/cm"}
|
||||
|
||||
|
||||
def test_deprecated_unit_of_conductivity_members(
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test UnitOfConductivity deprecation."""
|
||||
|
||||
module_name = "config.custom_components.hue.light"
|
||||
filename = f"/home/paulus/{module_name.replace('.', '/')}.py"
|
||||
|
||||
with (
|
||||
patch.dict(sys.modules, {module_name: Mock(__file__=filename)}),
|
||||
patch(
|
||||
"homeassistant.helpers.frame.linecache.getline",
|
||||
return_value="await session.close()",
|
||||
),
|
||||
patch(
|
||||
"homeassistant.helpers.frame.get_current_frame",
|
||||
return_value=extract_stack_to_frame(
|
||||
[
|
||||
Mock(
|
||||
filename="/home/paulus/homeassistant/core.py",
|
||||
lineno="23",
|
||||
line="do_something()",
|
||||
),
|
||||
Mock(
|
||||
filename=filename,
|
||||
lineno="23",
|
||||
line="await session.close()",
|
||||
),
|
||||
Mock(
|
||||
filename="/home/paulus/aiohue/lights.py",
|
||||
lineno="2",
|
||||
line="something()",
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
):
|
||||
const.UnitOfConductivity.SIEMENS # noqa: B018
|
||||
const.UnitOfConductivity.MICROSIEMENS # noqa: B018
|
||||
const.UnitOfConductivity.MILLISIEMENS # noqa: B018
|
||||
|
||||
assert len(caplog.record_tuples) == 3
|
||||
|
||||
def deprecation_message(member: str, replacement: str) -> str:
|
||||
return (
|
||||
f"The deprecated enum member UnitOfConductivity.{member} was used from hue. "
|
||||
"It will be removed in HA Core 2025.11.0. Use UnitOfConductivity."
|
||||
f"{replacement} instead, please report it to the author of the 'hue' custom"
|
||||
" integration"
|
||||
)
|
||||
|
||||
assert (
|
||||
const.__name__,
|
||||
logging.WARNING,
|
||||
deprecation_message("SIEMENS", "SIEMENS_PER_CM"),
|
||||
) in caplog.record_tuples
|
||||
assert (
|
||||
const.__name__,
|
||||
logging.WARNING,
|
||||
deprecation_message("MICROSIEMENS", "MICROSIEMENS_PER_CM"),
|
||||
) in caplog.record_tuples
|
||||
assert (
|
||||
const.__name__,
|
||||
logging.WARNING,
|
||||
deprecation_message("MILLISIEMENS", "MILLISIEMENS_PER_CM"),
|
||||
) in caplog.record_tuples
|
||||
|
||||
Reference in New Issue
Block a user