hass-core/tests/components/intellifire/conftest.py
Jeef cea21a00b3
Add intellifire UDP discovery at configuration start (#67002)
Co-authored-by: J. Nick Koston <nick@koston.org>
2022-03-13 20:58:55 -10:00

51 lines
1.6 KiB
Python

"""Fixtures for IntelliFire integration tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, Mock, patch
import pytest
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
"""Mock setting up a config entry."""
with patch(
"homeassistant.components.intellifire.async_setup_entry", return_value=True
) as mock_setup:
yield mock_setup
@pytest.fixture()
def mock_fireplace_finder_none() -> Generator[None, MagicMock, None]:
"""Mock fireplace finder."""
mock_found_fireplaces = Mock()
mock_found_fireplaces.ips = []
with patch(
"homeassistant.components.intellifire.config_flow.AsyncUDPFireplaceFinder.search_fireplace"
):
yield mock_found_fireplaces
@pytest.fixture()
def mock_fireplace_finder_single() -> Generator[None, MagicMock, None]:
"""Mock fireplace finder."""
mock_found_fireplaces = Mock()
mock_found_fireplaces.ips = ["192.168.1.69"]
with patch(
"homeassistant.components.intellifire.config_flow.AsyncUDPFireplaceFinder.search_fireplace"
):
yield mock_found_fireplaces
@pytest.fixture
def mock_intellifire_config_flow() -> Generator[None, MagicMock, None]:
"""Return a mocked IntelliFire client."""
data_mock = Mock()
data_mock.serial = "12345"
with patch(
"homeassistant.components.intellifire.config_flow.IntellifireAsync",
autospec=True,
) as intellifire_mock:
intellifire = intellifire_mock.return_value
intellifire.data = data_mock
yield intellifire