hass-core/tests/components/wmspro/conftest.py
Marc Hörsken 587ebd5d47
Add new integration for WMS WebControl pro using local API (#124176)
* Add new integration for WMS WebControl pro using local API

Warema recently released a new local API for their WMS hub
called "WebControl pro". This integration makes use of the
new local API via a new dedicated Python library pywmspro.

For now this integration only supports awnings as covers.
But pywmspro is device-agnostic to ease future extensions.

* Incorporated review feedback from joostlek

Thanks a lot!

* Incorporated more review feedback from joostlek

Thanks a lot!

* Incorporated more review feedback from joostlek

Thanks a lot!

* Fix

* Follow-up fix

* Improve handling of DHCP discovery

* Further test improvements suggested by joostlek, thanks!

---------

Co-authored-by: Joostlek <joostlek@outlook.com>
2024-09-16 16:07:43 +02:00

106 lines
2.9 KiB
Python

"""Common fixtures for the wmspro tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch
import pytest
from homeassistant.components.wmspro.const import DOMAIN
from homeassistant.const import CONF_HOST
from tests.common import MockConfigEntry, load_json_object_fixture
@pytest.fixture
def mock_config_entry() -> MockConfigEntry:
"""Return a dummy config entry."""
return MockConfigEntry(
title="WebControl",
domain=DOMAIN,
data={CONF_HOST: "webcontrol"},
)
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock]:
"""Override async_setup_entry."""
with patch(
"homeassistant.components.wmspro.async_setup_entry", return_value=True
) as mock_setup_entry:
yield mock_setup_entry
@pytest.fixture
def mock_hub_ping() -> Generator[AsyncMock]:
"""Override WebControlPro.ping."""
with patch(
"wmspro.webcontrol.WebControlPro.ping",
return_value=True,
) as mock_hub_ping:
yield mock_hub_ping
@pytest.fixture
def mock_hub_refresh() -> Generator[AsyncMock]:
"""Override WebControlPro.refresh."""
with patch(
"wmspro.webcontrol.WebControlPro.refresh",
return_value=True,
) as mock_hub_refresh:
yield mock_hub_refresh
@pytest.fixture
def mock_hub_configuration_test() -> Generator[AsyncMock]:
"""Override WebControlPro.configuration."""
with patch(
"wmspro.webcontrol.WebControlPro._getConfiguration",
return_value=load_json_object_fixture("example_config_test.json", DOMAIN),
) as mock_hub_configuration:
yield mock_hub_configuration
@pytest.fixture
def mock_hub_configuration_prod() -> Generator[AsyncMock]:
"""Override WebControlPro._getConfiguration."""
with patch(
"wmspro.webcontrol.WebControlPro._getConfiguration",
return_value=load_json_object_fixture("example_config_prod.json", DOMAIN),
) as mock_hub_configuration:
yield mock_hub_configuration
@pytest.fixture
def mock_hub_status_prod_awning() -> Generator[AsyncMock]:
"""Override WebControlPro._getStatus."""
with patch(
"wmspro.webcontrol.WebControlPro._getStatus",
return_value=load_json_object_fixture(
"example_status_prod_awning.json", DOMAIN
),
) as mock_dest_refresh:
yield mock_dest_refresh
@pytest.fixture
def mock_dest_refresh() -> Generator[AsyncMock]:
"""Override Destination.refresh."""
with patch(
"wmspro.destination.Destination.refresh",
return_value=True,
) as mock_dest_refresh:
yield mock_dest_refresh
@pytest.fixture
def mock_action_call() -> Generator[AsyncMock]:
"""Override Action.__call__."""
async def fake_call(self, **kwargs):
self._update_params(kwargs)
with patch(
"wmspro.action.Action.__call__",
fake_call,
) as mock_action_call:
yield mock_action_call