2023-03-30 05:42:09 +00:00
|
|
|
"""Test the snapcast config flow."""
|
2024-03-08 13:47:22 +00:00
|
|
|
|
2024-07-01 09:54:42 +00:00
|
|
|
from collections.abc import Generator
|
2024-05-03 11:29:05 +00:00
|
|
|
from unittest.mock import AsyncMock, MagicMock, patch
|
2023-03-30 05:42:09 +00:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2024-06-06 15:41:37 +00:00
|
|
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
2023-03-30 05:42:09 +00:00
|
|
|
"""Override async_setup_entry."""
|
|
|
|
with patch(
|
|
|
|
"homeassistant.components.snapcast.async_setup_entry", return_value=True
|
|
|
|
) as mock_setup_entry:
|
|
|
|
yield mock_setup_entry
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2024-06-06 15:41:37 +00:00
|
|
|
def mock_create_server() -> Generator[AsyncMock]:
|
2023-03-30 05:42:09 +00:00
|
|
|
"""Create mock snapcast connection."""
|
|
|
|
mock_connection = AsyncMock()
|
|
|
|
mock_connection.start = AsyncMock(return_value=None)
|
2024-05-03 11:29:05 +00:00
|
|
|
mock_connection.stop = MagicMock()
|
2023-03-30 05:42:09 +00:00
|
|
|
with patch("snapcast.control.create_server", return_value=mock_connection):
|
|
|
|
yield mock_connection
|