Revert logic change
This commit is contained in:
parent
4769e84bae
commit
60959a0050
2 changed files with 4 additions and 10 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue