mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 02:07:54 +00:00

* Deako integration using pydeako * fix: address feedback - make unit tests more e2e - use runtime_data to store connection * fix: address feedback part 2 - added better type safety for Deako config entries - refactored the config flow tests to use a conftest mock instead of directly patching - removed pytest.mark.asyncio test decorators * fix: address feedback pt 3 - simplify config entry type - add test for single_instance_allowed - remove light.py get_state(), only used once, no need to be separate function * fix: ruff format * Update homeassistant/components/deako/__init__.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
"""deako session fixtures."""
|
|
|
|
from collections.abc import Generator
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
from homeassistant.components.deako.const import DOMAIN
|
|
|
|
from tests.common import MockConfigEntry
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_config_entry() -> MockConfigEntry:
|
|
"""Return the default mocked config entry."""
|
|
return MockConfigEntry(
|
|
domain=DOMAIN,
|
|
)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def pydeako_deako_mock() -> Generator[MagicMock]:
|
|
"""Mock pydeako deako client."""
|
|
with patch("homeassistant.components.deako.Deako", autospec=True) as mock:
|
|
yield mock
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def pydeako_discoverer_mock(mock_async_zeroconf: MagicMock) -> Generator[MagicMock]:
|
|
"""Mock pydeako discovery client."""
|
|
with (
|
|
patch("homeassistant.components.deako.DeakoDiscoverer", autospec=True) as mock,
|
|
patch("homeassistant.components.deako.config_flow.DeakoDiscoverer", new=mock),
|
|
):
|
|
yield mock
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_deako_setup() -> Generator[MagicMock]:
|
|
"""Mock async_setup_entry for config flow tests."""
|
|
with patch(
|
|
"homeassistant.components.deako.async_setup_entry",
|
|
return_value=True,
|
|
) as mock_setup:
|
|
yield mock_setup
|