1
0
mirror of https://github.com/home-assistant/core.git synced 2026-02-21 02:18:47 +00:00
Files
core/tests/components/enocean/test_init.py
2026-02-19 17:53:29 +00:00

27 lines
817 B
Python

"""Test the EnOcean integration."""
from unittest.mock import patch
from serial import SerialException
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry
async def test_device_not_connected(
hass: HomeAssistant, mock_config_entry: MockConfigEntry
) -> None:
"""Test that a config entry is not ready if the device is not connected."""
mock_config_entry.add_to_hass(hass)
with patch(
"homeassistant.components.enocean.dongle.SerialCommunicator",
side_effect=SerialException("Device not found"),
):
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY