mirror of
https://github.com/home-assistant/core.git
synced 2026-09-24 15:31:52 -05:00
Add 100% coverage to coordinator in Shelly (#180644)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user