Files
core/tests/components/stiebel_eltron/conftest.py
Manuel Stahl d7f43bddfa Remove dependency on modbus for stiebel_eltron (#136482)
* Remove dependency on modbus for stiebel_eltron

The modbus integration changed its setup, so it is
not possible anymore to have an empty hub.

* Add config flow

* Update pystiebeleltron to v0.1.0

* Fix

* Fix

* Add test for non existing modbus hub

* Fix tests

* Add more tests

* Add missing translation string

* Add test for import failure

* Fix issues from review comments

* Fix issues from review comments

* Mock stiebel eltron client instead of setup_entry

* Update homeassistant/components/stiebel_eltron/__init__.py

* Update homeassistant/components/stiebel_eltron/__init__.py

---------

Co-authored-by: Joostlek <joostlek@outlook.com>
2025-04-29 14:57:01 +02:00

56 lines
1.5 KiB
Python

"""Common fixtures for the STIEBEL ELTRON tests."""
from collections.abc import Generator
from unittest.mock import MagicMock, patch
import pytest
from homeassistant.components.stiebel_eltron import DOMAIN
from homeassistant.const import CONF_HOST, CONF_PORT
from tests.common import MockConfigEntry
@pytest.fixture
def mock_stiebel_eltron_client() -> Generator[MagicMock]:
"""Mock a stiebel eltron client."""
with (
patch(
"homeassistant.components.stiebel_eltron.StiebelEltronAPI",
autospec=True,
) as mock_client,
patch(
"homeassistant.components.stiebel_eltron.config_flow.StiebelEltronAPI",
new=mock_client,
),
):
client = mock_client.return_value
client.update.return_value = True
yield client
@pytest.fixture(autouse=True)
def mock_modbus() -> Generator[MagicMock]:
"""Mock a modbus client."""
with (
patch(
"homeassistant.components.stiebel_eltron.ModbusTcpClient",
autospec=True,
) as mock_client,
patch(
"homeassistant.components.stiebel_eltron.config_flow.ModbusTcpClient",
new=mock_client,
),
):
yield mock_client
@pytest.fixture
def mock_config_entry() -> MockConfigEntry:
"""Mock a config entry."""
return MockConfigEntry(
domain=DOMAIN,
title="Stiebel Eltron",
data={CONF_HOST: "1.1.1.1", CONF_PORT: 502},
)