mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +00:00
Improve negative TTS test (#126126)
This commit is contained in:
parent
4d04402ad4
commit
2190054abf
@ -1,6 +1,7 @@
|
|||||||
"""Tests for TTS media source."""
|
"""Tests for TTS media source."""
|
||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
import re
|
||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -169,29 +170,34 @@ async def test_resolving(
|
|||||||
[(MSProvider(DEFAULT_LANG), MSEntity(DEFAULT_LANG))],
|
[(MSProvider(DEFAULT_LANG), MSEntity(DEFAULT_LANG))],
|
||||||
)
|
)
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"setup",
|
("setup", "engine"),
|
||||||
[
|
[
|
||||||
"mock_setup",
|
("mock_setup", "test"),
|
||||||
"mock_config_entry_setup",
|
("mock_config_entry_setup", "tts.test"),
|
||||||
],
|
],
|
||||||
indirect=["setup"],
|
indirect=["setup"],
|
||||||
)
|
)
|
||||||
async def test_resolving_errors(hass: HomeAssistant, setup: str) -> None:
|
async def test_resolving_errors(hass: HomeAssistant, setup: str, engine: str) -> None:
|
||||||
"""Test resolving."""
|
"""Test resolving."""
|
||||||
# No message added
|
# No message added
|
||||||
with pytest.raises(media_source.Unresolvable):
|
with pytest.raises(media_source.Unresolvable):
|
||||||
await media_source.async_resolve_media(hass, "media-source://tts/test", None)
|
await media_source.async_resolve_media(hass, "media-source://tts/test", None)
|
||||||
|
|
||||||
# Non-existing provider
|
# Non-existing provider
|
||||||
with pytest.raises(media_source.Unresolvable):
|
with pytest.raises(
|
||||||
|
media_source.Unresolvable, match="Provider non-existing not found"
|
||||||
|
):
|
||||||
await media_source.async_resolve_media(
|
await media_source.async_resolve_media(
|
||||||
hass, "media-source://tts/non-existing?message=bla", None
|
hass, "media-source://tts/non-existing?message=bla", None
|
||||||
)
|
)
|
||||||
|
|
||||||
# Non-existing option
|
# Non-existing option
|
||||||
with pytest.raises(media_source.Unresolvable):
|
with pytest.raises(
|
||||||
|
media_source.Unresolvable,
|
||||||
|
match=re.escape("Invalid options found: ['non_existing_option']"),
|
||||||
|
):
|
||||||
await media_source.async_resolve_media(
|
await media_source.async_resolve_media(
|
||||||
hass,
|
hass,
|
||||||
"media-source://tts/non-existing?message=bla&non_existing_option=bla",
|
f"media-source://tts/{engine}?message=bla&non_existing_option=bla",
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user