Remove argument validation in Unit Converter (#79107)

* Remove argument validation in Unit Converter

* Use HomeAssistantError

* Adjust tests

* Improve coverage
This commit is contained in:
epenet 2022-09-28 10:58:04 +02:00 committed by GitHub
parent 1b8bed936c
commit c96c5bed7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 66 additions and 50 deletions

View file

@ -10,6 +10,7 @@ from homeassistant.const import (
VOLUME_LITERS,
VOLUME_MILLILITERS,
)
from homeassistant.exceptions import HomeAssistantError
import homeassistant.util.volume as volume_util
INVALID_SYMBOL = "bob"
@ -43,10 +44,10 @@ def test_convert_same_unit():
def test_convert_invalid_unit():
"""Test exception is thrown for invalid units."""
with pytest.raises(ValueError):
with pytest.raises(HomeAssistantError, match="is not a recognized .* unit"):
volume_util.convert(5, INVALID_SYMBOL, VALID_SYMBOL)
with pytest.raises(ValueError):
with pytest.raises(HomeAssistantError, match="is not a recognized .* unit"):
volume_util.convert(5, VALID_SYMBOL, INVALID_SYMBOL)