Remove argument validation in Unit Converter (#79107)
* Remove argument validation in Unit Converter * Use HomeAssistantError * Adjust tests * Improve coverage
This commit is contained in:
parent
1b8bed936c
commit
c96c5bed7d
8 changed files with 66 additions and 50 deletions
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue