mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 18:58:04 +02:00
Revert logic change
This commit is contained in:
@ -215,9 +215,7 @@ def get_unit_system(key: str) -> UnitSystem:
|
||||
"""Get unit system based on key."""
|
||||
if key == _CONF_UNIT_SYSTEM_IMPERIAL:
|
||||
return IMPERIAL_SYSTEM
|
||||
if key == _CONF_UNIT_SYSTEM_METRIC:
|
||||
return METRIC_SYSTEM
|
||||
raise ValueError(f"`{key}` is not a valid unit system key")
|
||||
return METRIC_SYSTEM
|
||||
|
||||
|
||||
validate_unit_system = vol.All(
|
||||
|
@ -342,15 +342,11 @@ def test_deprecated_name(
|
||||
[
|
||||
(_CONF_UNIT_SYSTEM_METRIC, METRIC_SYSTEM),
|
||||
(_CONF_UNIT_SYSTEM_IMPERIAL, IMPERIAL_SYSTEM),
|
||||
(None, METRIC_SYSTEM),
|
||||
("", METRIC_SYSTEM),
|
||||
("unknown_system", METRIC_SYSTEM),
|
||||
],
|
||||
)
|
||||
def test_get_unit_system(key: str, expected_system: UnitSystem) -> None:
|
||||
"""Test get_unit_system."""
|
||||
assert get_unit_system(key) is expected_system
|
||||
|
||||
|
||||
@pytest.mark.parametrize("key", [None, "", "invalid_custom"])
|
||||
def test_get_unit_system_invalid(key: str) -> None:
|
||||
"""Test get_unit_system with an invalid key."""
|
||||
with pytest.raises(ValueError, match=f"`{key}` is not a valid unit system key"):
|
||||
_ = get_unit_system(key)
|
||||
|
Reference in New Issue
Block a user