From b4826e7f89d140776fc97d78a1315efc81d6f7d7 Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Sat, 29 Aug 2026 18:36:57 +0200 Subject: [PATCH] Add 100% coverage to coordinator in Shelly (#180644) --- tests/components/shelly/test_coordinator.py | 22 ++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/components/shelly/test_coordinator.py b/tests/components/shelly/test_coordinator.py index ded9f296460e..8218f82a92c2 100644 --- a/tests/components/shelly/test_coordinator.py +++ b/tests/components/shelly/test_coordinator.py @@ -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,