Mock HMConnection in homematic notify tests (#164381)

This commit is contained in:
Franck Nijhof
2026-02-27 20:29:14 +01:00
committed by GitHub
parent 6b89359a73
commit d0401de70d

View File

@@ -1,5 +1,7 @@
"""The tests for the Homematic notification platform."""
from unittest.mock import MagicMock, patch
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
@@ -9,11 +11,15 @@ from tests.common import assert_setup_component
async def test_setup_full(hass: HomeAssistant) -> None:
"""Test valid configuration."""
await async_setup_component(
hass,
"homematic",
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}},
)
with patch(
"homeassistant.components.homematic.HMConnection",
return_value=MagicMock(),
):
await async_setup_component(
hass,
"homematic",
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}},
)
with assert_setup_component(1, domain="notify") as handle_config:
assert await async_setup_component(
hass,
@@ -35,11 +41,15 @@ async def test_setup_full(hass: HomeAssistant) -> None:
async def test_setup_without_optional(hass: HomeAssistant) -> None:
"""Test valid configuration without optional."""
await async_setup_component(
hass,
"homematic",
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}},
)
with patch(
"homeassistant.components.homematic.HMConnection",
return_value=MagicMock(),
):
await async_setup_component(
hass,
"homematic",
{"homematic": {"hosts": {"ccu2": {"host": "127.0.0.1"}}}},
)
with assert_setup_component(1, domain="notify") as handle_config:
assert await async_setup_component(
hass,