mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Catch exception in coordinator setup of IronOS integration (#123079)
This commit is contained in:
parent
4d103c1fc2
commit
7308912b39
@ -46,4 +46,8 @@ class IronOSCoordinator(DataUpdateCoordinator[LiveDataResponse]):
|
||||
async def _async_setup(self) -> None:
|
||||
"""Set up the coordinator."""
|
||||
|
||||
self.device_info = await self.device.get_device_info()
|
||||
try:
|
||||
self.device_info = await self.device.get_device_info()
|
||||
|
||||
except CommunicationError as e:
|
||||
raise UpdateFailed("Cannot connect to device") from e
|
||||
|
26
tests/components/iron_os/test_init.py
Normal file
26
tests/components/iron_os/test_init.py
Normal file
@ -0,0 +1,26 @@
|
||||
"""Test init of IronOS integration."""
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from pynecil import CommunicationError
|
||||
import pytest
|
||||
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("ble_device")
|
||||
async def test_setup_config_entry_not_ready(
|
||||
hass: HomeAssistant,
|
||||
config_entry: MockConfigEntry,
|
||||
mock_pynecil: AsyncMock,
|
||||
) -> None:
|
||||
"""Test config entry not ready."""
|
||||
mock_pynecil.get_device_info.side_effect = CommunicationError
|
||||
config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert config_entry.state is ConfigEntryState.SETUP_RETRY
|
Loading…
x
Reference in New Issue
Block a user