mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Improve TTS test fixtures (#93517)
This commit is contained in:
@@ -1,17 +1,10 @@
|
||||
"""Fixtures for component testing."""
|
||||
from collections.abc import Generator
|
||||
from unittest.mock import patch
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.components.tts.conftest import ( # noqa: F401, pylint: disable=unused-import
|
||||
init_tts_cache_dir_side_effect_fixture,
|
||||
mock_tts_cache_dir_fixture,
|
||||
mock_tts_get_cache_files_fixture,
|
||||
mock_tts_init_cache_dir_fixture,
|
||||
tts_mutagen_mock_fixture,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def patch_zeroconf_multiple_catcher() -> Generator[None, None, None]:
|
||||
@@ -40,3 +33,51 @@ def entity_registry_enabled_by_default() -> Generator[None, None, None]:
|
||||
return_value=True,
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(name="mock_tts_get_cache_files")
|
||||
def mock_tts_get_cache_files_fixture():
|
||||
"""Mock the list TTS cache function."""
|
||||
from tests.components.tts.common import mock_tts_get_cache_files_fixture_helper
|
||||
|
||||
yield from mock_tts_get_cache_files_fixture_helper()
|
||||
|
||||
|
||||
@pytest.fixture(name="mock_tts_init_cache_dir")
|
||||
def mock_tts_init_cache_dir_fixture(
|
||||
init_tts_cache_dir_side_effect: Any,
|
||||
) -> Generator[MagicMock, None, None]:
|
||||
"""Mock the TTS cache dir in memory."""
|
||||
from tests.components.tts.common import mock_tts_init_cache_dir_fixture_helper
|
||||
|
||||
yield from mock_tts_init_cache_dir_fixture_helper(init_tts_cache_dir_side_effect)
|
||||
|
||||
|
||||
@pytest.fixture(name="init_tts_cache_dir_side_effect")
|
||||
def init_tts_cache_dir_side_effect_fixture() -> Any:
|
||||
"""Return the cache dir."""
|
||||
from tests.components.tts.common import (
|
||||
init_tts_cache_dir_side_effect_fixture_helper,
|
||||
)
|
||||
|
||||
return init_tts_cache_dir_side_effect_fixture_helper()
|
||||
|
||||
|
||||
@pytest.fixture(name="mock_tts_cache_dir")
|
||||
def mock_tts_cache_dir_fixture(
|
||||
tmp_path, mock_tts_init_cache_dir, mock_tts_get_cache_files, request
|
||||
):
|
||||
"""Mock the TTS cache dir with empty dir."""
|
||||
from tests.components.tts.common import mock_tts_cache_dir_fixture_helper
|
||||
|
||||
yield from mock_tts_cache_dir_fixture_helper(
|
||||
tmp_path, mock_tts_init_cache_dir, mock_tts_get_cache_files, request
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(name="tts_mutagen_mock")
|
||||
def tts_mutagen_mock_fixture():
|
||||
"""Mock writing tags."""
|
||||
from tests.components.tts.common import tts_mutagen_mock_fixture_helper
|
||||
|
||||
yield from tts_mutagen_mock_fixture_helper()
|
||||
|
||||
Reference in New Issue
Block a user