Add type hints for TTS test fixtures (#118704)
This commit is contained in:
parent
32d4431f9b
commit
f178467b0e
16 changed files with 72 additions and 42 deletions
|
@ -130,6 +130,7 @@ _TEST_FIXTURES: dict[str, list[str] | str] = {
|
||||||
"hass_supervisor_access_token": "str",
|
"hass_supervisor_access_token": "str",
|
||||||
"hass_supervisor_user": "MockUser",
|
"hass_supervisor_user": "MockUser",
|
||||||
"hass_ws_client": "WebSocketGenerator",
|
"hass_ws_client": "WebSocketGenerator",
|
||||||
|
"init_tts_cache_dir_side_effect": "Any",
|
||||||
"issue_registry": "IssueRegistry",
|
"issue_registry": "IssueRegistry",
|
||||||
"legacy_auth": "LegacyApiPasswordAuthProvider",
|
"legacy_auth": "LegacyApiPasswordAuthProvider",
|
||||||
"local_auth": "HassAuthProvider",
|
"local_auth": "HassAuthProvider",
|
||||||
|
@ -141,6 +142,9 @@ _TEST_FIXTURES: dict[str, list[str] | str] = {
|
||||||
"mock_get_source_ip": "_patch",
|
"mock_get_source_ip": "_patch",
|
||||||
"mock_hass_config": "None",
|
"mock_hass_config": "None",
|
||||||
"mock_hass_config_yaml": "None",
|
"mock_hass_config_yaml": "None",
|
||||||
|
"mock_tts_cache_dir": "Path",
|
||||||
|
"mock_tts_get_cache_files": "MagicMock",
|
||||||
|
"mock_tts_init_cache_dir": "MagicMock",
|
||||||
"mock_zeroconf": "MagicMock",
|
"mock_zeroconf": "MagicMock",
|
||||||
"mqtt_client_mock": "MqttMockPahoClient",
|
"mqtt_client_mock": "MqttMockPahoClient",
|
||||||
"mqtt_mock": "MqttMockHAClient",
|
"mqtt_mock": "MqttMockHAClient",
|
||||||
|
@ -153,6 +157,7 @@ _TEST_FIXTURES: dict[str, list[str] | str] = {
|
||||||
"stub_blueprint_populate": "None",
|
"stub_blueprint_populate": "None",
|
||||||
"tmp_path": "Path",
|
"tmp_path": "Path",
|
||||||
"tmpdir": "py.path.local",
|
"tmpdir": "py.path.local",
|
||||||
|
"tts_mutagen_mock": "MagicMock",
|
||||||
"unused_tcp_port_factory": "Callable[[], int]",
|
"unused_tcp_port_factory": "Callable[[], int]",
|
||||||
"unused_udp_port_factory": "Callable[[], int]",
|
"unused_udp_port_factory": "Callable[[], int]",
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import AsyncIterable, Generator
|
from collections.abc import AsyncIterable, Generator
|
||||||
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ _TRANSCRIPT = "test transcript"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_tts_cache_dir_autouse(mock_tts_cache_dir):
|
def mock_tts_cache_dir_autouse(mock_tts_cache_dir: Path) -> Path:
|
||||||
"""Mock the TTS cache dir with empty dir."""
|
"""Mock the TTS cache dir with empty dir."""
|
||||||
return mock_tts_cache_dir
|
return mock_tts_cache_dir
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""Fixtures for cloud tests."""
|
"""Fixtures for cloud tests."""
|
||||||
|
|
||||||
from collections.abc import AsyncGenerator, Callable, Coroutine
|
from collections.abc import AsyncGenerator, Callable, Coroutine
|
||||||
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import DEFAULT, MagicMock, PropertyMock, patch
|
from unittest.mock import DEFAULT, MagicMock, PropertyMock, patch
|
||||||
|
|
||||||
|
@ -180,13 +181,13 @@ def set_cloud_prefs_fixture(
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_tts_cache_dir_autouse(mock_tts_cache_dir):
|
def mock_tts_cache_dir_autouse(mock_tts_cache_dir: Path) -> Path:
|
||||||
"""Mock the TTS cache dir with empty dir."""
|
"""Mock the TTS cache dir with empty dir."""
|
||||||
return mock_tts_cache_dir
|
return mock_tts_cache_dir
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def tts_mutagen_mock_fixture_autouse(tts_mutagen_mock):
|
def tts_mutagen_mock_fixture_autouse(tts_mutagen_mock: MagicMock) -> None:
|
||||||
"""Mock writing tags."""
|
"""Mock writing tags."""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable, Generator
|
from collections.abc import Callable, Generator
|
||||||
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ def stub_blueprint_populate_fixture() -> Generator[None, None, None]:
|
||||||
|
|
||||||
# TTS test fixtures
|
# TTS test fixtures
|
||||||
@pytest.fixture(name="mock_tts_get_cache_files")
|
@pytest.fixture(name="mock_tts_get_cache_files")
|
||||||
def mock_tts_get_cache_files_fixture():
|
def mock_tts_get_cache_files_fixture() -> Generator[MagicMock, None, None]:
|
||||||
"""Mock the list TTS cache function."""
|
"""Mock the list TTS cache function."""
|
||||||
from tests.components.tts.common import mock_tts_get_cache_files_fixture_helper
|
from tests.components.tts.common import mock_tts_get_cache_files_fixture_helper
|
||||||
|
|
||||||
|
@ -88,8 +89,11 @@ def init_tts_cache_dir_side_effect_fixture() -> Any:
|
||||||
|
|
||||||
@pytest.fixture(name="mock_tts_cache_dir")
|
@pytest.fixture(name="mock_tts_cache_dir")
|
||||||
def mock_tts_cache_dir_fixture(
|
def mock_tts_cache_dir_fixture(
|
||||||
tmp_path, mock_tts_init_cache_dir, mock_tts_get_cache_files, request
|
tmp_path: Path,
|
||||||
):
|
mock_tts_init_cache_dir: MagicMock,
|
||||||
|
mock_tts_get_cache_files: MagicMock,
|
||||||
|
request: pytest.FixtureRequest,
|
||||||
|
) -> Generator[Path, None, None]:
|
||||||
"""Mock the TTS cache dir with empty dir."""
|
"""Mock the TTS cache dir with empty dir."""
|
||||||
from tests.components.tts.common import mock_tts_cache_dir_fixture_helper
|
from tests.components.tts.common import mock_tts_cache_dir_fixture_helper
|
||||||
|
|
||||||
|
@ -99,7 +103,7 @@ def mock_tts_cache_dir_fixture(
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="tts_mutagen_mock")
|
@pytest.fixture(name="tts_mutagen_mock")
|
||||||
def tts_mutagen_mock_fixture():
|
def tts_mutagen_mock_fixture() -> Generator[MagicMock, None, None]:
|
||||||
"""Mock writing tags."""
|
"""Mock writing tags."""
|
||||||
from tests.components.tts.common import tts_mutagen_mock_fixture_helper
|
from tests.components.tts.common import tts_mutagen_mock_fixture_helper
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ from __future__ import annotations
|
||||||
import asyncio
|
import asyncio
|
||||||
from asyncio import Event
|
from asyncio import Event
|
||||||
from collections.abc import Awaitable, Callable
|
from collections.abc import Awaitable, Callable
|
||||||
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import AsyncMock, Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ async def load_homeassistant(hass) -> None:
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_tts(mock_tts_cache_dir):
|
def mock_tts(mock_tts_cache_dir: Path) -> None:
|
||||||
"""Auto mock the tts cache."""
|
"""Auto mock the tts cache."""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
@ -28,12 +29,12 @@ from tests.typing import ClientSessionGenerator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def tts_mutagen_mock_fixture_autouse(tts_mutagen_mock):
|
def tts_mutagen_mock_fixture_autouse(tts_mutagen_mock: MagicMock) -> None:
|
||||||
"""Mock writing tags."""
|
"""Mock writing tags."""
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_tts_cache_dir_autouse(mock_tts_cache_dir):
|
def mock_tts_cache_dir_autouse(mock_tts_cache_dir: Path) -> Path:
|
||||||
"""Mock the TTS cache dir with empty dir."""
|
"""Mock the TTS cache dir with empty dir."""
|
||||||
return mock_tts_cache_dir
|
return mock_tts_cache_dir
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import io
|
import io
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
import wave
|
import wave
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ def get_empty_wav() -> bytes:
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_tts_cache_dir_autouse(mock_tts_cache_dir):
|
def mock_tts_cache_dir_autouse(mock_tts_cache_dir: Path) -> Path:
|
||||||
"""Mock the TTS cache dir with empty dir."""
|
"""Mock the TTS cache dir with empty dir."""
|
||||||
return mock_tts_cache_dir
|
return mock_tts_cache_dir
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""Tests for Microsoft text-to-speech."""
|
"""Tests for Microsoft text-to-speech."""
|
||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from pycsspeechtts import pycsspeechtts
|
from pycsspeechtts import pycsspeechtts
|
||||||
|
@ -24,7 +25,7 @@ from tests.typing import ClientSessionGenerator
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_tts_cache_dir_autouse(mock_tts_cache_dir):
|
def mock_tts_cache_dir_autouse(mock_tts_cache_dir: Path) -> Path:
|
||||||
"""Mock the TTS cache dir with empty dir."""
|
"""Mock the TTS cache dir with empty dir."""
|
||||||
return mock_tts_cache_dir
|
return mock_tts_cache_dir
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ SUPPORT_LANGUAGES = ["de_CH", "de_DE", "en_GB", "en_US"]
|
||||||
TEST_DOMAIN = "test"
|
TEST_DOMAIN = "test"
|
||||||
|
|
||||||
|
|
||||||
def mock_tts_get_cache_files_fixture_helper():
|
def mock_tts_get_cache_files_fixture_helper() -> Generator[MagicMock, None, None]:
|
||||||
"""Mock the list TTS cache function."""
|
"""Mock the list TTS cache function."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.tts._get_cache_files", return_value={}
|
"homeassistant.components.tts._get_cache_files", return_value={}
|
||||||
|
@ -66,8 +67,11 @@ def init_tts_cache_dir_side_effect_fixture_helper() -> Any:
|
||||||
|
|
||||||
|
|
||||||
def mock_tts_cache_dir_fixture_helper(
|
def mock_tts_cache_dir_fixture_helper(
|
||||||
tmp_path, mock_tts_init_cache_dir, mock_tts_get_cache_files, request
|
tmp_path: Path,
|
||||||
):
|
mock_tts_init_cache_dir: MagicMock,
|
||||||
|
mock_tts_get_cache_files: MagicMock,
|
||||||
|
request: pytest.FixtureRequest,
|
||||||
|
) -> Generator[Path, None, None]:
|
||||||
"""Mock the TTS cache dir with empty dir."""
|
"""Mock the TTS cache dir with empty dir."""
|
||||||
mock_tts_init_cache_dir.return_value = str(tmp_path)
|
mock_tts_init_cache_dir.return_value = str(tmp_path)
|
||||||
|
|
||||||
|
@ -88,7 +92,7 @@ def mock_tts_cache_dir_fixture_helper(
|
||||||
pytest.fail("Test failed, see log for details")
|
pytest.fail("Test failed, see log for details")
|
||||||
|
|
||||||
|
|
||||||
def tts_mutagen_mock_fixture_helper():
|
def tts_mutagen_mock_fixture_helper() -> Generator[MagicMock, None, None]:
|
||||||
"""Mock writing tags."""
|
"""Mock writing tags."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.tts.SpeechManager.write_tags",
|
"homeassistant.components.tts.SpeechManager.write_tags",
|
||||||
|
|
|
@ -4,6 +4,8 @@ From http://doc.pytest.org/en/latest/example/simple.html#making-test-result-info
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
|
from pathlib import Path
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -37,13 +39,13 @@ def pytest_runtest_makereport(item, call):
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True, name="mock_tts_cache_dir")
|
@pytest.fixture(autouse=True, name="mock_tts_cache_dir")
|
||||||
def mock_tts_cache_dir_fixture_autouse(mock_tts_cache_dir):
|
def mock_tts_cache_dir_fixture_autouse(mock_tts_cache_dir: Path) -> Path:
|
||||||
"""Mock the TTS cache dir with empty dir."""
|
"""Mock the TTS cache dir with empty dir."""
|
||||||
return mock_tts_cache_dir
|
return mock_tts_cache_dir
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def tts_mutagen_mock_fixture_autouse(tts_mutagen_mock):
|
def tts_mutagen_mock_fixture_autouse(tts_mutagen_mock: MagicMock) -> None:
|
||||||
"""Mock writing tags."""
|
"""Mock writing tags."""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest.mock import MagicMock, patch
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
@ -187,7 +188,7 @@ async def test_setup_component_no_access_cache_folder(
|
||||||
)
|
)
|
||||||
async def test_service(
|
async def test_service(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
setup: str,
|
setup: str,
|
||||||
tts_service: str,
|
tts_service: str,
|
||||||
service_data: dict[str, Any],
|
service_data: dict[str, Any],
|
||||||
|
@ -248,7 +249,7 @@ async def test_service(
|
||||||
)
|
)
|
||||||
async def test_service_default_language(
|
async def test_service_default_language(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
setup: str,
|
setup: str,
|
||||||
tts_service: str,
|
tts_service: str,
|
||||||
service_data: dict[str, Any],
|
service_data: dict[str, Any],
|
||||||
|
@ -309,7 +310,7 @@ async def test_service_default_language(
|
||||||
)
|
)
|
||||||
async def test_service_default_special_language(
|
async def test_service_default_special_language(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
setup: str,
|
setup: str,
|
||||||
tts_service: str,
|
tts_service: str,
|
||||||
service_data: dict[str, Any],
|
service_data: dict[str, Any],
|
||||||
|
@ -366,7 +367,7 @@ async def test_service_default_special_language(
|
||||||
)
|
)
|
||||||
async def test_service_language(
|
async def test_service_language(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
setup: str,
|
setup: str,
|
||||||
tts_service: str,
|
tts_service: str,
|
||||||
service_data: dict[str, Any],
|
service_data: dict[str, Any],
|
||||||
|
@ -423,7 +424,7 @@ async def test_service_language(
|
||||||
)
|
)
|
||||||
async def test_service_wrong_language(
|
async def test_service_wrong_language(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
setup: str,
|
setup: str,
|
||||||
tts_service: str,
|
tts_service: str,
|
||||||
service_data: dict[str, Any],
|
service_data: dict[str, Any],
|
||||||
|
@ -477,7 +478,7 @@ async def test_service_wrong_language(
|
||||||
)
|
)
|
||||||
async def test_service_options(
|
async def test_service_options(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
setup: str,
|
setup: str,
|
||||||
tts_service: str,
|
tts_service: str,
|
||||||
service_data: dict[str, Any],
|
service_data: dict[str, Any],
|
||||||
|
@ -561,7 +562,7 @@ class MockEntityWithDefaults(MockTTSEntity):
|
||||||
)
|
)
|
||||||
async def test_service_default_options(
|
async def test_service_default_options(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
setup: str,
|
setup: str,
|
||||||
tts_service: str,
|
tts_service: str,
|
||||||
service_data: dict[str, Any],
|
service_data: dict[str, Any],
|
||||||
|
@ -629,7 +630,7 @@ async def test_service_default_options(
|
||||||
)
|
)
|
||||||
async def test_merge_default_service_options(
|
async def test_merge_default_service_options(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
setup: str,
|
setup: str,
|
||||||
tts_service: str,
|
tts_service: str,
|
||||||
service_data: dict[str, Any],
|
service_data: dict[str, Any],
|
||||||
|
@ -696,7 +697,7 @@ async def test_merge_default_service_options(
|
||||||
)
|
)
|
||||||
async def test_service_wrong_options(
|
async def test_service_wrong_options(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
setup: str,
|
setup: str,
|
||||||
tts_service: str,
|
tts_service: str,
|
||||||
service_data: dict[str, Any],
|
service_data: dict[str, Any],
|
||||||
|
@ -752,7 +753,7 @@ async def test_service_wrong_options(
|
||||||
)
|
)
|
||||||
async def test_service_clear_cache(
|
async def test_service_clear_cache(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
setup: str,
|
setup: str,
|
||||||
tts_service: str,
|
tts_service: str,
|
||||||
service_data: dict[str, Any],
|
service_data: dict[str, Any],
|
||||||
|
@ -814,7 +815,7 @@ async def test_service_clear_cache(
|
||||||
async def test_service_receive_voice(
|
async def test_service_receive_voice(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
setup: str,
|
setup: str,
|
||||||
tts_service: str,
|
tts_service: str,
|
||||||
service_data: dict[str, Any],
|
service_data: dict[str, Any],
|
||||||
|
@ -886,7 +887,7 @@ async def test_service_receive_voice(
|
||||||
async def test_service_receive_voice_german(
|
async def test_service_receive_voice_german(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
setup: str,
|
setup: str,
|
||||||
tts_service: str,
|
tts_service: str,
|
||||||
service_data: dict[str, Any],
|
service_data: dict[str, Any],
|
||||||
|
@ -994,7 +995,7 @@ async def test_web_view_wrong_filename(
|
||||||
)
|
)
|
||||||
async def test_service_without_cache(
|
async def test_service_without_cache(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
setup: str,
|
setup: str,
|
||||||
tts_service: str,
|
tts_service: str,
|
||||||
service_data: dict[str, Any],
|
service_data: dict[str, Any],
|
||||||
|
@ -1042,7 +1043,7 @@ class MockEntityBoom(MockTTSEntity):
|
||||||
@pytest.mark.parametrize("mock_provider", [MockProviderBoom(DEFAULT_LANG)])
|
@pytest.mark.parametrize("mock_provider", [MockProviderBoom(DEFAULT_LANG)])
|
||||||
async def test_setup_legacy_cache_dir(
|
async def test_setup_legacy_cache_dir(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
mock_provider: MockProvider,
|
mock_provider: MockProvider,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up a TTS platform with cache and call service without cache."""
|
"""Set up a TTS platform with cache and call service without cache."""
|
||||||
|
@ -1078,7 +1079,7 @@ async def test_setup_legacy_cache_dir(
|
||||||
@pytest.mark.parametrize("mock_tts_entity", [MockEntityBoom(DEFAULT_LANG)])
|
@pytest.mark.parametrize("mock_tts_entity", [MockEntityBoom(DEFAULT_LANG)])
|
||||||
async def test_setup_cache_dir(
|
async def test_setup_cache_dir(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
mock_tts_entity: MockTTSEntity,
|
mock_tts_entity: MockTTSEntity,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up a TTS platform with cache and call service without cache."""
|
"""Set up a TTS platform with cache and call service without cache."""
|
||||||
|
@ -1185,7 +1186,7 @@ async def test_service_get_tts_error(
|
||||||
async def test_load_cache_legacy_retrieve_without_mem_cache(
|
async def test_load_cache_legacy_retrieve_without_mem_cache(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_provider: MockProvider,
|
mock_provider: MockProvider,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up component and load cache and get without mem cache."""
|
"""Set up component and load cache and get without mem cache."""
|
||||||
|
@ -1211,7 +1212,7 @@ async def test_load_cache_legacy_retrieve_without_mem_cache(
|
||||||
async def test_load_cache_retrieve_without_mem_cache(
|
async def test_load_cache_retrieve_without_mem_cache(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_tts_entity: MockTTSEntity,
|
mock_tts_entity: MockTTSEntity,
|
||||||
mock_tts_cache_dir,
|
mock_tts_cache_dir: Path,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up component and load cache and get without mem cache."""
|
"""Set up component and load cache and get without mem cache."""
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.media_player import (
|
from homeassistant.components.media_player import (
|
||||||
|
@ -139,7 +141,7 @@ async def test_platform_setup_with_error(
|
||||||
|
|
||||||
|
|
||||||
async def test_service_without_cache_config(
|
async def test_service_without_cache_config(
|
||||||
hass: HomeAssistant, mock_tts_cache_dir, mock_tts
|
hass: HomeAssistant, mock_tts_cache_dir: Path, mock_tts
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up a TTS platform without cache."""
|
"""Set up a TTS platform without cache."""
|
||||||
calls = async_mock_service(hass, DOMAIN_MP, SERVICE_PLAY_MEDIA)
|
calls = async_mock_service(hass, DOMAIN_MP, SERVICE_PLAY_MEDIA)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
"""The tests for the VoiceRSS speech platform."""
|
"""The tests for the VoiceRSS speech platform."""
|
||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
from pathlib import Path
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -29,12 +31,12 @@ FORM_DATA = {
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def tts_mutagen_mock_fixture_autouse(tts_mutagen_mock):
|
def tts_mutagen_mock_fixture_autouse(tts_mutagen_mock: MagicMock) -> None:
|
||||||
"""Mock writing tags."""
|
"""Mock writing tags."""
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_tts_cache_dir_autouse(mock_tts_cache_dir):
|
def mock_tts_cache_dir_autouse(mock_tts_cache_dir: Path) -> Path:
|
||||||
"""Mock the TTS cache dir with empty dir."""
|
"""Mock the TTS cache dir with empty dir."""
|
||||||
return mock_tts_cache_dir
|
return mock_tts_cache_dir
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import io
|
import io
|
||||||
|
from pathlib import Path
|
||||||
import time
|
import time
|
||||||
from unittest.mock import AsyncMock, Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
import wave
|
import wave
|
||||||
|
@ -18,7 +19,7 @@ _MEDIA_ID = "12345"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_tts_cache_dir_autouse(mock_tts_cache_dir):
|
def mock_tts_cache_dir_autouse(mock_tts_cache_dir: Path) -> Path:
|
||||||
"""Mock the TTS cache dir with empty dir."""
|
"""Mock the TTS cache dir with empty dir."""
|
||||||
return mock_tts_cache_dir
|
return mock_tts_cache_dir
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""Common fixtures for the Wyoming tests."""
|
"""Common fixtures for the Wyoming tests."""
|
||||||
|
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
|
from pathlib import Path
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -18,7 +19,7 @@ from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_tts_cache_dir_autouse(mock_tts_cache_dir):
|
def mock_tts_cache_dir_autouse(mock_tts_cache_dir: Path) -> Path:
|
||||||
"""Mock the TTS cache dir with empty dir."""
|
"""Mock the TTS cache dir with empty dir."""
|
||||||
return mock_tts_cache_dir
|
return mock_tts_cache_dir
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
"""The tests for the Yandex SpeechKit speech platform."""
|
"""The tests for the Yandex SpeechKit speech platform."""
|
||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
from pathlib import Path
|
||||||
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -22,12 +24,12 @@ URL = "https://tts.voicetech.yandex.net/generate?"
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def tts_mutagen_mock_fixture_autouse(tts_mutagen_mock):
|
def tts_mutagen_mock_fixture_autouse(tts_mutagen_mock: MagicMock) -> None:
|
||||||
"""Mock writing tags."""
|
"""Mock writing tags."""
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_tts_cache_dir_autouse(mock_tts_cache_dir):
|
def mock_tts_cache_dir_autouse(mock_tts_cache_dir: Path) -> Path:
|
||||||
"""Mock the TTS cache dir with empty dir."""
|
"""Mock the TTS cache dir with empty dir."""
|
||||||
return mock_tts_cache_dir
|
return mock_tts_cache_dir
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue