1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-20 19:09:45 +00:00
Files
core/tests/components/smarty/conftest.py
2024-10-24 13:32:27 +02:00

47 lines
1.2 KiB
Python

"""Smarty tests configuration."""
from collections.abc import Generator
from unittest.mock import patch
import pytest
from homeassistant.components.smarty import DOMAIN
from homeassistant.const import CONF_HOST
from tests.common import MockConfigEntry
from tests.components.smhi.common import AsyncMock
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock]:
"""Override integration setup."""
with patch(
"homeassistant.components.smarty.async_setup_entry",
return_value=True,
) as mock_setup_entry:
yield mock_setup_entry
@pytest.fixture
def mock_smarty() -> Generator[AsyncMock]:
"""Mock a Smarty client."""
with (
patch(
"homeassistant.components.smarty.Smarty",
autospec=True,
) as mock_client,
patch(
"homeassistant.components.smarty.config_flow.Smarty",
new=mock_client,
),
):
client = mock_client.return_value
client.update.return_value = True
yield client
@pytest.fixture
def mock_config_entry() -> MockConfigEntry:
"""Return the default mocked config entry."""
return MockConfigEntry(domain=DOMAIN, data={CONF_HOST: "192.168.0.2"})