2023-09-09 15:39:54 -07:00
|
|
|
"""Setup fixtures for ScreenLogic integration tests."""
|
2024-03-08 19:16:21 +01:00
|
|
|
|
2026-02-19 12:57:55 +01:00
|
|
|
from collections.abc import Generator
|
|
|
|
|
from unittest.mock import Mock, patch
|
|
|
|
|
|
2023-09-09 15:39:54 -07:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from homeassistant.components.screenlogic import DOMAIN
|
|
|
|
|
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, CONF_SCAN_INTERVAL
|
|
|
|
|
|
2024-05-09 05:19:58 -07:00
|
|
|
from . import (
|
|
|
|
|
MOCK_ADAPTER_IP,
|
|
|
|
|
MOCK_ADAPTER_MAC,
|
|
|
|
|
MOCK_ADAPTER_NAME,
|
|
|
|
|
MOCK_ADAPTER_PORT,
|
|
|
|
|
MOCK_CONFIG_ENTRY_ID,
|
|
|
|
|
)
|
2023-09-09 15:39:54 -07:00
|
|
|
|
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def mock_config_entry() -> MockConfigEntry:
|
|
|
|
|
"""Return a mocked config entry."""
|
|
|
|
|
return MockConfigEntry(
|
|
|
|
|
title=MOCK_ADAPTER_NAME,
|
|
|
|
|
domain=DOMAIN,
|
|
|
|
|
data={
|
|
|
|
|
CONF_IP_ADDRESS: MOCK_ADAPTER_IP,
|
|
|
|
|
CONF_PORT: MOCK_ADAPTER_PORT,
|
|
|
|
|
},
|
|
|
|
|
options={
|
|
|
|
|
CONF_SCAN_INTERVAL: 30,
|
|
|
|
|
},
|
|
|
|
|
unique_id=MOCK_ADAPTER_MAC,
|
2024-05-09 05:19:58 -07:00
|
|
|
entry_id=MOCK_CONFIG_ENTRY_ID,
|
2023-09-09 15:39:54 -07:00
|
|
|
)
|
2026-02-19 12:57:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
|
def mock_disconnect() -> Generator[None]:
|
|
|
|
|
"""Mock disconnect for all tests."""
|
|
|
|
|
|
|
|
|
|
async def _subscribe_client(*args, **kwargs):
|
|
|
|
|
"""Mock subscribe client."""
|
|
|
|
|
return Mock()
|
|
|
|
|
|
|
|
|
|
with patch(
|
|
|
|
|
"homeassistant.components.screenlogic.ScreenLogicGateway.async_subscribe_client",
|
|
|
|
|
_subscribe_client,
|
|
|
|
|
):
|
|
|
|
|
yield
|