Add 100% coverage to coordinator in Shelly (#180644)

This commit is contained in:
Simone Chemelli
2026-08-29 20:54:00 +00:00
committed by Franck Nijhof
parent 0fba58bb29
commit 354107a189
+21 -1
View File
@@ -25,7 +25,12 @@ from homeassistant.components.shelly.const import (
BLEScannerMode,
)
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
from homeassistant.const import ATTR_DEVICE_ID, STATE_ON, STATE_UNAVAILABLE
from homeassistant.const import (
ATTR_DEVICE_ID,
EVENT_HOMEASSISTANT_STOP,
STATE_ON,
STATE_UNAVAILABLE,
)
from homeassistant.core import Event, HomeAssistant, State
from homeassistant.helpers import device_registry as dr, issue_registry as ir
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceRegistry
@@ -511,6 +516,21 @@ async def test_rpc_connection_error_during_unload(
assert entry.state is ConfigEntryState.NOT_LOADED
async def test_block_shutdown_on_ha_stop(
hass: HomeAssistant,
mock_block_device: Mock,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test the device is shut down when Home Assistant stops."""
await init_integration(hass, 1)
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP)
await hass.async_block_till_done()
assert "Stopping RPC device coordinator for Test name" in caplog.text
mock_block_device.shutdown.assert_called()
async def test_rpc_click_event(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,