mirror of
https://github.com/home-assistant/core.git
synced 2025-11-15 22:10:09 +00:00
Add Homee integration to Core (#133738)
Co-authored-by: Joostlek <joostlek@outlook.com>
This commit is contained in:
68
tests/components/homee/conftest.py
Normal file
68
tests/components/homee/conftest.py
Normal file
@@ -0,0 +1,68 @@
|
||||
"""Fixtures for Homee integration tests."""
|
||||
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
from typing_extensions import Generator
|
||||
|
||||
from homeassistant.components.homee.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
HOMEE_ID = "00055511EECC"
|
||||
HOMEE_IP = "192.168.1.11"
|
||||
HOMEE_NAME = "TestHomee"
|
||||
TESTUSER = "testuser"
|
||||
TESTPASS = "testpass"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_config_entry() -> MockConfigEntry:
|
||||
"""Return the default mocked config entry."""
|
||||
return MockConfigEntry(
|
||||
title=f"{HOMEE_NAME} ({HOMEE_IP})",
|
||||
domain=DOMAIN,
|
||||
data={
|
||||
CONF_HOST: HOMEE_IP,
|
||||
CONF_USERNAME: TESTUSER,
|
||||
CONF_PASSWORD: TESTPASS,
|
||||
},
|
||||
unique_id=HOMEE_ID,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||
"""Mock setting up a config entry."""
|
||||
with patch(
|
||||
"homeassistant.components.homee.async_setup_entry", return_value=True
|
||||
) as mock_setup:
|
||||
yield mock_setup
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_homee() -> Generator[AsyncMock]:
|
||||
"""Return a mock Homee instance."""
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.homee.config_flow.Homee", autospec=True
|
||||
) as mocked_homee,
|
||||
patch(
|
||||
"homeassistant.components.homee.Homee",
|
||||
autospec=True,
|
||||
),
|
||||
):
|
||||
homee = mocked_homee.return_value
|
||||
|
||||
homee.host = HOMEE_IP
|
||||
homee.user = TESTUSER
|
||||
homee.password = TESTPASS
|
||||
homee.settings = MagicMock()
|
||||
homee.settings.uid = HOMEE_ID
|
||||
homee.settings.homee_name = HOMEE_NAME
|
||||
homee.reconnect_interval = 10
|
||||
|
||||
homee.get_access_token.return_value = "test_token"
|
||||
|
||||
yield homee
|
||||
Reference in New Issue
Block a user