mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Prevent config entries from being reloaded while they are setting up (#73387)
This commit is contained in:
parent
1187009280
commit
7a422774b6
@ -90,7 +90,7 @@ class ConfigEntryState(Enum):
|
||||
"""The config entry has not been loaded"""
|
||||
FAILED_UNLOAD = "failed_unload", False
|
||||
"""An error occurred when trying to unload the entry"""
|
||||
SETUP_IN_PROGRESS = "setup_in_progress", True
|
||||
SETUP_IN_PROGRESS = "setup_in_progress", False
|
||||
"""The config entry is setting up."""
|
||||
|
||||
_recoverable: bool
|
||||
@ -104,7 +104,11 @@ class ConfigEntryState(Enum):
|
||||
|
||||
@property
|
||||
def recoverable(self) -> bool:
|
||||
"""Get if the state is recoverable."""
|
||||
"""Get if the state is recoverable.
|
||||
|
||||
If the entry is state is recoverable, unloads
|
||||
and reloads are allowed.
|
||||
"""
|
||||
return self._recoverable
|
||||
|
||||
|
||||
|
@ -3260,3 +3260,15 @@ async def test_unique_id_update_while_setup_in_progress(
|
||||
assert len(async_reload.mock_calls) == 0
|
||||
await hass.async_block_till_done()
|
||||
assert entry.state is config_entries.ConfigEntryState.LOADED
|
||||
|
||||
|
||||
async def test_disallow_entry_reload_with_setup_in_progresss(hass, manager):
|
||||
"""Test we do not allow reload while the config entry is still setting up."""
|
||||
entry = MockConfigEntry(
|
||||
domain="comp", state=config_entries.ConfigEntryState.SETUP_IN_PROGRESS
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with pytest.raises(config_entries.OperationNotAllowed):
|
||||
assert await manager.async_reload(entry.entry_id)
|
||||
assert entry.state is config_entries.ConfigEntryState.SETUP_IN_PROGRESS
|
||||
|
Loading…
x
Reference in New Issue
Block a user