mirror of
https://github.com/home-assistant/core.git
synced 2026-10-07 23:09:19 -04:00
Handle MissingSerial during OpenEVSE entry setup (#183105)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""The OpenEVSE integration."""
|
||||
|
||||
from openevsehttp.__main__ import OpenEVSE
|
||||
from openevsehttp.exceptions import AuthenticationError
|
||||
from openevsehttp.exceptions import AuthenticationError, MissingSerial
|
||||
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -42,6 +42,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: OpenEVSEConfigEntry) ->
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="authentication_error",
|
||||
) from ex
|
||||
except MissingSerial:
|
||||
pass
|
||||
|
||||
coordinator = OpenEVSEDataUpdateCoordinator(hass, entry, charger)
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from openevsehttp.exceptions import AuthenticationError
|
||||
from openevsehttp.exceptions import AuthenticationError, MissingSerial
|
||||
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
@@ -84,3 +84,18 @@ async def test_unload_entry(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert mock_config_entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
||||
|
||||
async def test_setup_entry_missing_serial(
|
||||
hass: HomeAssistant,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_charger: MagicMock,
|
||||
) -> None:
|
||||
"""Test setup entry succeeds when serial number is missing."""
|
||||
mock_charger.test_and_get.side_effect = MissingSerial
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert mock_config_entry.state is ConfigEntryState.LOADED
|
||||
|
||||
Reference in New Issue
Block a user