Change config entry state to an enum (#49654)

* Change config entry state to an enum

* Allow but deprecate EntryState str equality comparison

* Test fixes

* Rename to ConfigEntryState

* Remove str comparability backcompat

* Update new occurrences of strs cropped up during review
This commit is contained in:
Ville Skyttä 2021-05-20 20:19:20 +03:00 committed by GitHub
parent 0e7409e617
commit 19d25cd901
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
101 changed files with 557 additions and 688 deletions

View file

@ -5,11 +5,7 @@ from uuid import uuid4
import pytest
from homeassistant.components.ialarm.const import DOMAIN
from homeassistant.config_entries import (
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_HOST, CONF_PORT
from tests.common import MockConfigEntry
@ -41,7 +37,7 @@ async def test_setup_entry(hass, ialarm_api, mock_config_entry):
await hass.async_block_till_done()
ialarm_api.return_value.get_mac.assert_called_once()
assert mock_config_entry.state == ENTRY_STATE_LOADED
assert mock_config_entry.state is ConfigEntryState.LOADED
async def test_setup_not_ready(hass, ialarm_api, mock_config_entry):
@ -51,7 +47,7 @@ async def test_setup_not_ready(hass, ialarm_api, mock_config_entry):
mock_config_entry.add_to_hass(hass)
assert not await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert mock_config_entry.state == ENTRY_STATE_SETUP_RETRY
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_entry(hass, ialarm_api, mock_config_entry):
@ -62,6 +58,6 @@ async def test_unload_entry(hass, ialarm_api, mock_config_entry):
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert mock_config_entry.state == ENTRY_STATE_LOADED
assert mock_config_entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(mock_config_entry.entry_id)
assert mock_config_entry.state == ENTRY_STATE_NOT_LOADED
assert mock_config_entry.state is ConfigEntryState.NOT_LOADED