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

@ -385,7 +385,7 @@ def entry_json(entry: config_entries.ConfigEntry) -> dict:
"domain": entry.domain, "domain": entry.domain,
"title": entry.title, "title": entry.title,
"source": entry.source, "source": entry.source,
"state": entry.state, "state": entry.state.value,
"supports_options": supports_options, "supports_options": supports_options,
"supports_unload": entry.supports_unload, "supports_unload": entry.supports_unload,
"disabled_by": entry.disabled_by, "disabled_by": entry.disabled_by,

View file

@ -149,8 +149,8 @@ class DSMRFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
and reload_on_update and reload_on_update
and entry.state and entry.state
in ( in (
config_entries.ENTRY_STATE_LOADED, config_entries.ConfigEntryState.LOADED,
config_entries.ENTRY_STATE_SETUP_RETRY, config_entries.ConfigEntryState.SETUP_RETRY,
) )
): ):
self.hass.async_create_task( self.hass.async_create_task(

View file

@ -22,7 +22,7 @@ from openzwavemqtt.util.mqtt_client import MQTTClient
from homeassistant.components import mqtt from homeassistant.components import mqtt
from homeassistant.components.hassio.handler import HassioAPIError from homeassistant.components.hassio.handler import HassioAPIError
from homeassistant.config_entries import ENTRY_STATE_LOADED, ConfigEntry from homeassistant.config_entries import ConfigEntry, ConfigEntryState
from homeassistant.const import EVENT_HOMEASSISTANT_STOP from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
@ -92,7 +92,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): # noqa: C
else: else:
mqtt_entries = hass.config_entries.async_entries("mqtt") mqtt_entries = hass.config_entries.async_entries("mqtt")
if not mqtt_entries or mqtt_entries[0].state != ENTRY_STATE_LOADED: if not mqtt_entries or mqtt_entries[0].state is not ConfigEntryState.LOADED:
_LOGGER.error("MQTT integration is not set up") _LOGGER.error("MQTT integration is not set up")
return False return False
@ -100,7 +100,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): # noqa: C
@callback @callback
def send_message(topic, payload): def send_message(topic, payload):
if mqtt_entry.state != ENTRY_STATE_LOADED: if mqtt_entry.state is not ConfigEntryState.LOADED:
_LOGGER.error("MQTT integration is not set up") _LOGGER.error("MQTT integration is not set up")
return return

View file

@ -98,7 +98,7 @@ class DomainConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
mqtt_entries = self.hass.config_entries.async_entries("mqtt") mqtt_entries = self.hass.config_entries.async_entries("mqtt")
if ( if (
not mqtt_entries not mqtt_entries
or mqtt_entries[0].state != config_entries.ENTRY_STATE_LOADED or mqtt_entries[0].state is not config_entries.ConfigEntryState.LOADED
): ):
return self.async_abort(reason="mqtt_required") return self.async_abort(reason="mqtt_required")
return self._async_create_entry_from_vars() return self._async_create_entry_from_vars()

View file

@ -14,7 +14,7 @@ from plexwebsocket import (
import requests.exceptions import requests.exceptions
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_URL, CONF_VERIFY_SSL, EVENT_HOMEASSISTANT_STOP from homeassistant.const import CONF_URL, CONF_VERIFY_SSL, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
@ -107,7 +107,7 @@ async def async_setup_entry(hass, entry):
entry, data={**entry.data, PLEX_SERVER_CONFIG: new_server_data} entry, data={**entry.data, PLEX_SERVER_CONFIG: new_server_data}
) )
except requests.exceptions.ConnectionError as error: except requests.exceptions.ConnectionError as error:
if entry.state != ENTRY_STATE_SETUP_RETRY: if entry.state is not ConfigEntryState.SETUP_RETRY:
_LOGGER.error( _LOGGER.error(
"Plex server (%s) could not be reached: [%s]", "Plex server (%s) could not be reached: [%s]",
server_config[CONF_URL], server_config[CONF_URL],

View file

@ -144,7 +144,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_init(self, user_input=None): async def async_step_init(self, user_input=None):
"""Handle options flow.""" """Handle options flow."""
if self.config_entry.state != config_entries.ENTRY_STATE_LOADED: if self.config_entry.state is not config_entries.ConfigEntryState.LOADED:
_LOGGER.error("MyLink must be connected to manage device options") _LOGGER.error("MyLink must be connected to manage device options")
return self.async_abort(reason="cannot_connect") return self.async_abort(reason="cannot_connect")

View file

@ -245,7 +245,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_init(self, user_input=None): async def async_step_init(self, user_input=None):
"""Handle options flow.""" """Handle options flow."""
if self.config_entry.state != config_entries.ENTRY_STATE_LOADED: if self.config_entry.state is not config_entries.ConfigEntryState.LOADED:
_LOGGER.error("Tuya integration not yet loaded") _LOGGER.error("Tuya integration not yet loaded")
return self.async_abort(reason=RESULT_CONN_ERROR) return self.async_abort(reason=RESULT_CONN_ERROR)

View file

@ -10,7 +10,7 @@ from pyvizio.util import gen_apps_list_from_url
import voluptuous as vol import voluptuous as vol
from homeassistant.components.media_player import DEVICE_CLASS_TV from homeassistant.components.media_player import DEVICE_CLASS_TV
from homeassistant.config_entries import ENTRY_STATE_LOADED, SOURCE_IMPORT, ConfigEntry from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry, ConfigEntryState
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -80,7 +80,7 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
) )
# Exclude this config entry because its not unloaded yet # Exclude this config entry because its not unloaded yet
if not any( if not any(
entry.state == ENTRY_STATE_LOADED entry.state is ConfigEntryState.LOADED
and entry.entry_id != config_entry.entry_id and entry.entry_id != config_entry.entry_id
and entry.data[CONF_DEVICE_CLASS] == DEVICE_CLASS_TV and entry.data[CONF_DEVICE_CLASS] == DEVICE_CLASS_TV
for entry in hass.config_entries.async_entries(DOMAIN) for entry in hass.config_entries.async_entries(DOMAIN)

View file

@ -25,7 +25,7 @@ from homeassistant.components.websocket_api.const import (
ERR_NOT_SUPPORTED, ERR_NOT_SUPPORTED,
ERR_UNKNOWN_ERROR, ERR_UNKNOWN_ERROR,
) )
from homeassistant.config_entries import ENTRY_STATE_LOADED, ConfigEntry from homeassistant.config_entries import ConfigEntry, ConfigEntryState
from homeassistant.const import CONF_URL from homeassistant.const import CONF_URL
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
@ -85,7 +85,7 @@ def async_get_entry(orig_func: Callable) -> Callable:
) )
return return
if entry.state != ENTRY_STATE_LOADED: if entry.state is not ConfigEntryState.LOADED:
connection.send_error( connection.send_error(
msg[ID], ERR_NOT_LOADED, f"Config entry {entry_id} not loaded" msg[ID], ERR_NOT_LOADED, f"Config entry {entry_id} not loaded"
) )

View file

@ -4,6 +4,7 @@ from __future__ import annotations
import asyncio import asyncio
from collections.abc import Iterable, Mapping from collections.abc import Iterable, Mapping
from contextvars import ContextVar from contextvars import ContextVar
from enum import Enum
import functools import functools
import logging import logging
from types import MappingProxyType, MethodType from types import MappingProxyType, MethodType
@ -63,20 +64,37 @@ PATH_CONFIG = ".config_entries.json"
SAVE_DELAY = 1 SAVE_DELAY = 1
# The config entry has been set up successfully
ENTRY_STATE_LOADED = "loaded"
# There was an error while trying to set up this config entry
ENTRY_STATE_SETUP_ERROR = "setup_error"
# There was an error while trying to migrate the config entry to a new version
ENTRY_STATE_MIGRATION_ERROR = "migration_error"
# The config entry was not ready to be set up yet, but might be later
ENTRY_STATE_SETUP_RETRY = "setup_retry"
# The config entry has not been loaded
ENTRY_STATE_NOT_LOADED = "not_loaded"
# An error occurred when trying to unload the entry
ENTRY_STATE_FAILED_UNLOAD = "failed_unload"
UNRECOVERABLE_STATES = (ENTRY_STATE_MIGRATION_ERROR, ENTRY_STATE_FAILED_UNLOAD) class ConfigEntryState(Enum):
"""Config entry state."""
LOADED = "loaded", True
"""The config entry has been set up successfully"""
SETUP_ERROR = "setup_error", True
"""There was an error while trying to set up this config entry"""
MIGRATION_ERROR = "migration_error", False
"""There was an error while trying to migrate the config entry to a new version"""
SETUP_RETRY = "setup_retry", True
"""The config entry was not ready to be set up yet, but might be later"""
NOT_LOADED = "not_loaded", True
"""The config entry has not been loaded"""
FAILED_UNLOAD = "failed_unload", False
"""An error occurred when trying to unload the entry"""
_recoverable: bool
def __new__(cls: type[object], value: str, recoverable: bool) -> ConfigEntryState:
"""Create new ConfigEntryState."""
obj = object.__new__(cls)
obj._value_ = value
obj._recoverable = recoverable
return cast("ConfigEntryState", obj)
@property
def recoverable(self) -> bool:
"""Get if the state is recoverable."""
return self._recoverable
DEFAULT_DISCOVERY_UNIQUE_ID = "default_discovery_unique_id" DEFAULT_DISCOVERY_UNIQUE_ID = "default_discovery_unique_id"
DISCOVERY_NOTIFICATION_ID = "config_entry_discovery" DISCOVERY_NOTIFICATION_ID = "config_entry_discovery"
@ -156,7 +174,7 @@ class ConfigEntry:
options: Mapping[str, Any] | None = None, options: Mapping[str, Any] | None = None,
unique_id: str | None = None, unique_id: str | None = None,
entry_id: str | None = None, entry_id: str | None = None,
state: str = ENTRY_STATE_NOT_LOADED, state: ConfigEntryState = ConfigEntryState.NOT_LOADED,
disabled_by: str | None = None, disabled_by: str | None = None,
) -> None: ) -> None:
"""Initialize a config entry.""" """Initialize a config entry."""
@ -237,7 +255,7 @@ class ConfigEntry:
err, err,
) )
if self.domain == integration.domain: if self.domain == integration.domain:
self.state = ENTRY_STATE_SETUP_ERROR self.state = ConfigEntryState.SETUP_ERROR
self.reason = "Import error" self.reason = "Import error"
return return
@ -251,13 +269,13 @@ class ConfigEntry:
self.domain, self.domain,
err, err,
) )
self.state = ENTRY_STATE_SETUP_ERROR self.state = ConfigEntryState.SETUP_ERROR
self.reason = "Import error" self.reason = "Import error"
return return
# Perform migration # Perform migration
if not await self.async_migrate(hass): if not await self.async_migrate(hass):
self.state = ENTRY_STATE_MIGRATION_ERROR self.state = ConfigEntryState.MIGRATION_ERROR
self.reason = None self.reason = None
return return
@ -288,7 +306,7 @@ class ConfigEntry:
self.async_start_reauth(hass) self.async_start_reauth(hass)
result = False result = False
except ConfigEntryNotReady as ex: except ConfigEntryNotReady as ex:
self.state = ENTRY_STATE_SETUP_RETRY self.state = ConfigEntryState.SETUP_RETRY
self.reason = str(ex) or None self.reason = str(ex) or None
wait_time = 2 ** min(tries, 4) * 5 wait_time = 2 ** min(tries, 4) * 5
tries += 1 tries += 1
@ -337,10 +355,10 @@ class ConfigEntry:
return return
if result: if result:
self.state = ENTRY_STATE_LOADED self.state = ConfigEntryState.LOADED
self.reason = None self.reason = None
else: else:
self.state = ENTRY_STATE_SETUP_ERROR self.state = ConfigEntryState.SETUP_ERROR
self.reason = error_reason self.reason = error_reason
async def async_shutdown(self) -> None: async def async_shutdown(self) -> None:
@ -362,7 +380,7 @@ class ConfigEntry:
Returns if unload is possible and was successful. Returns if unload is possible and was successful.
""" """
if self.source == SOURCE_IGNORE: if self.source == SOURCE_IGNORE:
self.state = ENTRY_STATE_NOT_LOADED self.state = ConfigEntryState.NOT_LOADED
self.reason = None self.reason = None
return True return True
@ -374,20 +392,20 @@ class ConfigEntry:
# that was uninstalled, or an integration # that was uninstalled, or an integration
# that has been renamed without removing the config # that has been renamed without removing the config
# entry. # entry.
self.state = ENTRY_STATE_NOT_LOADED self.state = ConfigEntryState.NOT_LOADED
self.reason = None self.reason = None
return True return True
component = integration.get_component() component = integration.get_component()
if integration.domain == self.domain: if integration.domain == self.domain:
if self.state in UNRECOVERABLE_STATES: if not self.state.recoverable:
return False return False
if self.state != ENTRY_STATE_LOADED: if self.state is not ConfigEntryState.LOADED:
self.async_cancel_retry_setup() self.async_cancel_retry_setup()
self.state = ENTRY_STATE_NOT_LOADED self.state = ConfigEntryState.NOT_LOADED
self.reason = None self.reason = None
return True return True
@ -395,7 +413,7 @@ class ConfigEntry:
if not supports_unload: if not supports_unload:
if integration.domain == self.domain: if integration.domain == self.domain:
self.state = ENTRY_STATE_FAILED_UNLOAD self.state = ConfigEntryState.FAILED_UNLOAD
self.reason = "Unload not supported" self.reason = "Unload not supported"
return False return False
@ -406,7 +424,7 @@ class ConfigEntry:
# Only adjust state if we unloaded the component # Only adjust state if we unloaded the component
if result and integration.domain == self.domain: if result and integration.domain == self.domain:
self.state = ENTRY_STATE_NOT_LOADED self.state = ConfigEntryState.NOT_LOADED
self.reason = None self.reason = None
self._async_process_on_unload() self._async_process_on_unload()
@ -417,7 +435,7 @@ class ConfigEntry:
"Error unloading entry %s for %s", self.title, integration.domain "Error unloading entry %s for %s", self.title, integration.domain
) )
if integration.domain == self.domain: if integration.domain == self.domain:
self.state = ENTRY_STATE_FAILED_UNLOAD self.state = ConfigEntryState.FAILED_UNLOAD
self.reason = "Unknown error" self.reason = "Unknown error"
return False return False
@ -620,10 +638,7 @@ class ConfigEntriesFlowManager(data_entry_flow.FlowManager):
# Unload the entry before setting up the new one. # Unload the entry before setting up the new one.
# We will remove it only after the other one is set up, # We will remove it only after the other one is set up,
# so that device customizations are not getting lost. # so that device customizations are not getting lost.
if ( if existing_entry is not None and existing_entry.state.recoverable:
existing_entry is not None
and existing_entry.state not in UNRECOVERABLE_STATES
):
await self.config_entries.async_unload(existing_entry.entry_id) await self.config_entries.async_unload(existing_entry.entry_id)
entry = ConfigEntry( entry = ConfigEntry(
@ -770,8 +785,8 @@ class ConfigEntries:
if entry is None: if entry is None:
raise UnknownEntry raise UnknownEntry
if entry.state in UNRECOVERABLE_STATES: if not entry.state.recoverable:
unload_success = entry.state != ENTRY_STATE_FAILED_UNLOAD unload_success = entry.state is not ConfigEntryState.FAILED_UNLOAD
else: else:
unload_success = await self.async_unload(entry_id) unload_success = await self.async_unload(entry_id)
@ -855,7 +870,7 @@ class ConfigEntries:
if entry is None: if entry is None:
raise UnknownEntry raise UnknownEntry
if entry.state != ENTRY_STATE_NOT_LOADED: if entry.state is not ConfigEntryState.NOT_LOADED:
raise OperationNotAllowed raise OperationNotAllowed
# Setup Component if not set up yet # Setup Component if not set up yet
@ -870,7 +885,7 @@ class ConfigEntries:
if not result: if not result:
return result return result
return entry.state == ENTRY_STATE_LOADED return entry.state is ConfigEntryState.LOADED # type: ignore[comparison-overlap] # mypy bug?
async def async_unload(self, entry_id: str) -> bool: async def async_unload(self, entry_id: str) -> bool:
"""Unload a config entry.""" """Unload a config entry."""
@ -879,7 +894,7 @@ class ConfigEntries:
if entry is None: if entry is None:
raise UnknownEntry raise UnknownEntry
if entry.state in UNRECOVERABLE_STATES: if not entry.state.recoverable:
raise OperationNotAllowed raise OperationNotAllowed
return await entry.async_unload(self.hass) return await entry.async_unload(self.hass)
@ -1115,7 +1130,8 @@ class ConfigFlow(data_entry_flow.FlowHandler):
if ( if (
changed changed
and reload_on_update and reload_on_update
and entry.state in (ENTRY_STATE_LOADED, ENTRY_STATE_SETUP_RETRY) and entry.state
in (ConfigEntryState.LOADED, ConfigEntryState.SETUP_RETRY)
): ):
self.hass.async_create_task( self.hass.async_create_task(
self.hass.config_entries.async_reload(entry.entry_id) self.hass.config_entries.async_reload(entry.entry_id)

View file

@ -11,7 +11,7 @@ from homeassistant.components.abode import (
SERVICE_TRIGGER_AUTOMATION, SERVICE_TRIGGER_AUTOMATION,
) )
from homeassistant.components.alarm_control_panel import DOMAIN as ALARM_DOMAIN from homeassistant.components.alarm_control_panel import DOMAIN as ALARM_DOMAIN
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_USERNAME, HTTP_BAD_REQUEST from homeassistant.const import CONF_USERNAME, HTTP_BAD_REQUEST
from .common import setup_platform from .common import setup_platform
@ -79,7 +79,7 @@ async def test_invalid_credentials(hass):
async def test_raise_config_entry_not_ready_when_offline(hass): async def test_raise_config_entry_not_ready_when_offline(hass):
"""Config entry state is ENTRY_STATE_SETUP_RETRY when abode is offline.""" """Config entry state is SETUP_RETRY when abode is offline."""
with patch( with patch(
"homeassistant.components.abode.Abode", "homeassistant.components.abode.Abode",
side_effect=AbodeException("any"), side_effect=AbodeException("any"),
@ -87,6 +87,6 @@ async def test_raise_config_entry_not_ready_when_offline(hass):
config_entry = await setup_platform(hass, ALARM_DOMAIN) config_entry = await setup_platform(hass, ALARM_DOMAIN)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_SETUP_RETRY assert config_entry.state is ConfigEntryState.SETUP_RETRY
assert hass.config_entries.flow.async_progress() == [] assert hass.config_entries.flow.async_progress() == []

View file

@ -6,11 +6,7 @@ from unittest.mock import patch
from accuweather import ApiError from accuweather import ApiError
from homeassistant.components.accuweather.const import DOMAIN from homeassistant.components.accuweather.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import STATE_UNAVAILABLE from homeassistant.const import STATE_UNAVAILABLE
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
@ -48,7 +44,7 @@ async def test_config_not_ready(hass):
): ):
entry.add_to_hass(hass) entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_entry(hass): async def test_unload_entry(hass):
@ -56,12 +52,12 @@ async def test_unload_entry(hass):
entry = await init_integration(hass) entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)
@ -69,7 +65,7 @@ async def test_update_interval(hass):
"""Test correct update interval.""" """Test correct update interval."""
entry = await init_integration(hass) entry = await init_integration(hass)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
current = json.loads(load_fixture("accuweather/current_conditions_data.json")) current = json.loads(load_fixture("accuweather/current_conditions_data.json"))
future = utcnow() + timedelta(minutes=40) future = utcnow() + timedelta(minutes=40)
@ -91,7 +87,7 @@ async def test_update_interval_forecast(hass):
"""Test correct update interval when forecast is True.""" """Test correct update interval when forecast is True."""
entry = await init_integration(hass, forecast=True) entry = await init_integration(hass, forecast=True)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
current = json.loads(load_fixture("accuweather/current_conditions_data.json")) current = json.loads(load_fixture("accuweather/current_conditions_data.json"))
forecast = json.loads(load_fixture("accuweather/forecast_data.json")) forecast = json.loads(load_fixture("accuweather/forecast_data.json"))

View file

@ -1,10 +1,6 @@
"""Test the Advantage Air Initialization.""" """Test the Advantage Air Initialization."""
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from tests.components.advantage_air import ( from tests.components.advantage_air import (
TEST_SYSTEM_DATA, TEST_SYSTEM_DATA,
@ -22,11 +18,11 @@ async def test_async_setup_entry(hass, aioclient_mock):
) )
entry = await add_mock_config(hass) entry = await add_mock_config(hass)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
async def test_async_setup_entry_failure(hass, aioclient_mock): async def test_async_setup_entry_failure(hass, aioclient_mock):
@ -38,4 +34,4 @@ async def test_async_setup_entry_failure(hass, aioclient_mock):
) )
entry = await add_mock_config(hass) entry = await add_mock_config(hass)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY

View file

@ -6,7 +6,7 @@ import requests_mock
from homeassistant import data_entry_flow from homeassistant import data_entry_flow
from homeassistant.components.aemet.const import CONF_STATION_UPDATES, DOMAIN from homeassistant.components.aemet.const import CONF_STATION_UPDATES, DOMAIN
from homeassistant.config_entries import ENTRY_STATE_LOADED, SOURCE_USER from homeassistant.config_entries import SOURCE_USER, ConfigEntryState
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -47,7 +47,7 @@ async def test_form(hass):
conf_entries = hass.config_entries.async_entries(DOMAIN) conf_entries = hass.config_entries.async_entries(DOMAIN)
entry = conf_entries[0] entry = conf_entries[0]
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == CONFIG[CONF_NAME] assert result["title"] == CONFIG[CONF_NAME]
@ -75,7 +75,7 @@ async def test_form_options(hass):
assert await hass.config_entries.async_setup(entry.entry_id) assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == "loaded" assert entry.state is ConfigEntryState.LOADED
result = await hass.config_entries.options.async_init(entry.entry_id) result = await hass.config_entries.options.async_init(entry.entry_id)
@ -93,7 +93,7 @@ async def test_form_options(hass):
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == "loaded" assert entry.state is ConfigEntryState.LOADED
result = await hass.config_entries.options.async_init(entry.entry_id) result = await hass.config_entries.options.async_init(entry.entry_id)
@ -111,7 +111,7 @@ async def test_form_options(hass):
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == "loaded" assert entry.state is ConfigEntryState.LOADED
async def test_form_duplicated_id(hass): async def test_form_duplicated_id(hass):

View file

@ -5,7 +5,7 @@ from unittest.mock import patch
import requests_mock import requests_mock
from homeassistant.components.aemet.const import DOMAIN from homeassistant.components.aemet.const import DOMAIN
from homeassistant.config_entries import ENTRY_STATE_LOADED, ENTRY_STATE_NOT_LOADED from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -37,8 +37,8 @@ async def test_unload_entry(hass):
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_LOADED assert config_entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(config_entry.entry_id) await hass.config_entries.async_unload(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_NOT_LOADED assert config_entry.state is ConfigEntryState.NOT_LOADED

View file

@ -5,11 +5,7 @@ import pytest
from homeassistant.components.airly import set_update_interval from homeassistant.components.airly import set_update_interval
from homeassistant.components.airly.const import DOMAIN from homeassistant.components.airly.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import STATE_UNAVAILABLE from homeassistant.const import STATE_UNAVAILABLE
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
@ -52,7 +48,7 @@ async def test_config_not_ready(hass, aioclient_mock):
aioclient_mock.get(API_POINT_URL, exc=ConnectionError()) aioclient_mock.get(API_POINT_URL, exc=ConnectionError())
entry.add_to_hass(hass) entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_config_without_unique_id(hass, aioclient_mock): async def test_config_without_unique_id(hass, aioclient_mock):
@ -71,7 +67,7 @@ async def test_config_without_unique_id(hass, aioclient_mock):
aioclient_mock.get(API_POINT_URL, text=load_fixture("airly_valid_station.json")) aioclient_mock.get(API_POINT_URL, text=load_fixture("airly_valid_station.json"))
entry.add_to_hass(hass) entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert entry.unique_id == "123-456" assert entry.unique_id == "123-456"
@ -92,7 +88,7 @@ async def test_config_with_turned_off_station(hass, aioclient_mock):
aioclient_mock.get(API_POINT_URL, text=load_fixture("airly_no_station.json")) aioclient_mock.get(API_POINT_URL, text=load_fixture("airly_no_station.json"))
entry.add_to_hass(hass) entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_update_interval(hass, aioclient_mock): async def test_update_interval(hass, aioclient_mock):
@ -127,7 +123,7 @@ async def test_update_interval(hass, aioclient_mock):
assert aioclient_mock.call_count == 1 assert aioclient_mock.call_count == 1
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
update_interval = set_update_interval(instances, REMAINING_RQUESTS) update_interval = set_update_interval(instances, REMAINING_RQUESTS)
future = utcnow() + update_interval future = utcnow() + update_interval
@ -164,7 +160,7 @@ async def test_update_interval(hass, aioclient_mock):
assert aioclient_mock.call_count == 3 assert aioclient_mock.call_count == 3
assert len(hass.config_entries.async_entries(DOMAIN)) == 2 assert len(hass.config_entries.async_entries(DOMAIN)) == 2
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
update_interval = set_update_interval(instances, REMAINING_RQUESTS) update_interval = set_update_interval(instances, REMAINING_RQUESTS)
future = utcnow() + update_interval future = utcnow() + update_interval
@ -181,12 +177,12 @@ async def test_unload_entry(hass, aioclient_mock):
entry = await init_integration(hass, aioclient_mock) entry = await init_integration(hass, aioclient_mock)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)

View file

@ -38,7 +38,7 @@ async def test_set_up_oauth_remote_url(hass, aioclient_mock):
): ):
assert await async_setup_component(hass, "almond", {}) assert await async_setup_component(hass, "almond", {})
assert entry.state == config_entries.ENTRY_STATE_LOADED assert entry.state is config_entries.ConfigEntryState.LOADED
hass.config.components.add("cloud") hass.config.components.add("cloud")
with patch("homeassistant.components.almond.ALMOND_SETUP_DELAY", 0), patch( with patch("homeassistant.components.almond.ALMOND_SETUP_DELAY", 0), patch(
@ -71,7 +71,7 @@ async def test_set_up_oauth_no_external_url(hass, aioclient_mock):
), patch("pyalmond.WebAlmondAPI.async_create_device") as mock_create_device: ), patch("pyalmond.WebAlmondAPI.async_create_device") as mock_create_device:
assert await async_setup_component(hass, "almond", {}) assert await async_setup_component(hass, "almond", {})
assert entry.state == config_entries.ENTRY_STATE_LOADED assert entry.state is config_entries.ConfigEntryState.LOADED
assert len(mock_create_device.mock_calls) == 0 assert len(mock_create_device.mock_calls) == 0
@ -90,7 +90,7 @@ async def test_set_up_hassio(hass, aioclient_mock):
with patch("pyalmond.WebAlmondAPI.async_create_device") as mock_create_device: with patch("pyalmond.WebAlmondAPI.async_create_device") as mock_create_device:
assert await async_setup_component(hass, "almond", {}) assert await async_setup_component(hass, "almond", {})
assert entry.state == config_entries.ENTRY_STATE_LOADED assert entry.state is config_entries.ConfigEntryState.LOADED
assert len(mock_create_device.mock_calls) == 0 assert len(mock_create_device.mock_calls) == 0
@ -112,5 +112,5 @@ async def test_set_up_local(hass, aioclient_mock):
with patch("pyalmond.WebAlmondAPI.async_create_device") as mock_create_device: with patch("pyalmond.WebAlmondAPI.async_create_device") as mock_create_device:
assert await async_setup_component(hass, "almond", {}) assert await async_setup_component(hass, "almond", {})
assert entry.state == config_entries.ENTRY_STATE_LOADED assert entry.state is config_entries.ConfigEntryState.LOADED
assert len(mock_create_device.mock_calls) == 1 assert len(mock_create_device.mock_calls) == 1

View file

@ -1,7 +1,7 @@
"""Tests for the ATAG integration.""" """Tests for the ATAG integration."""
from homeassistant.components.atag import DOMAIN from homeassistant.components.atag import DOMAIN
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from . import init_integration, mock_connection from . import init_integration, mock_connection
@ -15,7 +15,7 @@ async def test_config_entry_not_ready(
"""Test configuration entry not ready on library error.""" """Test configuration entry not ready on library error."""
mock_connection(aioclient_mock, conn_error=True) mock_connection(aioclient_mock, conn_error=True)
entry = await init_integration(hass, aioclient_mock) entry = await init_integration(hass, aioclient_mock)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_config_entry( async def test_unload_config_entry(

View file

@ -9,11 +9,7 @@ from yalexs.exceptions import AugustApiAIOHTTPError
from homeassistant import setup from homeassistant import setup
from homeassistant.components.august.const import DOMAIN from homeassistant.components.august.const import DOMAIN
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_SETUP_ERROR,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
SERVICE_LOCK, SERVICE_LOCK,
@ -36,7 +32,7 @@ from tests.components.august.mocks import (
async def test_august_is_offline(hass): async def test_august_is_offline(hass):
"""Config entry state is ENTRY_STATE_SETUP_RETRY when august is offline.""" """Config entry state is SETUP_RETRY when august is offline."""
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
@ -53,7 +49,7 @@ async def test_august_is_offline(hass):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_SETUP_RETRY assert config_entry.state is ConfigEntryState.SETUP_RETRY
async def test_unlock_throws_august_api_http_error(hass): async def test_unlock_throws_august_api_http_error(hass):
@ -141,7 +137,7 @@ async def test_lock_has_doorsense(hass):
async def test_auth_fails(hass): async def test_auth_fails(hass):
"""Config entry state is ENTRY_STATE_SETUP_ERROR when auth fails.""" """Config entry state is SETUP_ERROR when auth fails."""
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
@ -159,7 +155,7 @@ async def test_auth_fails(hass):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_SETUP_ERROR assert config_entry.state is ConfigEntryState.SETUP_ERROR
flows = hass.config_entries.flow.async_progress() flows = hass.config_entries.flow.async_progress()
@ -167,7 +163,7 @@ async def test_auth_fails(hass):
async def test_bad_password(hass): async def test_bad_password(hass):
"""Config entry state is ENTRY_STATE_SETUP_ERROR when the password has been changed.""" """Config entry state is SETUP_ERROR when the password has been changed."""
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
@ -187,7 +183,7 @@ async def test_bad_password(hass):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_SETUP_ERROR assert config_entry.state is ConfigEntryState.SETUP_ERROR
flows = hass.config_entries.flow.async_progress() flows = hass.config_entries.flow.async_progress()
@ -195,7 +191,7 @@ async def test_bad_password(hass):
async def test_http_failure(hass): async def test_http_failure(hass):
"""Config entry state is ENTRY_STATE_SETUP_RETRY when august is offline.""" """Config entry state is SETUP_RETRY when august is offline."""
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
@ -213,13 +209,13 @@ async def test_http_failure(hass):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_SETUP_RETRY assert config_entry.state is ConfigEntryState.SETUP_RETRY
assert hass.config_entries.flow.async_progress() == [] assert hass.config_entries.flow.async_progress() == []
async def test_unknown_auth_state(hass): async def test_unknown_auth_state(hass):
"""Config entry state is ENTRY_STATE_SETUP_ERROR when august is in an unknown auth state.""" """Config entry state is SETUP_ERROR when august is in an unknown auth state."""
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
@ -237,7 +233,7 @@ async def test_unknown_auth_state(hass):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_SETUP_ERROR assert config_entry.state is ConfigEntryState.SETUP_ERROR
flows = hass.config_entries.flow.async_progress() flows = hass.config_entries.flow.async_progress()
@ -245,7 +241,7 @@ async def test_unknown_auth_state(hass):
async def test_requires_validation_state(hass): async def test_requires_validation_state(hass):
"""Config entry state is ENTRY_STATE_SETUP_ERROR when august requires validation.""" """Config entry state is SETUP_ERROR when august requires validation."""
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
@ -265,14 +261,14 @@ async def test_requires_validation_state(hass):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_SETUP_ERROR assert config_entry.state is ConfigEntryState.SETUP_ERROR
assert len(hass.config_entries.flow.async_progress()) == 1 assert len(hass.config_entries.flow.async_progress()) == 1
assert hass.config_entries.flow.async_progress()[0]["context"]["source"] == "reauth" assert hass.config_entries.flow.async_progress()[0]["context"]["source"] == "reauth"
async def test_unknown_auth_http_401(hass): async def test_unknown_auth_http_401(hass):
"""Config entry state is ENTRY_STATE_SETUP_ERROR when august gets an http.""" """Config entry state is SETUP_ERROR when august gets an http."""
config_entry = MockConfigEntry( config_entry = MockConfigEntry(
domain=DOMAIN, domain=DOMAIN,
@ -290,7 +286,7 @@ async def test_unknown_auth_http_401(hass):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_SETUP_ERROR assert config_entry.state is ConfigEntryState.SETUP_ERROR
flows = hass.config_entries.flow.async_progress() flows = hass.config_entries.flow.async_progress()
@ -306,7 +302,7 @@ async def test_load_unload(hass):
hass, [august_operative_lock, august_inoperative_lock] hass, [august_operative_lock, august_inoperative_lock]
) )
assert config_entry.state == ENTRY_STATE_LOADED assert config_entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(config_entry.entry_id) await hass.config_entries.async_unload(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()

View file

@ -173,7 +173,7 @@ async def test_async_setup_entry(hass, valid_feature_mock):
await hass.async_block_till_done() await hass.async_block_till_done()
assert hass.config_entries.async_entries() == [config] assert hass.config_entries.async_entries() == [config]
assert config.state == config_entries.ENTRY_STATE_LOADED assert config.state is config_entries.ConfigEntryState.LOADED
async def test_async_remove_entry(hass, valid_feature_mock): async def test_async_remove_entry(hass, valid_feature_mock):
@ -189,4 +189,4 @@ async def test_async_remove_entry(hass, valid_feature_mock):
await hass.async_block_till_done() await hass.async_block_till_done()
assert hass.config_entries.async_entries() == [] assert hass.config_entries.async_entries() == []
assert config.state == config_entries.ENTRY_STATE_NOT_LOADED assert config.state is config_entries.ConfigEntryState.NOT_LOADED

View file

@ -5,7 +5,7 @@ import logging
import blebox_uniapi import blebox_uniapi
from homeassistant.components.blebox.const import DOMAIN from homeassistant.components.blebox.const import DOMAIN
from homeassistant.config_entries import ENTRY_STATE_NOT_LOADED, ENTRY_STATE_SETUP_RETRY from homeassistant.config_entries import ConfigEntryState
from .conftest import mock_config, patch_product_identify from .conftest import mock_config, patch_product_identify
@ -23,7 +23,7 @@ async def test_setup_failure(hass, caplog):
await hass.async_block_till_done() await hass.async_block_till_done()
assert "Identify failed at 172.100.123.4:80 ()" in caplog.text assert "Identify failed at 172.100.123.4:80 ()" in caplog.text
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_setup_failure_on_connection(hass, caplog): async def test_setup_failure_on_connection(hass, caplog):
@ -39,7 +39,7 @@ async def test_setup_failure_on_connection(hass, caplog):
await hass.async_block_till_done() await hass.async_block_till_done()
assert "Identify failed at 172.100.123.4:80 ()" in caplog.text assert "Identify failed at 172.100.123.4:80 ()" in caplog.text
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_config_entry(hass): async def test_unload_config_entry(hass):
@ -57,4 +57,4 @@ async def test_unload_config_entry(hass):
await hass.async_block_till_done() await hass.async_block_till_done()
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED

View file

@ -5,11 +5,7 @@ from aiohttp import ClientConnectionError, ClientResponseError
from bond_api import DeviceType from bond_api import DeviceType
from homeassistant.components.bond.const import DOMAIN from homeassistant.components.bond.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
@ -47,7 +43,7 @@ async def test_async_setup_raises_entry_not_ready(hass: HomeAssistant):
with patch_bond_version(side_effect=ClientConnectionError()): with patch_bond_version(side_effect=ClientConnectionError()):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
assert config_entry.state == ENTRY_STATE_SETUP_RETRY assert config_entry.state is ConfigEntryState.SETUP_RETRY
async def test_async_setup_entry_sets_up_hub_and_supported_domains(hass: HomeAssistant): async def test_async_setup_entry_sets_up_hub_and_supported_domains(hass: HomeAssistant):
@ -75,7 +71,7 @@ async def test_async_setup_entry_sets_up_hub_and_supported_domains(hass: HomeAss
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.entry_id in hass.data[DOMAIN] assert config_entry.entry_id in hass.data[DOMAIN]
assert config_entry.state == ENTRY_STATE_LOADED assert config_entry.state is ConfigEntryState.LOADED
assert config_entry.unique_id == "test-bond-id" assert config_entry.unique_id == "test-bond-id"
# verify hub device is registered correctly # verify hub device is registered correctly
@ -115,7 +111,7 @@ async def test_unload_config_entry(hass: HomeAssistant):
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.entry_id not in hass.data[DOMAIN] assert config_entry.entry_id not in hass.data[DOMAIN]
assert config_entry.state == ENTRY_STATE_NOT_LOADED assert config_entry.state is ConfigEntryState.NOT_LOADED
async def test_old_identifiers_are_removed(hass: HomeAssistant): async def test_old_identifiers_are_removed(hass: HomeAssistant):
@ -159,7 +155,7 @@ async def test_old_identifiers_are_removed(hass: HomeAssistant):
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.entry_id in hass.data[DOMAIN] assert config_entry.entry_id in hass.data[DOMAIN]
assert config_entry.state == ENTRY_STATE_LOADED assert config_entry.state is ConfigEntryState.LOADED
assert config_entry.unique_id == "test-bond-id" assert config_entry.unique_id == "test-bond-id"
# verify the device info is cleaned up # verify the device info is cleaned up
@ -201,7 +197,7 @@ async def test_smart_by_bond_device_suggested_area(hass: HomeAssistant):
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.entry_id in hass.data[DOMAIN] assert config_entry.entry_id in hass.data[DOMAIN]
assert config_entry.state == ENTRY_STATE_LOADED assert config_entry.state is ConfigEntryState.LOADED
assert config_entry.unique_id == "test-bond-id" assert config_entry.unique_id == "test-bond-id"
device_registry = dr.async_get(hass) device_registry = dr.async_get(hass)
@ -247,7 +243,7 @@ async def test_bridge_device_suggested_area(hass: HomeAssistant):
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.entry_id in hass.data[DOMAIN] assert config_entry.entry_id in hass.data[DOMAIN]
assert config_entry.state == ENTRY_STATE_LOADED assert config_entry.state is ConfigEntryState.LOADED
assert config_entry.unique_id == "test-bond-id" assert config_entry.unique_id == "test-bond-id"
device_registry = dr.async_get(hass) device_registry = dr.async_get(hass)

View file

@ -5,12 +5,7 @@ import broadlink.exceptions as blke
from homeassistant.components.broadlink.const import DOMAIN from homeassistant.components.broadlink.const import DOMAIN
from homeassistant.components.broadlink.device import get_domains from homeassistant.components.broadlink.device import get_domains
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.helpers.entity_registry import async_entries_for_device from homeassistant.helpers.entity_registry import async_entries_for_device
from . import get_device from . import get_device
@ -29,7 +24,7 @@ async def test_device_setup(hass):
) as mock_init: ) as mock_init:
mock_api, mock_entry = await device.setup_entry(hass) mock_api, mock_entry = await device.setup_entry(hass)
assert mock_entry.state == ENTRY_STATE_LOADED assert mock_entry.state == ConfigEntryState.LOADED
assert mock_api.auth.call_count == 1 assert mock_api.auth.call_count == 1
assert mock_api.get_fwversion.call_count == 1 assert mock_api.get_fwversion.call_count == 1
forward_entries = {c[1][1] for c in mock_forward.mock_calls} forward_entries = {c[1][1] for c in mock_forward.mock_calls}
@ -52,7 +47,7 @@ async def test_device_setup_authentication_error(hass):
) as mock_init: ) as mock_init:
mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api) mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api)
assert mock_entry.state == ENTRY_STATE_SETUP_ERROR assert mock_entry.state == ConfigEntryState.SETUP_ERROR
assert mock_api.auth.call_count == 1 assert mock_api.auth.call_count == 1
assert mock_forward.call_count == 0 assert mock_forward.call_count == 0
assert mock_init.call_count == 1 assert mock_init.call_count == 1
@ -76,7 +71,7 @@ async def test_device_setup_network_timeout(hass):
) as mock_init: ) as mock_init:
mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api) mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api)
assert mock_entry.state == ENTRY_STATE_SETUP_RETRY assert mock_entry.state is ConfigEntryState.SETUP_RETRY
assert mock_api.auth.call_count == 1 assert mock_api.auth.call_count == 1
assert mock_forward.call_count == 0 assert mock_forward.call_count == 0
assert mock_init.call_count == 0 assert mock_init.call_count == 0
@ -95,7 +90,7 @@ async def test_device_setup_os_error(hass):
) as mock_init: ) as mock_init:
mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api) mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api)
assert mock_entry.state == ENTRY_STATE_SETUP_RETRY assert mock_entry.state is ConfigEntryState.SETUP_RETRY
assert mock_api.auth.call_count == 1 assert mock_api.auth.call_count == 1
assert mock_forward.call_count == 0 assert mock_forward.call_count == 0
assert mock_init.call_count == 0 assert mock_init.call_count == 0
@ -114,7 +109,7 @@ async def test_device_setup_broadlink_exception(hass):
) as mock_init: ) as mock_init:
mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api) mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api)
assert mock_entry.state == ENTRY_STATE_SETUP_ERROR assert mock_entry.state is ConfigEntryState.SETUP_ERROR
assert mock_api.auth.call_count == 1 assert mock_api.auth.call_count == 1
assert mock_forward.call_count == 0 assert mock_forward.call_count == 0
assert mock_init.call_count == 0 assert mock_init.call_count == 0
@ -133,7 +128,7 @@ async def test_device_setup_update_network_timeout(hass):
) as mock_init: ) as mock_init:
mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api) mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api)
assert mock_entry.state == ENTRY_STATE_SETUP_RETRY assert mock_entry.state is ConfigEntryState.SETUP_RETRY
assert mock_api.auth.call_count == 1 assert mock_api.auth.call_count == 1
assert mock_api.check_sensors.call_count == 1 assert mock_api.check_sensors.call_count == 1
assert mock_forward.call_count == 0 assert mock_forward.call_count == 0
@ -156,7 +151,7 @@ async def test_device_setup_update_authorization_error(hass):
) as mock_init: ) as mock_init:
mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api) mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api)
assert mock_entry.state == ENTRY_STATE_LOADED assert mock_entry.state is ConfigEntryState.LOADED
assert mock_api.auth.call_count == 2 assert mock_api.auth.call_count == 2
assert mock_api.check_sensors.call_count == 2 assert mock_api.check_sensors.call_count == 2
forward_entries = {c[1][1] for c in mock_forward.mock_calls} forward_entries = {c[1][1] for c in mock_forward.mock_calls}
@ -180,7 +175,7 @@ async def test_device_setup_update_authentication_error(hass):
) as mock_init: ) as mock_init:
mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api) mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api)
assert mock_entry.state == ENTRY_STATE_SETUP_RETRY assert mock_entry.state is ConfigEntryState.SETUP_RETRY
assert mock_api.auth.call_count == 2 assert mock_api.auth.call_count == 2
assert mock_api.check_sensors.call_count == 1 assert mock_api.check_sensors.call_count == 1
assert mock_forward.call_count == 0 assert mock_forward.call_count == 0
@ -205,7 +200,7 @@ async def test_device_setup_update_broadlink_exception(hass):
) as mock_init: ) as mock_init:
mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api) mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api)
assert mock_entry.state == ENTRY_STATE_SETUP_RETRY assert mock_entry.state is ConfigEntryState.SETUP_RETRY
assert mock_api.auth.call_count == 1 assert mock_api.auth.call_count == 1
assert mock_api.check_sensors.call_count == 1 assert mock_api.check_sensors.call_count == 1
assert mock_forward.call_count == 0 assert mock_forward.call_count == 0
@ -221,7 +216,7 @@ async def test_device_setup_get_fwversion_broadlink_exception(hass):
with patch.object(hass.config_entries, "async_forward_entry_setup") as mock_forward: with patch.object(hass.config_entries, "async_forward_entry_setup") as mock_forward:
mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api) mock_api, mock_entry = await device.setup_entry(hass, mock_api=mock_api)
assert mock_entry.state == ENTRY_STATE_LOADED assert mock_entry.state is ConfigEntryState.LOADED
forward_entries = {c[1][1] for c in mock_forward.mock_calls} forward_entries = {c[1][1] for c in mock_forward.mock_calls}
domains = get_domains(mock_api.type) domains = get_domains(mock_api.type)
assert mock_forward.call_count == len(domains) assert mock_forward.call_count == len(domains)
@ -237,7 +232,7 @@ async def test_device_setup_get_fwversion_os_error(hass):
with patch.object(hass.config_entries, "async_forward_entry_setup") as mock_forward: with patch.object(hass.config_entries, "async_forward_entry_setup") as mock_forward:
_, mock_entry = await device.setup_entry(hass, mock_api=mock_api) _, mock_entry = await device.setup_entry(hass, mock_api=mock_api)
assert mock_entry.state == ENTRY_STATE_LOADED assert mock_entry.state is ConfigEntryState.LOADED
forward_entries = {c[1][1] for c in mock_forward.mock_calls} forward_entries = {c[1][1] for c in mock_forward.mock_calls}
domains = get_domains(mock_api.type) domains = get_domains(mock_api.type)
assert mock_forward.call_count == len(domains) assert mock_forward.call_count == len(domains)
@ -279,7 +274,7 @@ async def test_device_unload_works(hass):
) as mock_forward: ) as mock_forward:
await hass.config_entries.async_unload(mock_entry.entry_id) await hass.config_entries.async_unload(mock_entry.entry_id)
assert mock_entry.state == ENTRY_STATE_NOT_LOADED assert mock_entry.state is ConfigEntryState.NOT_LOADED
forward_entries = {c[1][1] for c in mock_forward.mock_calls} forward_entries = {c[1][1] for c in mock_forward.mock_calls}
domains = get_domains(mock_api.type) domains = get_domains(mock_api.type)
assert mock_forward.call_count == len(domains) assert mock_forward.call_count == len(domains)
@ -302,7 +297,7 @@ async def test_device_unload_authentication_error(hass):
) as mock_forward: ) as mock_forward:
await hass.config_entries.async_unload(mock_entry.entry_id) await hass.config_entries.async_unload(mock_entry.entry_id)
assert mock_entry.state == ENTRY_STATE_NOT_LOADED assert mock_entry.state is ConfigEntryState.NOT_LOADED
assert mock_forward.call_count == 0 assert mock_forward.call_count == 0
@ -320,7 +315,7 @@ async def test_device_unload_update_failed(hass):
) as mock_forward: ) as mock_forward:
await hass.config_entries.async_unload(mock_entry.entry_id) await hass.config_entries.async_unload(mock_entry.entry_id)
assert mock_entry.state == ENTRY_STATE_NOT_LOADED assert mock_entry.state is ConfigEntryState.NOT_LOADED
assert mock_forward.call_count == 0 assert mock_forward.call_count == 0

View file

@ -2,11 +2,7 @@
from unittest.mock import patch from unittest.mock import patch
from homeassistant.components.brother.const import DOMAIN from homeassistant.components.brother.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import CONF_HOST, CONF_TYPE, STATE_UNAVAILABLE from homeassistant.const import CONF_HOST, CONF_TYPE, STATE_UNAVAILABLE
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -35,7 +31,7 @@ async def test_config_not_ready(hass):
with patch("brother.Brother._get_data", side_effect=ConnectionError()): with patch("brother.Brother._get_data", side_effect=ConnectionError()):
entry.add_to_hass(hass) entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_entry(hass): async def test_unload_entry(hass):
@ -43,10 +39,10 @@ async def test_unload_entry(hass):
entry = await init_integration(hass) entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)

View file

@ -2,7 +2,7 @@
import aiohttp import aiohttp
from homeassistant.components.bsblan.const import DOMAIN from homeassistant.components.bsblan.const import DOMAIN
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from tests.components.bsblan import init_integration, init_integration_without_auth from tests.components.bsblan import init_integration, init_integration_without_auth
@ -19,7 +19,7 @@ async def test_config_entry_not_ready(
) )
entry = await init_integration(hass, aioclient_mock) entry = await init_integration(hass, aioclient_mock)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_config_entry( async def test_unload_config_entry(
@ -44,4 +44,4 @@ async def test_config_entry_no_authentication(
) )
entry = await init_integration_without_auth(hass, aioclient_mock) entry = await init_integration_without_auth(hass, aioclient_mock)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY

View file

@ -3,6 +3,7 @@ from unittest.mock import patch
from homeassistant import setup from homeassistant import setup
from homeassistant.components.buienradar.const import DOMAIN from homeassistant.components.buienradar.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.helpers.entity_registry import async_get_registry from homeassistant.helpers.entity_registry import async_get_registry
@ -39,7 +40,7 @@ async def test_import_all(hass):
entry = conf_entries[0] entry = conf_entries[0]
assert entry.state == "loaded" assert entry.state is ConfigEntryState.LOADED
assert entry.data == { assert entry.data == {
"latitude": hass.config.latitude, "latitude": hass.config.latitude,
"longitude": hass.config.longitude, "longitude": hass.config.longitude,
@ -77,7 +78,7 @@ async def test_import_camera(hass):
entry = conf_entries[0] entry = conf_entries[0]
assert entry.state == "loaded" assert entry.state is ConfigEntryState.LOADED
assert entry.data == { assert entry.data == {
"latitude": hass.config.latitude, "latitude": hass.config.latitude,
"longitude": hass.config.longitude, "longitude": hass.config.longitude,
@ -112,9 +113,9 @@ async def test_load_unload(aioclient_mock, hass):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == "loaded" assert entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == "not_loaded" assert entry.state is ConfigEntryState.NOT_LOADED

View file

@ -5,11 +5,7 @@ from requests import ConnectTimeout
from homeassistant.components.camera.const import DOMAIN as CAMERA_DOMAIN from homeassistant.components.camera.const import DOMAIN as CAMERA_DOMAIN
from homeassistant.components.canary.const import CONF_FFMPEG_ARGUMENTS, DOMAIN from homeassistant.components.canary.const import CONF_FFMPEG_ARGUMENTS, DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -64,12 +60,12 @@ async def test_unload_entry(hass, canary):
assert entry assert entry
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)
@ -79,4 +75,4 @@ async def test_async_setup_raises_entry_not_ready(hass, canary):
entry = await init_integration(hass) entry = await init_integration(hass)
assert entry assert entry
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY

View file

@ -4,7 +4,7 @@ from unittest.mock import patch
from homeassistant.components.cert_expiry.const import DOMAIN from homeassistant.components.cert_expiry.const import DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.config_entries import ENTRY_STATE_LOADED, ENTRY_STATE_NOT_LOADED from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CONF_PORT, CONF_PORT,
@ -63,7 +63,7 @@ async def test_update_unique_id(hass):
assert await async_setup_component(hass, DOMAIN, {}) is True assert await async_setup_component(hass, DOMAIN, {}) is True
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert entry.unique_id == f"{HOST}:{PORT}" assert entry.unique_id == f"{HOST}:{PORT}"
@ -89,7 +89,7 @@ async def test_unload_config_entry(mock_now, hass):
assert await async_setup_component(hass, DOMAIN, {}) is True assert await async_setup_component(hass, DOMAIN, {}) is True
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state = hass.states.get("sensor.cert_expiry_timestamp_example_com") state = hass.states.get("sensor.cert_expiry_timestamp_example_com")
assert state.state == timestamp.isoformat() assert state.state == timestamp.isoformat()
assert state.attributes.get("error") == "None" assert state.attributes.get("error") == "None"
@ -97,7 +97,7 @@ async def test_unload_config_entry(mock_now, hass):
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
state = hass.states.get("sensor.cert_expiry_timestamp_example_com") state = hass.states.get("sensor.cert_expiry_timestamp_example_com")
assert state.state == STATE_UNAVAILABLE assert state.state == STATE_UNAVAILABLE

View file

@ -5,7 +5,7 @@ import ssl
from unittest.mock import patch from unittest.mock import patch
from homeassistant.components.cert_expiry.const import DOMAIN from homeassistant.components.cert_expiry.const import DOMAIN
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_HOST, CONF_PORT, STATE_UNAVAILABLE, STATE_UNKNOWN from homeassistant.const import CONF_HOST, CONF_PORT, STATE_UNAVAILABLE, STATE_UNKNOWN
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
@ -81,7 +81,7 @@ async def test_async_setup_entry_host_unavailable(hass):
assert await hass.config_entries.async_setup(entry.entry_id) is False assert await hass.config_entries.async_setup(entry.entry_id) is False
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
next_update = utcnow() + timedelta(seconds=45) next_update = utcnow() + timedelta(seconds=45)
async_fire_time_changed(hass, next_update) async_fire_time_changed(hass, next_update)

View file

@ -2,11 +2,7 @@
from pycfdns.exceptions import CloudflareConnectionException from pycfdns.exceptions import CloudflareConnectionException
from homeassistant.components.cloudflare.const import DOMAIN, SERVICE_UPDATE_RECORDS from homeassistant.components.cloudflare.const import DOMAIN, SERVICE_UPDATE_RECORDS
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from . import ENTRY_CONFIG, init_integration from . import ENTRY_CONFIG, init_integration
@ -18,12 +14,12 @@ async def test_unload_entry(hass, cfupdate):
entry = await init_integration(hass) entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)
@ -37,7 +33,7 @@ async def test_async_setup_raises_entry_not_ready(hass, cfupdate):
instance.get_zone_id.side_effect = CloudflareConnectionException() instance.get_zone_id.side_effect = CloudflareConnectionException()
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_integration_services(hass, cfupdate): async def test_integration_services(hass, cfupdate):
@ -45,7 +41,7 @@ async def test_integration_services(hass, cfupdate):
instance = cfupdate.return_value instance = cfupdate.return_value
entry = await init_integration(hass) entry = await init_integration(hass)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.services.async_call( await hass.services.async_call(
DOMAIN, DOMAIN,

View file

@ -64,7 +64,7 @@ async def test_get_entries(hass, client):
domain="comp2", domain="comp2",
title="Test 2", title="Test 2",
source="bla2", source="bla2",
state=core_ce.ENTRY_STATE_SETUP_ERROR, state=core_ce.ConfigEntryState.SETUP_ERROR,
reason="Unsupported API", reason="Unsupported API",
).add_to_hass(hass) ).add_to_hass(hass)
MockConfigEntry( MockConfigEntry(
@ -84,7 +84,7 @@ async def test_get_entries(hass, client):
"domain": "comp1", "domain": "comp1",
"title": "Test 1", "title": "Test 1",
"source": "bla", "source": "bla",
"state": "not_loaded", "state": core_ce.ConfigEntryState.NOT_LOADED.value,
"supports_options": True, "supports_options": True,
"supports_unload": True, "supports_unload": True,
"disabled_by": None, "disabled_by": None,
@ -94,7 +94,7 @@ async def test_get_entries(hass, client):
"domain": "comp2", "domain": "comp2",
"title": "Test 2", "title": "Test 2",
"source": "bla2", "source": "bla2",
"state": "setup_error", "state": core_ce.ConfigEntryState.SETUP_ERROR.value,
"supports_options": False, "supports_options": False,
"supports_unload": False, "supports_unload": False,
"disabled_by": None, "disabled_by": None,
@ -104,7 +104,7 @@ async def test_get_entries(hass, client):
"domain": "comp3", "domain": "comp3",
"title": "Test 3", "title": "Test 3",
"source": "bla3", "source": "bla3",
"state": "not_loaded", "state": core_ce.ConfigEntryState.NOT_LOADED.value,
"supports_options": False, "supports_options": False,
"supports_unload": False, "supports_unload": False,
"disabled_by": core_ce.DISABLED_USER, "disabled_by": core_ce.DISABLED_USER,
@ -115,7 +115,7 @@ async def test_get_entries(hass, client):
async def test_remove_entry(hass, client): async def test_remove_entry(hass, client):
"""Test removing an entry via the API.""" """Test removing an entry via the API."""
entry = MockConfigEntry(domain="demo", state=core_ce.ENTRY_STATE_LOADED) entry = MockConfigEntry(domain="demo", state=core_ce.ConfigEntryState.LOADED)
entry.add_to_hass(hass) entry.add_to_hass(hass)
resp = await client.delete(f"/api/config/config_entries/entry/{entry.entry_id}") resp = await client.delete(f"/api/config/config_entries/entry/{entry.entry_id}")
assert resp.status == 200 assert resp.status == 200
@ -126,7 +126,7 @@ async def test_remove_entry(hass, client):
async def test_reload_entry(hass, client): async def test_reload_entry(hass, client):
"""Test reloading an entry via the API.""" """Test reloading an entry via the API."""
entry = MockConfigEntry(domain="demo", state=core_ce.ENTRY_STATE_LOADED) entry = MockConfigEntry(domain="demo", state=core_ce.ConfigEntryState.LOADED)
entry.add_to_hass(hass) entry.add_to_hass(hass)
resp = await client.post( resp = await client.post(
f"/api/config/config_entries/entry/{entry.entry_id}/reload" f"/api/config/config_entries/entry/{entry.entry_id}/reload"
@ -146,7 +146,7 @@ async def test_reload_invalid_entry(hass, client):
async def test_remove_entry_unauth(hass, client, hass_admin_user): async def test_remove_entry_unauth(hass, client, hass_admin_user):
"""Test removing an entry via the API.""" """Test removing an entry via the API."""
hass_admin_user.groups = [] hass_admin_user.groups = []
entry = MockConfigEntry(domain="demo", state=core_ce.ENTRY_STATE_LOADED) entry = MockConfigEntry(domain="demo", state=core_ce.ConfigEntryState.LOADED)
entry.add_to_hass(hass) entry.add_to_hass(hass)
resp = await client.delete(f"/api/config/config_entries/entry/{entry.entry_id}") resp = await client.delete(f"/api/config/config_entries/entry/{entry.entry_id}")
assert resp.status == 401 assert resp.status == 401
@ -156,7 +156,7 @@ async def test_remove_entry_unauth(hass, client, hass_admin_user):
async def test_reload_entry_unauth(hass, client, hass_admin_user): async def test_reload_entry_unauth(hass, client, hass_admin_user):
"""Test reloading an entry via the API.""" """Test reloading an entry via the API."""
hass_admin_user.groups = [] hass_admin_user.groups = []
entry = MockConfigEntry(domain="demo", state=core_ce.ENTRY_STATE_LOADED) entry = MockConfigEntry(domain="demo", state=core_ce.ConfigEntryState.LOADED)
entry.add_to_hass(hass) entry.add_to_hass(hass)
resp = await client.post( resp = await client.post(
f"/api/config/config_entries/entry/{entry.entry_id}/reload" f"/api/config/config_entries/entry/{entry.entry_id}/reload"
@ -167,7 +167,7 @@ async def test_reload_entry_unauth(hass, client, hass_admin_user):
async def test_reload_entry_in_failed_state(hass, client, hass_admin_user): async def test_reload_entry_in_failed_state(hass, client, hass_admin_user):
"""Test reloading an entry via the API that has already failed to unload.""" """Test reloading an entry via the API that has already failed to unload."""
entry = MockConfigEntry(domain="demo", state=core_ce.ENTRY_STATE_FAILED_UNLOAD) entry = MockConfigEntry(domain="demo", state=core_ce.ConfigEntryState.FAILED_UNLOAD)
entry.add_to_hass(hass) entry.add_to_hass(hass)
resp = await client.post( resp = await client.post(
f"/api/config/config_entries/entry/{entry.entry_id}/reload" f"/api/config/config_entries/entry/{entry.entry_id}/reload"
@ -325,7 +325,7 @@ async def test_create_account(hass, client, enable_custom_integrations):
"domain": "test", "domain": "test",
"entry_id": entries[0].entry_id, "entry_id": entries[0].entry_id,
"source": core_ce.SOURCE_USER, "source": core_ce.SOURCE_USER,
"state": "loaded", "state": core_ce.ConfigEntryState.LOADED.value,
"supports_options": False, "supports_options": False,
"supports_unload": False, "supports_unload": False,
"title": "Test Entry", "title": "Test Entry",
@ -396,7 +396,7 @@ async def test_two_step_flow(hass, client, enable_custom_integrations):
"domain": "test", "domain": "test",
"entry_id": entries[0].entry_id, "entry_id": entries[0].entry_id,
"source": core_ce.SOURCE_USER, "source": core_ce.SOURCE_USER,
"state": "loaded", "state": core_ce.ConfigEntryState.LOADED.value,
"supports_options": False, "supports_options": False,
"supports_unload": False, "supports_unload": False,
"title": "user-title", "title": "user-title",
@ -788,7 +788,7 @@ async def test_disable_entry(hass, hass_ws_client):
assert await async_setup_component(hass, "config", {}) assert await async_setup_component(hass, "config", {})
ws_client = await hass_ws_client(hass) ws_client = await hass_ws_client(hass)
entry = MockConfigEntry(domain="demo", state="loaded") entry = MockConfigEntry(domain="demo", state=core_ce.ConfigEntryState.LOADED)
entry.add_to_hass(hass) entry.add_to_hass(hass)
assert entry.disabled_by is None assert entry.disabled_by is None
@ -806,7 +806,7 @@ async def test_disable_entry(hass, hass_ws_client):
assert response["success"] assert response["success"]
assert response["result"] == {"require_restart": True} assert response["result"] == {"require_restart": True}
assert entry.disabled_by == core_ce.DISABLED_USER assert entry.disabled_by == core_ce.DISABLED_USER
assert entry.state == "failed_unload" assert entry.state is core_ce.ConfigEntryState.FAILED_UNLOAD
# Enable # Enable
await ws_client.send_json( await ws_client.send_json(
@ -822,7 +822,7 @@ async def test_disable_entry(hass, hass_ws_client):
assert response["success"] assert response["success"]
assert response["result"] == {"require_restart": True} assert response["result"] == {"require_restart": True}
assert entry.disabled_by is None assert entry.disabled_by is None
assert entry.state == "failed_unload" assert entry.state == core_ce.ConfigEntryState.FAILED_UNLOAD
# Enable again -> no op # Enable again -> no op
await ws_client.send_json( await ws_client.send_json(
@ -838,7 +838,7 @@ async def test_disable_entry(hass, hass_ws_client):
assert response["success"] assert response["success"]
assert response["result"] == {"require_restart": False} assert response["result"] == {"require_restart": False}
assert entry.disabled_by is None assert entry.disabled_by is None
assert entry.state == "failed_unload" assert entry.state == core_ce.ConfigEntryState.FAILED_UNLOAD
async def test_disable_entry_nonexisting(hass, hass_ws_client): async def test_disable_entry_nonexisting(hass, hass_ws_client):

View file

@ -4,7 +4,7 @@ from unittest.mock import MagicMock, patch
from aiohttp import ClientError from aiohttp import ClientError
from homeassistant.components.coronavirus.const import DOMAIN, OPTION_WORLDWIDE from homeassistant.components.coronavirus.const import DOMAIN, OPTION_WORLDWIDE
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -69,4 +69,4 @@ async def test_config_entry_not_ready(
assert await async_setup_component(hass, DOMAIN, {}) assert await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY

View file

@ -4,12 +4,7 @@ from unittest.mock import patch
from devolo_home_control_api.exceptions.gateway import GatewayOfflineError from devolo_home_control_api.exceptions.gateway import GatewayOfflineError
import pytest import pytest
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from tests.components.devolo_home_control import configure_integration from tests.components.devolo_home_control import configure_integration
@ -20,7 +15,7 @@ async def test_setup_entry(hass: HomeAssistant):
entry = configure_integration(hass) entry = configure_integration(hass)
with patch("homeassistant.components.devolo_home_control.HomeControl"): with patch("homeassistant.components.devolo_home_control.HomeControl"):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
@pytest.mark.credentials_invalid @pytest.mark.credentials_invalid
@ -28,7 +23,7 @@ async def test_setup_entry_credentials_invalid(hass: HomeAssistant):
"""Test setup entry fails if credentials are invalid.""" """Test setup entry fails if credentials are invalid."""
entry = configure_integration(hass) entry = configure_integration(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == ENTRY_STATE_SETUP_ERROR assert entry.state is ConfigEntryState.SETUP_ERROR
@pytest.mark.maintenance @pytest.mark.maintenance
@ -36,7 +31,7 @@ async def test_setup_entry_maintenance(hass: HomeAssistant):
"""Test setup entry fails if mydevolo is in maintenance mode.""" """Test setup entry fails if mydevolo is in maintenance mode."""
entry = configure_integration(hass) entry = configure_integration(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_setup_gateway_offline(hass: HomeAssistant): async def test_setup_gateway_offline(hass: HomeAssistant):
@ -47,7 +42,7 @@ async def test_setup_gateway_offline(hass: HomeAssistant):
side_effect=GatewayOfflineError, side_effect=GatewayOfflineError,
): ):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_entry(hass: HomeAssistant): async def test_unload_entry(hass: HomeAssistant):
@ -57,4 +52,4 @@ async def test_unload_entry(hass: HomeAssistant):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED

View file

@ -4,7 +4,7 @@ from unittest.mock import patch
from pydexcom import AccountError, SessionError from pydexcom import AccountError, SessionError
from homeassistant.components.dexcom.const import DOMAIN from homeassistant.components.dexcom.const import DOMAIN
from homeassistant.config_entries import ENTRY_STATE_LOADED, ENTRY_STATE_NOT_LOADED from homeassistant.config_entries import ConfigEntryState
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
from tests.components.dexcom import CONFIG, init_integration from tests.components.dexcom import CONFIG, init_integration
@ -55,10 +55,10 @@ async def test_unload_entry(hass):
entry = await init_integration(hass) entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)

View file

@ -1,10 +1,6 @@
"""Tests for the DirecTV integration.""" """Tests for the DirecTV integration."""
from homeassistant.components.directv.const import DOMAIN from homeassistant.components.directv.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from tests.components.directv import setup_integration from tests.components.directv import setup_integration
@ -19,7 +15,7 @@ async def test_config_entry_not_ready(
"""Test the DirecTV configuration entry not ready.""" """Test the DirecTV configuration entry not ready."""
entry = await setup_integration(hass, aioclient_mock, setup_error=True) entry = await setup_integration(hass, aioclient_mock, setup_error=True)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_config_entry( async def test_unload_config_entry(
@ -29,10 +25,10 @@ async def test_unload_config_entry(
entry = await setup_integration(hass, aioclient_mock) entry = await setup_integration(hass, aioclient_mock)
assert entry.entry_id in hass.data[DOMAIN] assert entry.entry_id in hass.data[DOMAIN]
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.entry_id not in hass.data[DOMAIN] assert entry.entry_id not in hass.data[DOMAIN]
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED

View file

@ -11,6 +11,7 @@ from decimal import Decimal
from itertools import chain, repeat from itertools import chain, repeat
from unittest.mock import DEFAULT, MagicMock from unittest.mock import DEFAULT, MagicMock
from homeassistant import config_entries
from homeassistant.components.dsmr.const import DOMAIN from homeassistant.components.dsmr.const import DOMAIN
from homeassistant.components.dsmr.sensor import DerivativeDSMREntity from homeassistant.components.dsmr.sensor import DerivativeDSMREntity
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
@ -59,7 +60,7 @@ async def test_setup_platform(hass, dsmr_connection_fixture):
entry = conf_entries[0] entry = conf_entries[0]
assert entry.state == "loaded" assert entry.state == config_entries.ConfigEntryState.LOADED
assert entry.data == {**entry_data, **serial_data} assert entry.data == {**entry_data, **serial_data}
@ -625,4 +626,4 @@ async def test_reconnect(hass, dsmr_connection_fixture):
await hass.config_entries.async_unload(mock_entry.entry_id) await hass.config_entries.async_unload(mock_entry.entry_id)
assert mock_entry.state == "not_loaded" assert mock_entry.state == config_entries.ConfigEntryState.NOT_LOADED

View file

@ -13,9 +13,9 @@ from tests.common import MockConfigEntry
@pytest.mark.parametrize( @pytest.mark.parametrize(
"first_con, second_con,exp_type, exp_result, exp_reason", "first_con, second_con,exp_type, exp_result, exp_reason",
[ [
(True, True, "create_entry", "loaded", ""), (True, True, "create_entry", config_entries.ConfigEntryState.LOADED, ""),
(False, False, "abort", "", "no_connection"), (False, False, "abort", None, "no_connection"),
(True, False, "create_entry", "setup_retry", ""), (True, False, "create_entry", config_entries.ConfigEntryState.SETUP_RETRY, ""),
], ],
) )
async def test_flow(hass, first_con, second_con, exp_type, exp_result, exp_reason): async def test_flow(hass, first_con, second_con, exp_type, exp_result, exp_reason):
@ -104,4 +104,4 @@ async def test_two_entries(hass):
data={dynalite.CONF_HOST: host2}, data={dynalite.CONF_HOST: host2},
) )
assert result["type"] == "create_entry" assert result["type"] == "create_entry"
assert result["result"].state == "loaded" assert result["result"].state == config_entries.ConfigEntryState.LOADED

View file

@ -35,7 +35,7 @@ async def async_setup_test_fixture(hass, mock_get_station, initial_value):
entry.add_to_hass(hass) entry.add_to_hass(hass)
assert await async_setup_component(hass, "eafm", {}) assert await async_setup_component(hass, "eafm", {})
assert entry.state == config_entries.ENTRY_STATE_LOADED assert entry.state is config_entries.ConfigEntryState.LOADED
await hass.async_block_till_done() await hass.async_block_till_done()
async def poll(value): async def poll(value):

View file

@ -2,7 +2,7 @@
import aiohttp import aiohttp
from homeassistant.components.elgato.const import DOMAIN from homeassistant.components.elgato.const import DOMAIN
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from tests.components.elgato import init_integration from tests.components.elgato import init_integration
@ -18,7 +18,7 @@ async def test_config_entry_not_ready(
) )
entry = await init_integration(hass, aioclient_mock) entry = await init_integration(hass, aioclient_mock)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_config_entry( async def test_unload_config_entry(

View file

@ -5,7 +5,7 @@ from homeassistant.components.device_tracker import DOMAIN as DT_DOMAIN
from homeassistant.components.freebox.const import DOMAIN as DOMAIN, SERVICE_REBOOT from homeassistant.components.freebox.const import DOMAIN as DOMAIN, SERVICE_REBOOT
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.config_entries import ENTRY_STATE_LOADED, ENTRY_STATE_NOT_LOADED from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_HOST, CONF_PORT, STATE_UNAVAILABLE from homeassistant.const import CONF_HOST, CONF_PORT, STATE_UNAVAILABLE
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -85,7 +85,7 @@ async def test_unload_remove(hass: HomeAssistant, router: Mock):
assert await async_setup_component(hass, DOMAIN, {}) is True assert await async_setup_component(hass, DOMAIN, {}) is True
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state_dt = hass.states.get(entity_id_dt) state_dt = hass.states.get(entity_id_dt)
assert state_dt assert state_dt
state_sensor = hass.states.get(entity_id_sensor) state_sensor = hass.states.get(entity_id_sensor)
@ -95,7 +95,7 @@ async def test_unload_remove(hass: HomeAssistant, router: Mock):
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
state_dt = hass.states.get(entity_id_dt) state_dt = hass.states.get(entity_id_dt)
assert state_dt.state == STATE_UNAVAILABLE assert state_dt.state == STATE_UNAVAILABLE
state_sensor = hass.states.get(entity_id_sensor) state_sensor = hass.states.get(entity_id_sensor)
@ -110,7 +110,7 @@ async def test_unload_remove(hass: HomeAssistant, router: Mock):
await hass.async_block_till_done() await hass.async_block_till_done()
assert router().close.call_count == 1 assert router().close.call_count == 1
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
state_dt = hass.states.get(entity_id_dt) state_dt = hass.states.get(entity_id_dt)
assert state_dt is None assert state_dt is None
state_sensor = hass.states.get(entity_id_sensor) state_sensor = hass.states.get(entity_id_sensor)

View file

@ -8,11 +8,7 @@ from requests.exceptions import HTTPError
from homeassistant.components.fritzbox.const import DOMAIN as FB_DOMAIN from homeassistant.components.fritzbox.const import DOMAIN as FB_DOMAIN
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_DEVICES, CONF_DEVICES,
CONF_HOST, CONF_HOST,
@ -94,14 +90,14 @@ async def test_unload_remove(hass: HomeAssistant, fritz: Mock):
assert await hass.config_entries.async_setup(entry.entry_id) assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
assert state assert state
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
assert fritz().logout.call_count == 1 assert fritz().logout.call_count == 1
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
assert state.state == STATE_UNAVAILABLE assert state.state == STATE_UNAVAILABLE
@ -109,13 +105,13 @@ async def test_unload_remove(hass: HomeAssistant, fritz: Mock):
await hass.async_block_till_done() await hass.async_block_till_done()
assert fritz().logout.call_count == 1 assert fritz().logout.call_count == 1
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
assert state is None assert state is None
async def test_raise_config_entry_not_ready_when_offline(hass: HomeAssistant): async def test_raise_config_entry_not_ready_when_offline(hass: HomeAssistant):
"""Config entry state is ENTRY_STATE_SETUP_RETRY when fritzbox is offline.""" """Config entry state is SETUP_RETRY when fritzbox is offline."""
entry = MockConfigEntry( entry = MockConfigEntry(
domain=FB_DOMAIN, domain=FB_DOMAIN,
data={CONF_HOST: "any", **MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0]}, data={CONF_HOST: "any", **MOCK_CONFIG[FB_DOMAIN][CONF_DEVICES][0]},
@ -132,4 +128,4 @@ async def test_raise_config_entry_not_ready_when_offline(hass: HomeAssistant):
entries = hass.config_entries.async_entries() entries = hass.config_entries.async_entries()
config_entry = entries[0] config_entry = entries[0]
assert config_entry.state == ENTRY_STATE_SETUP_ERROR assert config_entry.state is ConfigEntryState.SETUP_ERROR

View file

@ -3,11 +3,7 @@ import json
from unittest.mock import patch from unittest.mock import patch
from homeassistant.components.gios.const import DOMAIN from homeassistant.components.gios.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import STATE_UNAVAILABLE from homeassistant.const import STATE_UNAVAILABLE
from . import STATIONS from . import STATIONS
@ -41,7 +37,7 @@ async def test_config_not_ready(hass):
): ):
entry.add_to_hass(hass) entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_entry(hass): async def test_unload_entry(hass):
@ -49,12 +45,12 @@ async def test_unload_entry(hass):
entry = await init_integration(hass) entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)

View file

@ -2,7 +2,7 @@
from unittest.mock import patch from unittest.mock import patch
from homeassistant.components.gree.const import DOMAIN as GREE_DOMAIN from homeassistant.components.gree.const import DOMAIN as GREE_DOMAIN
from homeassistant.config_entries import ENTRY_STATE_LOADED, ENTRY_STATE_NOT_LOADED from homeassistant.config_entries import ConfigEntryState
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -25,7 +25,7 @@ async def test_setup_simple(hass):
assert len(climate_setup.mock_calls) == 1 assert len(climate_setup.mock_calls) == 1
assert len(switch_setup.mock_calls) == 1 assert len(switch_setup.mock_calls) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
# No flows started # No flows started
assert len(hass.config_entries.flow.async_progress()) == 0 assert len(hass.config_entries.flow.async_progress()) == 0
@ -43,4 +43,4 @@ async def test_unload_config_entry(hass):
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED

View file

@ -36,7 +36,7 @@ async def test_loading(hass, mock_config_entry):
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(mock_check.mock_calls) == 1 assert len(mock_check.mock_calls) == 1
assert mock_config_entry.state == config_entries.ENTRY_STATE_LOADED assert mock_config_entry.state is config_entries.ConfigEntryState.LOADED
async def test_loading_with_no_config(hass, mock_config_entry): async def test_loading_with_no_config(hass, mock_config_entry):
@ -44,7 +44,7 @@ async def test_loading_with_no_config(hass, mock_config_entry):
mock_config_entry.add_to_hass(hass) mock_config_entry.add_to_hass(hass)
await setup.async_setup_component(hass, DOMAIN, {}) await setup.async_setup_component(hass, DOMAIN, {})
# Component setup fails because the oauth2 implementation could not be registered # Component setup fails because the oauth2 implementation could not be registered
assert mock_config_entry.state == config_entries.ENTRY_STATE_SETUP_ERROR assert mock_config_entry.state is config_entries.ConfigEntryState.SETUP_ERROR
async def test_unloading(hass, mock_config_entry): async def test_unloading(hass, mock_config_entry):
@ -68,8 +68,8 @@ async def test_unloading(hass, mock_config_entry):
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(mock_check.mock_calls) == 1 assert len(mock_check.mock_calls) == 1
assert mock_config_entry.state == config_entries.ENTRY_STATE_LOADED assert mock_config_entry.state is config_entries.ConfigEntryState.LOADED
# We now unload the entry # We now unload the entry
assert await hass.config_entries.async_unload(mock_config_entry.entry_id) assert await hass.config_entries.async_unload(mock_config_entry.entry_id)
assert mock_config_entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert mock_config_entry.state is config_entries.ConfigEntryState.NOT_LOADED

View file

@ -388,7 +388,7 @@ async def test_initial_api_error(
assert len(mock_check.mock_calls) == 1 assert len(mock_check.mock_calls) == 1
# The component has been loaded # The component has been loaded
assert mock_config_entry.state == config_entries.ENTRY_STATE_LOADED assert mock_config_entry.state is config_entries.ConfigEntryState.LOADED
# Check the entities and devices - None have been configured # Check the entities and devices - None have been configured
entity_assertions(hass, num_exp_entities=0) entity_assertions(hass, num_exp_entities=0)
@ -421,7 +421,7 @@ async def test_update_with_api_error(
assert len(mock_check.mock_calls) == 1 assert len(mock_check.mock_calls) == 1
# The component has been loaded # The component has been loaded
assert mock_config_entry.state == config_entries.ENTRY_STATE_LOADED assert mock_config_entry.state is config_entries.ConfigEntryState.LOADED
# Check the entities and devices - all entities should be there # Check the entities and devices - all entities should be there
entity_assertions( entity_assertions(

View file

@ -14,7 +14,7 @@ from homeassistant.components.climate.const import (
SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE,
SUPPORT_TARGET_TEMPERATURE_RANGE, SUPPORT_TARGET_TEMPERATURE_RANGE,
) )
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY from homeassistant.config_entries import ConfigEntryState
from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.components.homekit_controller.common import ( from tests.components.homekit_controller.common import (
@ -143,7 +143,7 @@ async def test_ecobee3_setup_connection_failure(hass):
# If there is no cached entity map and the accessory connection is # If there is no cached entity map and the accessory connection is
# failing then we have to fail the config entry setup. # failing then we have to fail the config entry setup.
config_entry, pairing = await setup_test_accessories(hass, accessories) config_entry, pairing = await setup_test_accessories(hass, accessories)
assert config_entry.state == ENTRY_STATE_SETUP_RETRY assert config_entry.state is ConfigEntryState.SETUP_RETRY
climate = entity_registry.async_get("climate.homew") climate = entity_registry.async_get("climate.homew")
assert climate is None assert climate is None

View file

@ -18,7 +18,7 @@ from homeassistant.components.homematicip_cloud.hap import (
HomematicipAuth, HomematicipAuth,
HomematicipHAP, HomematicipHAP,
) )
from homeassistant.config_entries import ENTRY_STATE_NOT_LOADED from homeassistant.config_entries import ConfigEntryState
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
from .helper import HAPID, HAPPIN from .helper import HAPID, HAPPIN
@ -109,7 +109,7 @@ async def test_hap_reset_unloads_entry_if_setup(hass, default_mock_hap_factory):
# hap_reset is called during unload # hap_reset is called during unload
await hass.config_entries.async_unload(config_entries[0].entry_id) await hass.config_entries.async_unload(config_entries[0].entry_id)
# entry is unloaded # entry is unloaded
assert config_entries[0].state == ENTRY_STATE_NOT_LOADED assert config_entries[0].state is ConfigEntryState.NOT_LOADED
assert hass.data[HMIPC_DOMAIN] == {} assert hass.data[HMIPC_DOMAIN] == {}

View file

@ -13,12 +13,7 @@ from homeassistant.components.homematicip_cloud.const import (
HMIPC_NAME, HMIPC_NAME,
) )
from homeassistant.components.homematicip_cloud.hap import HomematicipHAP from homeassistant.components.homematicip_cloud.hap import HomematicipHAP
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -116,7 +111,7 @@ async def test_load_entry_fails_due_to_connection_error(
assert await async_setup_component(hass, HMIPC_DOMAIN, {}) assert await async_setup_component(hass, HMIPC_DOMAIN, {})
assert hass.data[HMIPC_DOMAIN][hmip_config_entry.unique_id] assert hass.data[HMIPC_DOMAIN][hmip_config_entry.unique_id]
assert hmip_config_entry.state == ENTRY_STATE_SETUP_RETRY assert hmip_config_entry.state is ConfigEntryState.SETUP_RETRY
async def test_load_entry_fails_due_to_generic_exception(hass, hmip_config_entry): async def test_load_entry_fails_due_to_generic_exception(hass, hmip_config_entry):
@ -132,7 +127,7 @@ async def test_load_entry_fails_due_to_generic_exception(hass, hmip_config_entry
assert await async_setup_component(hass, HMIPC_DOMAIN, {}) assert await async_setup_component(hass, HMIPC_DOMAIN, {})
assert hass.data[HMIPC_DOMAIN][hmip_config_entry.unique_id] assert hass.data[HMIPC_DOMAIN][hmip_config_entry.unique_id]
assert hmip_config_entry.state == ENTRY_STATE_SETUP_ERROR assert hmip_config_entry.state is ConfigEntryState.SETUP_ERROR
async def test_unload_entry(hass): async def test_unload_entry(hass):
@ -157,9 +152,9 @@ async def test_unload_entry(hass):
assert hass.data[HMIPC_DOMAIN]["ABC123"] assert hass.data[HMIPC_DOMAIN]["ABC123"]
config_entries = hass.config_entries.async_entries(HMIPC_DOMAIN) config_entries = hass.config_entries.async_entries(HMIPC_DOMAIN)
assert len(config_entries) == 1 assert len(config_entries) == 1
assert config_entries[0].state == ENTRY_STATE_LOADED assert config_entries[0].state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(config_entries[0].entry_id) await hass.config_entries.async_unload(config_entries[0].entry_id)
assert config_entries[0].state == ENTRY_STATE_NOT_LOADED assert config_entries[0].state is ConfigEntryState.NOT_LOADED
assert mock_hap.return_value.mock_calls[2][0] == "async_reset" assert mock_hap.return_value.mock_calls[2][0] == "async_reset"
# entry is unloaded # entry is unloaded
assert hass.data[HMIPC_DOMAIN] == {} assert hass.data[HMIPC_DOMAIN] == {}

View file

@ -4,11 +4,7 @@ from unittest.mock import patch
from huisbaasje import HuisbaasjeException from huisbaasje import HuisbaasjeException
from homeassistant.components import huisbaasje from homeassistant.components import huisbaasje
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
)
from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME, STATE_UNAVAILABLE from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME, STATE_UNAVAILABLE
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -49,12 +45,12 @@ async def test_setup_entry(hass: HomeAssistant):
) )
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
assert config_entry.state == ENTRY_STATE_NOT_LOADED assert config_entry.state is ConfigEntryState.NOT_LOADED
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
# Assert integration is loaded # Assert integration is loaded
assert config_entry.state == ENTRY_STATE_LOADED assert config_entry.state is ConfigEntryState.LOADED
assert huisbaasje.DOMAIN in hass.config.components assert huisbaasje.DOMAIN in hass.config.components
assert huisbaasje.DOMAIN in hass.data assert huisbaasje.DOMAIN in hass.data
assert config_entry.entry_id in hass.data[huisbaasje.DOMAIN] assert config_entry.entry_id in hass.data[huisbaasje.DOMAIN]
@ -89,12 +85,12 @@ async def test_setup_entry_error(hass: HomeAssistant):
) )
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
assert config_entry.state == ENTRY_STATE_NOT_LOADED assert config_entry.state is ConfigEntryState.NOT_LOADED
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
# Assert integration is loaded with error # Assert integration is loaded with error
assert config_entry.state == ENTRY_STATE_SETUP_ERROR assert config_entry.state is ConfigEntryState.SETUP_ERROR
assert huisbaasje.DOMAIN not in hass.data assert huisbaasje.DOMAIN not in hass.data
# Assert entities are not loaded # Assert entities are not loaded
@ -133,13 +129,13 @@ async def test_unload_entry(hass: HomeAssistant):
# Load config entry # Load config entry
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_LOADED assert config_entry.state is ConfigEntryState.LOADED
entities = hass.states.async_entity_ids("sensor") entities = hass.states.async_entity_ids("sensor")
assert len(entities) == 14 assert len(entities) == 14
# Unload config entry # Unload config entry
await hass.config_entries.async_unload(config_entry.entry_id) await hass.config_entries.async_unload(config_entry.entry_id)
assert config_entry.state == ENTRY_STATE_NOT_LOADED assert config_entry.state is ConfigEntryState.NOT_LOADED
entities = hass.states.async_entity_ids("sensor") entities = hass.states.async_entity_ids("sensor")
assert len(entities) == 14 assert len(entities) == 14
for entity in entities: for entity in entities:

View file

@ -25,10 +25,10 @@ from homeassistant.components.light import (
DOMAIN as LIGHT_DOMAIN, DOMAIN as LIGHT_DOMAIN,
) )
from homeassistant.config_entries import ( from homeassistant.config_entries import (
ENTRY_STATE_SETUP_ERROR,
RELOAD_AFTER_UPDATE_DELAY, RELOAD_AFTER_UPDATE_DELAY,
SOURCE_REAUTH, SOURCE_REAUTH,
ConfigEntry, ConfigEntry,
ConfigEntryState,
) )
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_ENTITY_ID,
@ -900,7 +900,7 @@ async def test_setup_entry_no_token_reauth(hass: HomeAssistant) -> None:
}, },
data=config_entry.data, data=config_entry.data,
) )
assert config_entry.state == ENTRY_STATE_SETUP_ERROR assert config_entry.state is ConfigEntryState.SETUP_ERROR
async def test_setup_entry_bad_token_reauth(hass: HomeAssistant) -> None: async def test_setup_entry_bad_token_reauth(hass: HomeAssistant) -> None:
@ -928,7 +928,7 @@ async def test_setup_entry_bad_token_reauth(hass: HomeAssistant) -> None:
}, },
data=config_entry.data, data=config_entry.data,
) )
assert config_entry.state == ENTRY_STATE_SETUP_ERROR assert config_entry.state is ConfigEntryState.SETUP_ERROR
async def test_priority_light_async_updates( async def test_priority_light_async_updates(

View file

@ -5,11 +5,7 @@ from uuid import uuid4
import pytest import pytest
from homeassistant.components.ialarm.const import DOMAIN from homeassistant.components.ialarm.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.const import CONF_HOST, CONF_PORT
from tests.common import MockConfigEntry 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() await hass.async_block_till_done()
ialarm_api.return_value.get_mac.assert_called_once() 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): 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) mock_config_entry.add_to_hass(hass)
assert not await hass.config_entries.async_setup(mock_config_entry.entry_id) assert not await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done() 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): 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) assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done() 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 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

View file

@ -110,7 +110,7 @@ async def test_fail_on_existing(hass: HomeAssistant):
options={}, options={},
) )
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
assert config_entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert config_entry.state is config_entries.ConfigEntryState.NOT_LOADED
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, DOMAIN,
@ -276,7 +276,7 @@ async def test_import_existing(hass: HomeAssistant):
options={}, options={},
) )
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
assert config_entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert config_entry.state is config_entries.ConfigEntryState.NOT_LOADED
result = await _import_config( result = await _import_config(
hass, {**MOCK_IMPORT_MINIMUM_HUB_V2, CONF_PORT: 25105, CONF_HUB_VERSION: 2} hass, {**MOCK_IMPORT_MINIMUM_HUB_V2, CONF_PORT: 25105, CONF_HUB_VERSION: 2}

View file

@ -1,10 +1,6 @@
"""Tests for the IPP integration.""" """Tests for the IPP integration."""
from homeassistant.components.ipp.const import DOMAIN from homeassistant.components.ipp.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from tests.components.ipp import init_integration from tests.components.ipp import init_integration
@ -16,7 +12,7 @@ async def test_config_entry_not_ready(
) -> None: ) -> None:
"""Test the IPP configuration entry not ready.""" """Test the IPP configuration entry not ready."""
entry = await init_integration(hass, aioclient_mock, conn_error=True) entry = await init_integration(hass, aioclient_mock, conn_error=True)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_config_entry( async def test_unload_config_entry(
@ -27,10 +23,10 @@ async def test_unload_config_entry(
assert hass.data[DOMAIN] assert hass.data[DOMAIN]
assert entry.entry_id in hass.data[DOMAIN] assert entry.entry_id in hass.data[DOMAIN]
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.entry_id not in hass.data[DOMAIN] assert entry.entry_id not in hass.data[DOMAIN]
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED

View file

@ -52,7 +52,7 @@ async def test_successful_config_entry(hass, legacy_patchable_time):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == config_entries.ENTRY_STATE_LOADED assert entry.state is config_entries.ConfigEntryState.LOADED
assert entry.options == { assert entry.options == {
islamic_prayer_times.CONF_CALC_METHOD: islamic_prayer_times.DEFAULT_CALC_METHOD islamic_prayer_times.CONF_CALC_METHOD: islamic_prayer_times.DEFAULT_CALC_METHOD
} }
@ -74,7 +74,7 @@ async def test_setup_failed(hass, legacy_patchable_time):
): ):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == config_entries.ENTRY_STATE_SETUP_RETRY assert entry.state is config_entries.ConfigEntryState.SETUP_RETRY
async def test_unload_entry(hass, legacy_patchable_time): async def test_unload_entry(hass, legacy_patchable_time):
@ -93,7 +93,7 @@ async def test_unload_entry(hass, legacy_patchable_time):
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert entry.state is config_entries.ConfigEntryState.NOT_LOADED
assert islamic_prayer_times.DOMAIN not in hass.data assert islamic_prayer_times.DOMAIN not in hass.data

View file

@ -5,7 +5,7 @@ from aiohttp import ClientConnectorError, ClientResponseError
from homeassistant import config_entries, data_entry_flow, setup from homeassistant import config_entries, data_entry_flow, setup
from homeassistant.components.kmtronic.const import CONF_REVERSE, DOMAIN from homeassistant.components.kmtronic.const import CONF_REVERSE, DOMAIN
from homeassistant.config_entries import ENTRY_STATE_LOADED from homeassistant.config_entries import ConfigEntryState
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -65,7 +65,7 @@ async def test_form_options(hass, aioclient_mock):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_LOADED assert config_entry.state is ConfigEntryState.LOADED
result = await hass.config_entries.options.async_init(config_entry.entry_id) result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -80,7 +80,7 @@ async def test_form_options(hass, aioclient_mock):
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == "loaded" assert config_entry.state == config_entries.ConfigEntryState.LOADED
async def test_form_invalid_auth(hass): async def test_form_invalid_auth(hass):

View file

@ -2,11 +2,7 @@
import asyncio import asyncio
from homeassistant.components.kmtronic.const import DOMAIN from homeassistant.components.kmtronic.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -31,12 +27,12 @@ async def test_unload_config_entry(hass, aioclient_mock):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_LOADED assert config_entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(config_entry.entry_id) await hass.config_entries.async_unload(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_NOT_LOADED assert config_entry.state is ConfigEntryState.NOT_LOADED
async def test_config_entry_not_ready(hass, aioclient_mock): async def test_config_entry_not_ready(hass, aioclient_mock):
@ -59,4 +55,4 @@ async def test_config_entry_not_ready(hass, aioclient_mock):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_SETUP_RETRY assert config_entry.state is ConfigEntryState.SETUP_RETRY

View file

@ -2,7 +2,7 @@
from unittest.mock import patch from unittest.mock import patch
from homeassistant.components.kodi.const import DOMAIN from homeassistant.components.kodi.const import DOMAIN
from homeassistant.config_entries import ENTRY_STATE_LOADED, ENTRY_STATE_NOT_LOADED from homeassistant.config_entries import ConfigEntryState
from . import init_integration from . import init_integration
@ -16,10 +16,10 @@ async def test_unload_entry(hass):
entry = await init_integration(hass) entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)

View file

@ -10,10 +10,7 @@ from homeassistant.components.vacuum import (
SERVICE_START, SERVICE_START,
STATE_DOCKED, STATE_DOCKED,
) )
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_SETUP_ERROR,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import ATTR_ENTITY_ID from homeassistant.const import ATTR_ENTITY_ID
from .common import CONFIG, VACUUM_ENTITY_ID from .common import CONFIG, VACUUM_ENTITY_ID
@ -46,8 +43,8 @@ async def test_unload_entry(hass, mock_account):
@pytest.mark.parametrize( @pytest.mark.parametrize(
"side_effect,expected_state", "side_effect,expected_state",
( (
(LitterRobotLoginException, ENTRY_STATE_SETUP_ERROR), (LitterRobotLoginException, ConfigEntryState.SETUP_ERROR),
(LitterRobotException, ENTRY_STATE_SETUP_RETRY), (LitterRobotException, ConfigEntryState.SETUP_RETRY),
), ),
) )
async def test_entry_not_setup(hass, side_effect, expected_state): async def test_entry_not_setup(hass, side_effect, expected_state):
@ -63,4 +60,4 @@ async def test_entry_not_setup(hass, side_effect, expected_state):
side_effect=side_effect, side_effect=side_effect,
): ):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == expected_state assert entry.state is expected_state

View file

@ -109,7 +109,7 @@ async def test_full_flow(
assert DOMAIN in hass.config.components assert DOMAIN in hass.config.components
entry = hass.config_entries.async_entries(DOMAIN)[0] entry = hass.config_entries.async_entries(DOMAIN)[0]
assert entry.state == config_entries.ENTRY_STATE_LOADED assert entry.state is config_entries.ConfigEntryState.LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert len(mock_setup.mock_calls) == 1 assert len(mock_setup.mock_calls) == 1

View file

@ -6,12 +6,7 @@ from unittest.mock import patch
from pymazda import MazdaAuthenticationException, MazdaException from pymazda import MazdaAuthenticationException, MazdaException
from homeassistant.components.mazda.const import DOMAIN from homeassistant.components.mazda.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_EMAIL, CONF_EMAIL,
CONF_PASSWORD, CONF_PASSWORD,
@ -44,7 +39,7 @@ async def test_config_entry_not_ready(hass: HomeAssistant) -> None:
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_SETUP_RETRY assert config_entry.state is ConfigEntryState.SETUP_RETRY
async def test_init_auth_failure(hass: HomeAssistant): async def test_init_auth_failure(hass: HomeAssistant):
@ -61,7 +56,7 @@ async def test_init_auth_failure(hass: HomeAssistant):
entries = hass.config_entries.async_entries(DOMAIN) entries = hass.config_entries.async_entries(DOMAIN)
assert len(entries) == 1 assert len(entries) == 1
assert entries[0].state == ENTRY_STATE_SETUP_ERROR assert entries[0].state is ConfigEntryState.SETUP_ERROR
flows = hass.config_entries.flow.async_progress() flows = hass.config_entries.flow.async_progress()
assert len(flows) == 1 assert len(flows) == 1
@ -93,7 +88,7 @@ async def test_update_auth_failure(hass: HomeAssistant):
entries = hass.config_entries.async_entries(DOMAIN) entries = hass.config_entries.async_entries(DOMAIN)
assert len(entries) == 1 assert len(entries) == 1
assert entries[0].state == ENTRY_STATE_LOADED assert entries[0].state is ConfigEntryState.LOADED
with patch( with patch(
"homeassistant.components.mazda.MazdaAPI.get_vehicles", "homeassistant.components.mazda.MazdaAPI.get_vehicles",
@ -132,7 +127,7 @@ async def test_update_general_failure(hass: HomeAssistant):
entries = hass.config_entries.async_entries(DOMAIN) entries = hass.config_entries.async_entries(DOMAIN)
assert len(entries) == 1 assert len(entries) == 1
assert entries[0].state == ENTRY_STATE_LOADED assert entries[0].state is ConfigEntryState.LOADED
with patch( with patch(
"homeassistant.components.mazda.MazdaAPI.get_vehicles", "homeassistant.components.mazda.MazdaAPI.get_vehicles",
@ -153,11 +148,11 @@ async def test_unload_config_entry(hass: HomeAssistant) -> None:
entries = hass.config_entries.async_entries(DOMAIN) entries = hass.config_entries.async_entries(DOMAIN)
assert len(entries) == 1 assert len(entries) == 1
assert entries[0].state == ENTRY_STATE_LOADED assert entries[0].state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(entries[0].entry_id) await hass.config_entries.async_unload(entries[0].entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entries[0].state == ENTRY_STATE_NOT_LOADED assert entries[0].state is ConfigEntryState.NOT_LOADED
async def test_device_nickname(hass): async def test_device_nickname(hass):

View file

@ -5,11 +5,7 @@ from homeassistant.components.met.const import (
DOMAIN, DOMAIN,
) )
from homeassistant.config import async_process_ha_core_config from homeassistant.config import async_process_ha_core_config
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
)
from . import init_integration from . import init_integration
@ -19,12 +15,12 @@ async def test_unload_entry(hass):
entry = await init_integration(hass) entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)
@ -41,7 +37,7 @@ async def test_fail_default_home_entry(hass, caplog):
entry = await init_integration(hass, track_home=True) entry = await init_integration(hass, track_home=True)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_SETUP_ERROR assert entry.state is ConfigEntryState.SETUP_ERROR
assert ( assert (
"Skip setting up met.no integration; No Home location has been set" "Skip setting up met.no integration; No Home location has been set"

View file

@ -1,6 +1,6 @@
"""Test the Met Éireann integration init.""" """Test the Met Éireann integration init."""
from homeassistant.components.met_eireann.const import DOMAIN from homeassistant.components.met_eireann.const import DOMAIN
from homeassistant.config_entries import ENTRY_STATE_LOADED, ENTRY_STATE_NOT_LOADED from homeassistant.config_entries import ConfigEntryState
from . import init_integration from . import init_integration
@ -10,10 +10,10 @@ async def test_unload_entry(hass):
entry = await init_integration(hass) entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)

View file

@ -86,7 +86,7 @@ async def test_hub_setup_failed(hass):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
assert config_entry.state == config_entries.ENTRY_STATE_SETUP_RETRY assert config_entry.state is config_entries.ConfigEntryState.SETUP_RETRY
# error when username or password is invalid # error when username or password is invalid
config_entry = MockConfigEntry(domain=mikrotik.DOMAIN, data=MOCK_DATA) config_entry = MockConfigEntry(domain=mikrotik.DOMAIN, data=MOCK_DATA)

View file

@ -4,11 +4,7 @@ from unittest.mock import patch
from nettigo_air_monitor import ApiError from nettigo_air_monitor import ApiError
from homeassistant.components.nam.const import DOMAIN from homeassistant.components.nam.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import STATE_UNAVAILABLE from homeassistant.const import STATE_UNAVAILABLE
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -40,7 +36,7 @@ async def test_config_not_ready(hass):
): ):
entry.add_to_hass(hass) entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_entry(hass): async def test_unload_entry(hass):
@ -48,10 +44,10 @@ async def test_unload_entry(hass):
entry = await init_integration(hass) entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)

View file

@ -152,6 +152,6 @@ async def test_reauth(
assert result3["type"] == data_entry_flow.RESULT_TYPE_ABORT assert result3["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result3["reason"] == "reauth_successful" assert result3["reason"] == "reauth_successful"
assert new_entry.state == "loaded" assert new_entry.state == config_entries.ConfigEntryState.LOADED
assert len(hass.config_entries.async_entries(NEATO_DOMAIN)) == 1 assert len(hass.config_entries.async_entries(NEATO_DOMAIN)) == 1
assert len(mock_setup.mock_calls) == 1 assert len(mock_setup.mock_calls) == 1

View file

@ -11,12 +11,7 @@ from unittest.mock import patch
from google_nest_sdm.exceptions import AuthException, GoogleNestException from google_nest_sdm.exceptions import AuthException, GoogleNestException
from homeassistant.components.nest import DOMAIN from homeassistant.components.nest import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from .common import CONFIG, async_setup_sdm_platform, create_config_entry from .common import CONFIG, async_setup_sdm_platform, create_config_entry
@ -32,7 +27,7 @@ async def test_setup_success(hass, caplog):
entries = hass.config_entries.async_entries(DOMAIN) entries = hass.config_entries.async_entries(DOMAIN)
assert len(entries) == 1 assert len(entries) == 1
assert entries[0].state == ENTRY_STATE_LOADED assert entries[0].state is ConfigEntryState.LOADED
async def async_setup_sdm(hass, config=CONFIG): async def async_setup_sdm(hass, config=CONFIG):
@ -54,7 +49,7 @@ async def test_setup_configuration_failure(hass, caplog):
entries = hass.config_entries.async_entries(DOMAIN) entries = hass.config_entries.async_entries(DOMAIN)
assert len(entries) == 1 assert len(entries) == 1
assert entries[0].state == ENTRY_STATE_SETUP_ERROR assert entries[0].state is ConfigEntryState.SETUP_ERROR
# This error comes from the python google-nest-sdm library, as a check added # This error comes from the python google-nest-sdm library, as a check added
# to prevent common misconfigurations (e.g. confusing topic and subscriber) # to prevent common misconfigurations (e.g. confusing topic and subscriber)
@ -73,7 +68,7 @@ async def test_setup_susbcriber_failure(hass, caplog):
entries = hass.config_entries.async_entries(DOMAIN) entries = hass.config_entries.async_entries(DOMAIN)
assert len(entries) == 1 assert len(entries) == 1
assert entries[0].state == ENTRY_STATE_SETUP_RETRY assert entries[0].state is ConfigEntryState.SETUP_RETRY
async def test_setup_device_manager_failure(hass, caplog): async def test_setup_device_manager_failure(hass, caplog):
@ -89,7 +84,7 @@ async def test_setup_device_manager_failure(hass, caplog):
entries = hass.config_entries.async_entries(DOMAIN) entries = hass.config_entries.async_entries(DOMAIN)
assert len(entries) == 1 assert len(entries) == 1
assert entries[0].state == ENTRY_STATE_SETUP_RETRY assert entries[0].state is ConfigEntryState.SETUP_RETRY
async def test_subscriber_auth_failure(hass, caplog): async def test_subscriber_auth_failure(hass, caplog):
@ -103,7 +98,7 @@ async def test_subscriber_auth_failure(hass, caplog):
entries = hass.config_entries.async_entries(DOMAIN) entries = hass.config_entries.async_entries(DOMAIN)
assert len(entries) == 1 assert len(entries) == 1
assert entries[0].state == ENTRY_STATE_SETUP_ERROR assert entries[0].state is ConfigEntryState.SETUP_ERROR
flows = hass.config_entries.flow.async_progress() flows = hass.config_entries.flow.async_progress()
assert len(flows) == 1 assert len(flows) == 1
@ -121,7 +116,7 @@ async def test_setup_missing_subscriber_id(hass, caplog):
entries = hass.config_entries.async_entries(DOMAIN) entries = hass.config_entries.async_entries(DOMAIN)
assert len(entries) == 1 assert len(entries) == 1
assert entries[0].state == ENTRY_STATE_NOT_LOADED assert entries[0].state is ConfigEntryState.NOT_LOADED
async def test_empty_config(hass, caplog): async def test_empty_config(hass, caplog):

View file

@ -85,7 +85,7 @@ async def test_setup_component(hass):
mock_impl.assert_called_once() mock_impl.assert_called_once()
mock_webhook.assert_called_once() mock_webhook.assert_called_once()
assert config_entry.state == config_entries.ENTRY_STATE_LOADED assert config_entry.state is config_entries.ConfigEntryState.LOADED
assert hass.config_entries.async_entries(DOMAIN) assert hass.config_entries.async_entries(DOMAIN)
assert len(hass.states.async_all()) > 0 assert len(hass.states.async_all()) > 0

View file

@ -4,11 +4,7 @@ from unittest.mock import patch
from aiohttp import ClientError from aiohttp import ClientError
from homeassistant.components.nightscout.const import DOMAIN from homeassistant.components.nightscout.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import CONF_URL from homeassistant.const import CONF_URL
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -20,12 +16,12 @@ async def test_unload_entry(hass):
entry = await init_integration(hass) entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)
@ -42,4 +38,4 @@ async def test_async_setup_raises_entry_not_ready(hass):
side_effect=ClientError(), side_effect=ClientError(),
): ):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
assert config_entry.state == ENTRY_STATE_SETUP_RETRY assert config_entry.state is ConfigEntryState.SETUP_RETRY

View file

@ -4,11 +4,7 @@ from unittest.mock import patch
from pynzbgetapi import NZBGetAPIException from pynzbgetapi import NZBGetAPIException
from homeassistant.components.nzbget.const import DOMAIN from homeassistant.components.nzbget.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -44,12 +40,12 @@ async def test_unload_entry(hass, nzbget_api):
entry = await init_integration(hass) entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)
@ -64,4 +60,4 @@ async def test_async_setup_raises_entry_not_ready(hass):
): ):
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
assert config_entry.state == ENTRY_STATE_SETUP_RETRY assert config_entry.state is ConfigEntryState.SETUP_RETRY

View file

@ -5,12 +5,7 @@ from pyownet.protocol import ConnError, OwnetError
from homeassistant.components.onewire.const import CONF_TYPE_OWSERVER, DOMAIN from homeassistant.components.onewire.const import CONF_TYPE_OWSERVER, DOMAIN
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import SOURCE_USER, ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
SOURCE_USER,
)
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TYPE from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TYPE
from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -48,7 +43,7 @@ async def test_owserver_connect_failure(hass):
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert config_entry_owserver.state == ENTRY_STATE_SETUP_RETRY assert config_entry_owserver.state is ConfigEntryState.SETUP_RETRY
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)
@ -81,15 +76,15 @@ async def test_unload_entry(hass):
config_entry_sysbus = await setup_onewire_sysbus_integration(hass) config_entry_sysbus = await setup_onewire_sysbus_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 2 assert len(hass.config_entries.async_entries(DOMAIN)) == 2
assert config_entry_owserver.state == ENTRY_STATE_LOADED assert config_entry_owserver.state is ConfigEntryState.LOADED
assert config_entry_sysbus.state == ENTRY_STATE_LOADED assert config_entry_sysbus.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(config_entry_owserver.entry_id) assert await hass.config_entries.async_unload(config_entry_owserver.entry_id)
assert await hass.config_entries.async_unload(config_entry_sysbus.entry_id) assert await hass.config_entries.async_unload(config_entry_sysbus.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry_owserver.state == ENTRY_STATE_NOT_LOADED assert config_entry_owserver.state is ConfigEntryState.NOT_LOADED
assert config_entry_sysbus.state == ENTRY_STATE_NOT_LOADED assert config_entry_sysbus.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)

View file

@ -10,7 +10,7 @@ from homeassistant.components.openweathermap.const import (
DEFAULT_LANGUAGE, DEFAULT_LANGUAGE,
DOMAIN, DOMAIN,
) )
from homeassistant.config_entries import SOURCE_USER from homeassistant.config_entries import SOURCE_USER, ConfigEntryState
from homeassistant.const import ( from homeassistant.const import (
CONF_API_KEY, CONF_API_KEY,
CONF_LATITUDE, CONF_LATITUDE,
@ -57,11 +57,11 @@ async def test_form(hass):
conf_entries = hass.config_entries.async_entries(DOMAIN) conf_entries = hass.config_entries.async_entries(DOMAIN)
entry = conf_entries[0] entry = conf_entries[0]
assert entry.state == "loaded" assert entry.state == ConfigEntryState.LOADED
await hass.config_entries.async_unload(conf_entries[0].entry_id) await hass.config_entries.async_unload(conf_entries[0].entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == "not_loaded" assert entry.state == ConfigEntryState.NOT_LOADED
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == CONFIG[CONF_NAME] assert result["title"] == CONFIG[CONF_NAME]
@ -86,7 +86,7 @@ async def test_form_options(hass):
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == "loaded" assert config_entry.state == ConfigEntryState.LOADED
result = await hass.config_entries.options.async_init(config_entry.entry_id) result = await hass.config_entries.options.async_init(config_entry.entry_id)
@ -105,7 +105,7 @@ async def test_form_options(hass):
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == "loaded" assert config_entry.state == ConfigEntryState.LOADED
result = await hass.config_entries.options.async_init(config_entry.entry_id) result = await hass.config_entries.options.async_init(config_entry.entry_id)
@ -124,7 +124,7 @@ async def test_form_options(hass):
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == "loaded" assert config_entry.state == ConfigEntryState.LOADED
async def test_form_invalid_api_key(hass): async def test_form_invalid_api_key(hass):

View file

@ -10,7 +10,9 @@ from tests.common import MockConfigEntry
async def setup_ozw(hass, entry=None, fixture=None): async def setup_ozw(hass, entry=None, fixture=None):
"""Set up OZW and load a dump.""" """Set up OZW and load a dump."""
mqtt_entry = MockConfigEntry(domain="mqtt", state=config_entries.ENTRY_STATE_LOADED) mqtt_entry = MockConfigEntry(
domain="mqtt", state=config_entries.ConfigEntryState.LOADED
)
mqtt_entry.add_to_hass(hass) mqtt_entry.add_to_hass(hass)
if entry is None: if entry is None:

View file

@ -4,7 +4,7 @@ from unittest.mock import patch
import pytest import pytest
from homeassistant.config_entries import ENTRY_STATE_LOADED from homeassistant.config_entries import ConfigEntryState
from .common import MQTTMessage from .common import MQTTMessage
@ -275,6 +275,6 @@ def mock_get_addon_discovery_info():
@pytest.fixture(name="mqtt") @pytest.fixture(name="mqtt")
async def mock_mqtt_fixture(hass): async def mock_mqtt_fixture(hass):
"""Mock the MQTT integration.""" """Mock the MQTT integration."""
mqtt_entry = MockConfigEntry(domain="mqtt", state=ENTRY_STATE_LOADED) mqtt_entry = MockConfigEntry(domain="mqtt", state=ConfigEntryState.LOADED)
mqtt_entry.add_to_hass(hass) mqtt_entry.add_to_hass(hass)
return mqtt_entry return mqtt_entry

View file

@ -65,16 +65,16 @@ async def test_unload_entry(hass, generic_data, switch_msg, caplog):
title="Z-Wave", title="Z-Wave",
) )
entry.add_to_hass(hass) entry.add_to_hass(hass)
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert entry.state is config_entries.ConfigEntryState.NOT_LOADED
receive_message = await setup_ozw(hass, entry=entry, fixture=generic_data) receive_message = await setup_ozw(hass, entry=entry, fixture=generic_data)
assert entry.state == config_entries.ENTRY_STATE_LOADED assert entry.state is config_entries.ConfigEntryState.LOADED
assert len(hass.states.async_entity_ids("switch")) == 1 assert len(hass.states.async_entity_ids("switch")) == 1
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert entry.state is config_entries.ConfigEntryState.NOT_LOADED
entities = hass.states.async_entity_ids("switch") entities = hass.states.async_entity_ids("switch")
assert len(entities) == 1 assert len(entities) == 1
for entity in entities: for entity in entities:
@ -98,7 +98,7 @@ async def test_unload_entry(hass, generic_data, switch_msg, caplog):
await setup_ozw(hass, entry=entry, fixture=generic_data) await setup_ozw(hass, entry=entry, fixture=generic_data)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == config_entries.ENTRY_STATE_LOADED assert entry.state is config_entries.ConfigEntryState.LOADED
assert len(hass.states.async_entity_ids("switch")) == 1 assert len(hass.states.async_entity_ids("switch")) == 1
for record in caplog.records: for record in caplog.records:
assert record.levelname != "ERROR" assert record.levelname != "ERROR"
@ -113,12 +113,12 @@ async def test_remove_entry(hass, stop_addon, uninstall_addon, caplog):
data={"integration_created_addon": False}, data={"integration_created_addon": False},
) )
entry.add_to_hass(hass) entry.add_to_hass(hass)
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert entry.state is config_entries.ConfigEntryState.NOT_LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
await hass.config_entries.async_remove(entry.entry_id) await hass.config_entries.async_remove(entry.entry_id)
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert entry.state is config_entries.ConfigEntryState.NOT_LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 0 assert len(hass.config_entries.async_entries(DOMAIN)) == 0
# test successful remove with created add-on # test successful remove with created add-on
@ -134,7 +134,7 @@ async def test_remove_entry(hass, stop_addon, uninstall_addon, caplog):
assert stop_addon.call_count == 1 assert stop_addon.call_count == 1
assert uninstall_addon.call_count == 1 assert uninstall_addon.call_count == 1
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert entry.state is config_entries.ConfigEntryState.NOT_LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 0 assert len(hass.config_entries.async_entries(DOMAIN)) == 0
stop_addon.reset_mock() stop_addon.reset_mock()
uninstall_addon.reset_mock() uninstall_addon.reset_mock()
@ -148,7 +148,7 @@ async def test_remove_entry(hass, stop_addon, uninstall_addon, caplog):
assert stop_addon.call_count == 1 assert stop_addon.call_count == 1
assert uninstall_addon.call_count == 0 assert uninstall_addon.call_count == 0
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert entry.state is config_entries.ConfigEntryState.NOT_LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 0 assert len(hass.config_entries.async_entries(DOMAIN)) == 0
assert "Failed to stop the OpenZWave add-on" in caplog.text assert "Failed to stop the OpenZWave add-on" in caplog.text
stop_addon.side_effect = None stop_addon.side_effect = None
@ -164,7 +164,7 @@ async def test_remove_entry(hass, stop_addon, uninstall_addon, caplog):
assert stop_addon.call_count == 1 assert stop_addon.call_count == 1
assert uninstall_addon.call_count == 1 assert uninstall_addon.call_count == 1
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert entry.state is config_entries.ConfigEntryState.NOT_LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 0 assert len(hass.config_entries.async_entries(DOMAIN)) == 0
assert "Failed to uninstall the OpenZWave add-on" in caplog.text assert "Failed to uninstall the OpenZWave add-on" in caplog.text
@ -210,7 +210,7 @@ async def test_setup_entry_without_addon_info(hass, get_addon_discovery_info):
assert not await hass.config_entries.async_setup(entry.entry_id) assert not await hass.config_entries.async_setup(entry.entry_id)
assert mock_client.return_value.start_client.call_count == 0 assert mock_client.return_value.start_client.call_count == 0
assert entry.state == config_entries.ENTRY_STATE_SETUP_RETRY assert entry.state is config_entries.ConfigEntryState.SETUP_RETRY
async def test_unload_entry_with_addon( async def test_unload_entry_with_addon(
@ -224,15 +224,15 @@ async def test_unload_entry_with_addon(
) )
entry.add_to_hass(hass) entry.add_to_hass(hass)
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert entry.state is config_entries.ConfigEntryState.NOT_LOADED
with patch("homeassistant.components.ozw.MQTTClient", autospec=True) as mock_client: with patch("homeassistant.components.ozw.MQTTClient", autospec=True) as mock_client:
assert await hass.config_entries.async_setup(entry.entry_id) assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert mock_client.return_value.start_client.call_count == 1 assert mock_client.return_value.start_client.call_count == 1
assert entry.state == config_entries.ENTRY_STATE_LOADED assert entry.state is config_entries.ConfigEntryState.LOADED
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert entry.state is config_entries.ConfigEntryState.NOT_LOADED

View file

@ -7,7 +7,7 @@ from homeassistant.components.panasonic_viera.const import (
DEFAULT_NAME, DEFAULT_NAME,
DOMAIN, DOMAIN,
) )
from homeassistant.config_entries import ENTRY_STATE_NOT_LOADED from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_HOST, STATE_UNAVAILABLE from homeassistant.const import CONF_HOST, STATE_UNAVAILABLE
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -209,7 +209,7 @@ async def test_setup_unload_entry(hass, mock_remote):
await hass.async_block_till_done() await hass.async_block_till_done()
await hass.config_entries.async_unload(mock_entry.entry_id) await hass.config_entries.async_unload(mock_entry.entry_id)
assert mock_entry.state == ENTRY_STATE_NOT_LOADED assert mock_entry.state is ConfigEntryState.NOT_LOADED
state_tv = hass.states.get("media_player.panasonic_viera_tv") state_tv = hass.states.get("media_player.panasonic_viera_tv")
state_remote = hass.states.get("remote.panasonic_viera_tv") state_remote = hass.states.get("remote.panasonic_viera_tv")

View file

@ -23,10 +23,10 @@ from homeassistant.components.plex.const import (
SERVERS, SERVERS,
) )
from homeassistant.config_entries import ( from homeassistant.config_entries import (
ENTRY_STATE_LOADED,
SOURCE_INTEGRATION_DISCOVERY, SOURCE_INTEGRATION_DISCOVERY,
SOURCE_REAUTH, SOURCE_REAUTH,
SOURCE_USER, SOURCE_USER,
ConfigEntryState,
) )
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
@ -354,7 +354,7 @@ async def test_all_available_servers_configured(
async def test_option_flow(hass, entry, mock_plex_server): async def test_option_flow(hass, entry, mock_plex_server):
"""Test config options flow selection.""" """Test config options flow selection."""
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
result = await hass.config_entries.options.async_init( result = await hass.config_entries.options.async_init(
entry.entry_id, context={"source": "test"}, data=None entry.entry_id, context={"source": "test"}, data=None
@ -386,7 +386,7 @@ async def test_option_flow(hass, entry, mock_plex_server):
async def test_missing_option_flow(hass, entry, mock_plex_server): async def test_missing_option_flow(hass, entry, mock_plex_server):
"""Test config options flow selection when no options stored.""" """Test config options flow selection when no options stored."""
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
result = await hass.config_entries.options.async_init( result = await hass.config_entries.options.async_init(
entry.entry_id, context={"source": "test"}, data=None entry.entry_id, context={"source": "test"}, data=None
@ -676,7 +676,7 @@ async def test_setup_with_limited_credentials(hass, entry, setup_plex_server):
assert plex_server.owner is None assert plex_server.owner is None
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
async def test_integration_discovery(hass): async def test_integration_discovery(hass):
@ -707,7 +707,7 @@ async def test_trigger_reauth(
"""Test setup and reauthorization of a Plex token.""" """Test setup and reauthorization of a Plex token."""
await async_setup_component(hass, "persistent_notification", {}) await async_setup_component(hass, "persistent_notification", {})
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
with patch( with patch(
"plexapi.server.PlexServer.clients", side_effect=plexapi.exceptions.Unauthorized "plexapi.server.PlexServer.clients", side_effect=plexapi.exceptions.Unauthorized
@ -716,7 +716,7 @@ async def test_trigger_reauth(
await wait_for_debouncer(hass) await wait_for_debouncer(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state != ENTRY_STATE_LOADED assert entry.state is not ConfigEntryState.LOADED
flows = hass.config_entries.flow.async_progress() flows = hass.config_entries.flow.async_progress()
assert len(flows) == 1 assert len(flows) == 1
@ -741,7 +741,7 @@ async def test_trigger_reauth(
assert len(hass.config_entries.flow.async_progress()) == 0 assert len(hass.config_entries.flow.async_progress()) == 0
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert entry.data[CONF_SERVER] == mock_plex_server.friendly_name assert entry.data[CONF_SERVER] == mock_plex_server.friendly_name
assert entry.data[CONF_SERVER_IDENTIFIER] == mock_plex_server.machine_identifier assert entry.data[CONF_SERVER_IDENTIFIER] == mock_plex_server.machine_identifier
assert entry.data[PLEX_SERVER_CONFIG][CONF_URL] == PLEX_DIRECT_URL assert entry.data[PLEX_SERVER_CONFIG][CONF_URL] == PLEX_DIRECT_URL

View file

@ -13,12 +13,7 @@ from homeassistant.components.plex.models import (
TRANSIENT_SECTION, TRANSIENT_SECTION,
UNKNOWN_SECTION, UNKNOWN_SECTION,
) )
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import ( from homeassistant.const import (
CONF_TOKEN, CONF_TOKEN,
CONF_URL, CONF_URL,
@ -38,7 +33,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
async def test_set_config_entry_unique_id(hass, entry, mock_plex_server): async def test_set_config_entry_unique_id(hass, entry, mock_plex_server):
"""Test updating missing unique_id from config entry.""" """Test updating missing unique_id from config entry."""
assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1 assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert ( assert (
hass.config_entries.async_entries(const.DOMAIN)[0].unique_id hass.config_entries.async_entries(const.DOMAIN)[0].unique_id
@ -57,7 +52,7 @@ async def test_setup_config_entry_with_error(hass, entry):
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1 assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
with patch( with patch(
"homeassistant.components.plex.PlexServer.connect", "homeassistant.components.plex.PlexServer.connect",
@ -68,7 +63,7 @@ async def test_setup_config_entry_with_error(hass, entry):
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1 assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1
assert entry.state == ENTRY_STATE_SETUP_ERROR assert entry.state is ConfigEntryState.SETUP_ERROR
async def test_setup_with_insecure_config_entry(hass, entry, setup_plex_server): async def test_setup_with_insecure_config_entry(hass, entry, setup_plex_server):
@ -80,7 +75,7 @@ async def test_setup_with_insecure_config_entry(hass, entry, setup_plex_server):
await setup_plex_server(config_entry=entry) await setup_plex_server(config_entry=entry)
assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1 assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
async def test_unload_config_entry(hass, entry, mock_plex_server): async def test_unload_config_entry(hass, entry, mock_plex_server):
@ -88,7 +83,7 @@ async def test_unload_config_entry(hass, entry, mock_plex_server):
config_entries = hass.config_entries.async_entries(const.DOMAIN) config_entries = hass.config_entries.async_entries(const.DOMAIN)
assert len(config_entries) == 1 assert len(config_entries) == 1
assert entry is config_entries[0] assert entry is config_entries[0]
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
server_id = mock_plex_server.machine_identifier server_id = mock_plex_server.machine_identifier
loaded_server = hass.data[const.DOMAIN][const.SERVERS][server_id] loaded_server = hass.data[const.DOMAIN][const.SERVERS][server_id]
@ -97,7 +92,7 @@ async def test_unload_config_entry(hass, entry, mock_plex_server):
websocket = hass.data[const.DOMAIN][const.WEBSOCKETS][server_id] websocket = hass.data[const.DOMAIN][const.WEBSOCKETS][server_id]
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
assert websocket.close.called assert websocket.close.called
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
async def test_setup_with_photo_session(hass, entry, setup_plex_server): async def test_setup_with_photo_session(hass, entry, setup_plex_server):
@ -105,7 +100,7 @@ async def test_setup_with_photo_session(hass, entry, setup_plex_server):
await setup_plex_server(session_type="photo") await setup_plex_server(session_type="photo")
assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1 assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.async_block_till_done() await hass.async_block_till_done()
media_player = hass.states.get( media_player = hass.states.get(
@ -124,7 +119,7 @@ async def test_setup_with_live_tv_session(hass, entry, setup_plex_server):
await setup_plex_server(session_type="live_tv") await setup_plex_server(session_type="live_tv")
assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1 assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.async_block_till_done() await hass.async_block_till_done()
media_player = hass.states.get( media_player = hass.states.get(
@ -144,7 +139,7 @@ async def test_setup_with_transient_session(hass, entry, setup_plex_server):
await setup_plex_server(session_type="transient") await setup_plex_server(session_type="transient")
assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1 assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.async_block_till_done() await hass.async_block_till_done()
media_player = hass.states.get( media_player = hass.states.get(
@ -164,7 +159,7 @@ async def test_setup_with_unknown_session(hass, entry, setup_plex_server):
await setup_plex_server(session_type="unknown") await setup_plex_server(session_type="unknown")
assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1 assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.async_block_till_done() await hass.async_block_till_done()
media_player = hass.states.get( media_player = hass.states.get(
@ -226,7 +221,7 @@ async def test_setup_when_certificate_changed(
assert await hass.config_entries.async_setup(old_entry.entry_id) is False assert await hass.config_entries.async_setup(old_entry.entry_id) is False
await hass.async_block_till_done() await hass.async_block_till_done()
assert old_entry.state == ENTRY_STATE_SETUP_ERROR assert old_entry.state is ConfigEntryState.SETUP_ERROR
await hass.config_entries.async_unload(old_entry.entry_id) await hass.config_entries.async_unload(old_entry.entry_id)
# Test with no servers found # Test with no servers found
@ -236,7 +231,7 @@ async def test_setup_when_certificate_changed(
assert await hass.config_entries.async_setup(old_entry.entry_id) is False assert await hass.config_entries.async_setup(old_entry.entry_id) is False
await hass.async_block_till_done() await hass.async_block_till_done()
assert old_entry.state == ENTRY_STATE_SETUP_ERROR assert old_entry.state is ConfigEntryState.SETUP_ERROR
await hass.config_entries.async_unload(old_entry.entry_id) await hass.config_entries.async_unload(old_entry.entry_id)
# Test with success # Test with success
@ -249,7 +244,7 @@ async def test_setup_when_certificate_changed(
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1 assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1
assert old_entry.state == ENTRY_STATE_LOADED assert old_entry.state is ConfigEntryState.LOADED
assert old_entry.data[const.PLEX_SERVER_CONFIG][CONF_URL] == new_url assert old_entry.data[const.PLEX_SERVER_CONFIG][CONF_URL] == new_url
@ -261,7 +256,7 @@ async def test_tokenless_server(entry, setup_plex_server):
entry.data = TOKENLESS_DATA entry.data = TOKENLESS_DATA
await setup_plex_server(config_entry=entry) await setup_plex_server(config_entry=entry)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
async def test_bad_token_with_tokenless_server( async def test_bad_token_with_tokenless_server(
@ -272,7 +267,7 @@ async def test_bad_token_with_tokenless_server(
await setup_plex_server() await setup_plex_server()
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
# Ensure updates that rely on account return nothing # Ensure updates that rely on account return nothing
trigger_plex_update(mock_websocket) trigger_plex_update(mock_websocket)

View file

@ -1,6 +1,6 @@
"""Tests for the Plugwise binary_sensor integration.""" """Tests for the Plugwise binary_sensor integration."""
from homeassistant.config_entries import ENTRY_STATE_LOADED from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.const import STATE_OFF, STATE_ON
from tests.components.plugwise.common import async_init_integration from tests.components.plugwise.common import async_init_integration
@ -9,7 +9,7 @@ from tests.components.plugwise.common import async_init_integration
async def test_anna_climate_binary_sensor_entities(hass, mock_smile_anna): async def test_anna_climate_binary_sensor_entities(hass, mock_smile_anna):
"""Test creation of climate related binary_sensor entities.""" """Test creation of climate related binary_sensor entities."""
entry = await async_init_integration(hass, mock_smile_anna) entry = await async_init_integration(hass, mock_smile_anna)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state = hass.states.get("binary_sensor.auxiliary_slave_boiler_state") state = hass.states.get("binary_sensor.auxiliary_slave_boiler_state")
assert str(state.state) == STATE_OFF assert str(state.state) == STATE_OFF
@ -21,7 +21,7 @@ async def test_anna_climate_binary_sensor_entities(hass, mock_smile_anna):
async def test_anna_climate_binary_sensor_change(hass, mock_smile_anna): async def test_anna_climate_binary_sensor_change(hass, mock_smile_anna):
"""Test change of climate related binary_sensor entities.""" """Test change of climate related binary_sensor entities."""
entry = await async_init_integration(hass, mock_smile_anna) entry = await async_init_integration(hass, mock_smile_anna)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
hass.states.async_set("binary_sensor.auxiliary_dhw_state", STATE_ON, {}) hass.states.async_set("binary_sensor.auxiliary_dhw_state", STATE_ON, {})
await hass.async_block_till_done() await hass.async_block_till_done()
@ -40,7 +40,7 @@ async def test_anna_climate_binary_sensor_change(hass, mock_smile_anna):
async def test_adam_climate_binary_sensor_change(hass, mock_smile_adam): async def test_adam_climate_binary_sensor_change(hass, mock_smile_adam):
"""Test change of climate related binary_sensor entities.""" """Test change of climate related binary_sensor entities."""
entry = await async_init_integration(hass, mock_smile_adam) entry = await async_init_integration(hass, mock_smile_adam)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state = hass.states.get("binary_sensor.adam_plugwise_notification") state = hass.states.get("binary_sensor.adam_plugwise_notification")
assert str(state.state) == STATE_ON assert str(state.state) == STATE_ON

View file

@ -3,7 +3,7 @@
from plugwise.exceptions import PlugwiseException from plugwise.exceptions import PlugwiseException
from homeassistant.components.climate.const import HVAC_MODE_AUTO, HVAC_MODE_HEAT from homeassistant.components.climate.const import HVAC_MODE_AUTO, HVAC_MODE_HEAT
from homeassistant.config_entries import ENTRY_STATE_LOADED from homeassistant.config_entries import ConfigEntryState
from tests.components.plugwise.common import async_init_integration from tests.components.plugwise.common import async_init_integration
@ -11,7 +11,7 @@ from tests.components.plugwise.common import async_init_integration
async def test_adam_climate_entity_attributes(hass, mock_smile_adam): async def test_adam_climate_entity_attributes(hass, mock_smile_adam):
"""Test creation of adam climate device environment.""" """Test creation of adam climate device environment."""
entry = await async_init_integration(hass, mock_smile_adam) entry = await async_init_integration(hass, mock_smile_adam)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state = hass.states.get("climate.zone_lisa_wk") state = hass.states.get("climate.zone_lisa_wk")
attrs = state.attributes attrs = state.attributes
@ -50,7 +50,7 @@ async def test_adam_climate_adjust_negative_testing(hass, mock_smile_adam):
mock_smile_adam.set_schedule_state.side_effect = PlugwiseException mock_smile_adam.set_schedule_state.side_effect = PlugwiseException
mock_smile_adam.set_temperature.side_effect = PlugwiseException mock_smile_adam.set_temperature.side_effect = PlugwiseException
entry = await async_init_integration(hass, mock_smile_adam) entry = await async_init_integration(hass, mock_smile_adam)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.services.async_call( await hass.services.async_call(
"climate", "climate",
@ -85,7 +85,7 @@ async def test_adam_climate_adjust_negative_testing(hass, mock_smile_adam):
async def test_adam_climate_entity_climate_changes(hass, mock_smile_adam): async def test_adam_climate_entity_climate_changes(hass, mock_smile_adam):
"""Test handling of user requests in adam climate device environment.""" """Test handling of user requests in adam climate device environment."""
entry = await async_init_integration(hass, mock_smile_adam) entry = await async_init_integration(hass, mock_smile_adam)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.services.async_call( await hass.services.async_call(
"climate", "climate",
@ -138,7 +138,7 @@ async def test_adam_climate_entity_climate_changes(hass, mock_smile_adam):
async def test_anna_climate_entity_attributes(hass, mock_smile_anna): async def test_anna_climate_entity_attributes(hass, mock_smile_anna):
"""Test creation of anna climate device environment.""" """Test creation of anna climate device environment."""
entry = await async_init_integration(hass, mock_smile_anna) entry = await async_init_integration(hass, mock_smile_anna)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state = hass.states.get("climate.anna") state = hass.states.get("climate.anna")
attrs = state.attributes attrs = state.attributes
@ -163,7 +163,7 @@ async def test_anna_climate_entity_attributes(hass, mock_smile_anna):
async def test_anna_climate_entity_climate_changes(hass, mock_smile_anna): async def test_anna_climate_entity_climate_changes(hass, mock_smile_anna):
"""Test handling of user requests in anna climate device environment.""" """Test handling of user requests in anna climate device environment."""
entry = await async_init_integration(hass, mock_smile_anna) entry = await async_init_integration(hass, mock_smile_anna)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.services.async_call( await hass.services.async_call(
"climate", "climate",

View file

@ -5,11 +5,7 @@ import asyncio
from plugwise.exceptions import XMLDataMissingError from plugwise.exceptions import XMLDataMissingError
from homeassistant.components.plugwise.const import DOMAIN from homeassistant.components.plugwise.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
ENTRY_STATE_SETUP_RETRY,
)
from tests.common import AsyncMock, MockConfigEntry from tests.common import AsyncMock, MockConfigEntry
from tests.components.plugwise.common import async_init_integration from tests.components.plugwise.common import async_init_integration
@ -18,34 +14,34 @@ from tests.components.plugwise.common import async_init_integration
async def test_smile_unauthorized(hass, mock_smile_unauth): async def test_smile_unauthorized(hass, mock_smile_unauth):
"""Test failing unauthorization by Smile.""" """Test failing unauthorization by Smile."""
entry = await async_init_integration(hass, mock_smile_unauth) entry = await async_init_integration(hass, mock_smile_unauth)
assert entry.state == ENTRY_STATE_SETUP_ERROR assert entry.state is ConfigEntryState.SETUP_ERROR
async def test_smile_error(hass, mock_smile_error): async def test_smile_error(hass, mock_smile_error):
"""Test server error handling by Smile.""" """Test server error handling by Smile."""
entry = await async_init_integration(hass, mock_smile_error) entry = await async_init_integration(hass, mock_smile_error)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_smile_notconnect(hass, mock_smile_notconnect): async def test_smile_notconnect(hass, mock_smile_notconnect):
"""Connection failure error handling by Smile.""" """Connection failure error handling by Smile."""
mock_smile_notconnect.connect.return_value = False mock_smile_notconnect.connect.return_value = False
entry = await async_init_integration(hass, mock_smile_notconnect) entry = await async_init_integration(hass, mock_smile_notconnect)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_smile_timeout(hass, mock_smile_notconnect): async def test_smile_timeout(hass, mock_smile_notconnect):
"""Timeout error handling by Smile.""" """Timeout error handling by Smile."""
mock_smile_notconnect.connect.side_effect = asyncio.TimeoutError mock_smile_notconnect.connect.side_effect = asyncio.TimeoutError
entry = await async_init_integration(hass, mock_smile_notconnect) entry = await async_init_integration(hass, mock_smile_notconnect)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_smile_adam_xmlerror(hass, mock_smile_adam): async def test_smile_adam_xmlerror(hass, mock_smile_adam):
"""Detect malformed XML by Smile in Adam environment.""" """Detect malformed XML by Smile in Adam environment."""
mock_smile_adam.full_update_device.side_effect = XMLDataMissingError mock_smile_adam.full_update_device.side_effect = XMLDataMissingError
entry = await async_init_integration(hass, mock_smile_adam) entry = await async_init_integration(hass, mock_smile_adam)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_entry(hass, mock_smile_adam): async def test_unload_entry(hass, mock_smile_adam):
@ -55,7 +51,7 @@ async def test_unload_entry(hass, mock_smile_adam):
mock_smile_adam.async_reset = AsyncMock(return_value=True) mock_smile_adam.async_reset = AsyncMock(return_value=True)
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data[DOMAIN] assert not hass.data[DOMAIN]
@ -66,4 +62,4 @@ async def test_async_setup_entry_fail(hass):
entry.add_to_hass(hass) entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_SETUP_ERROR assert entry.state is ConfigEntryState.SETUP_ERROR

View file

@ -1,6 +1,6 @@
"""Tests for the Plugwise Sensor integration.""" """Tests for the Plugwise Sensor integration."""
from homeassistant.config_entries import ENTRY_STATE_LOADED from homeassistant.config_entries import ConfigEntryState
from tests.common import Mock from tests.common import Mock
from tests.components.plugwise.common import async_init_integration from tests.components.plugwise.common import async_init_integration
@ -9,7 +9,7 @@ from tests.components.plugwise.common import async_init_integration
async def test_adam_climate_sensor_entities(hass, mock_smile_adam): async def test_adam_climate_sensor_entities(hass, mock_smile_adam):
"""Test creation of climate related sensor entities.""" """Test creation of climate related sensor entities."""
entry = await async_init_integration(hass, mock_smile_adam) entry = await async_init_integration(hass, mock_smile_adam)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state = hass.states.get("sensor.adam_outdoor_temperature") state = hass.states.get("sensor.adam_outdoor_temperature")
assert float(state.state) == 7.81 assert float(state.state) == 7.81
@ -34,7 +34,7 @@ async def test_adam_climate_sensor_entities(hass, mock_smile_adam):
async def test_anna_as_smt_climate_sensor_entities(hass, mock_smile_anna): async def test_anna_as_smt_climate_sensor_entities(hass, mock_smile_anna):
"""Test creation of climate related sensor entities.""" """Test creation of climate related sensor entities."""
entry = await async_init_integration(hass, mock_smile_anna) entry = await async_init_integration(hass, mock_smile_anna)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state = hass.states.get("sensor.auxiliary_outdoor_temperature") state = hass.states.get("sensor.auxiliary_outdoor_temperature")
assert float(state.state) == 18.0 assert float(state.state) == 18.0
@ -50,7 +50,7 @@ async def test_anna_climate_sensor_entities(hass, mock_smile_anna):
"""Test creation of climate related sensor entities as single master thermostat.""" """Test creation of climate related sensor entities as single master thermostat."""
mock_smile_anna.single_master_thermostat.side_effect = Mock(return_value=False) mock_smile_anna.single_master_thermostat.side_effect = Mock(return_value=False)
entry = await async_init_integration(hass, mock_smile_anna) entry = await async_init_integration(hass, mock_smile_anna)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state = hass.states.get("sensor.auxiliary_outdoor_temperature") state = hass.states.get("sensor.auxiliary_outdoor_temperature")
assert float(state.state) == 18.0 assert float(state.state) == 18.0
@ -59,7 +59,7 @@ async def test_anna_climate_sensor_entities(hass, mock_smile_anna):
async def test_p1_dsmr_sensor_entities(hass, mock_smile_p1): async def test_p1_dsmr_sensor_entities(hass, mock_smile_p1):
"""Test creation of power related sensor entities.""" """Test creation of power related sensor entities."""
entry = await async_init_integration(hass, mock_smile_p1) entry = await async_init_integration(hass, mock_smile_p1)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state = hass.states.get("sensor.p1_net_electricity_point") state = hass.states.get("sensor.p1_net_electricity_point")
assert float(state.state) == -2761.0 assert float(state.state) == -2761.0
@ -80,7 +80,7 @@ async def test_p1_dsmr_sensor_entities(hass, mock_smile_p1):
async def test_stretch_sensor_entities(hass, mock_stretch): async def test_stretch_sensor_entities(hass, mock_stretch):
"""Test creation of power related sensor entities.""" """Test creation of power related sensor entities."""
entry = await async_init_integration(hass, mock_stretch) entry = await async_init_integration(hass, mock_stretch)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state = hass.states.get("sensor.koelkast_92c4a_electricity_consumed") state = hass.states.get("sensor.koelkast_92c4a_electricity_consumed")
assert float(state.state) == 50.5 assert float(state.state) == 50.5

View file

@ -2,7 +2,7 @@
from plugwise.exceptions import PlugwiseException from plugwise.exceptions import PlugwiseException
from homeassistant.config_entries import ENTRY_STATE_LOADED from homeassistant.config_entries import ConfigEntryState
from tests.components.plugwise.common import async_init_integration from tests.components.plugwise.common import async_init_integration
@ -10,7 +10,7 @@ from tests.components.plugwise.common import async_init_integration
async def test_adam_climate_switch_entities(hass, mock_smile_adam): async def test_adam_climate_switch_entities(hass, mock_smile_adam):
"""Test creation of climate related switch entities.""" """Test creation of climate related switch entities."""
entry = await async_init_integration(hass, mock_smile_adam) entry = await async_init_integration(hass, mock_smile_adam)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state = hass.states.get("switch.cv_pomp") state = hass.states.get("switch.cv_pomp")
assert str(state.state) == "on" assert str(state.state) == "on"
@ -23,7 +23,7 @@ async def test_adam_climate_switch_negative_testing(hass, mock_smile_adam):
"""Test exceptions of climate related switch entities.""" """Test exceptions of climate related switch entities."""
mock_smile_adam.set_relay_state.side_effect = PlugwiseException mock_smile_adam.set_relay_state.side_effect = PlugwiseException
entry = await async_init_integration(hass, mock_smile_adam) entry = await async_init_integration(hass, mock_smile_adam)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.services.async_call( await hass.services.async_call(
"switch", "switch",
@ -47,7 +47,7 @@ async def test_adam_climate_switch_negative_testing(hass, mock_smile_adam):
async def test_adam_climate_switch_changes(hass, mock_smile_adam): async def test_adam_climate_switch_changes(hass, mock_smile_adam):
"""Test changing of climate related switch entities.""" """Test changing of climate related switch entities."""
entry = await async_init_integration(hass, mock_smile_adam) entry = await async_init_integration(hass, mock_smile_adam)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.services.async_call( await hass.services.async_call(
"switch", "switch",
@ -80,7 +80,7 @@ async def test_adam_climate_switch_changes(hass, mock_smile_adam):
async def test_stretch_switch_entities(hass, mock_stretch): async def test_stretch_switch_entities(hass, mock_stretch):
"""Test creation of climate related switch entities.""" """Test creation of climate related switch entities."""
entry = await async_init_integration(hass, mock_stretch) entry = await async_init_integration(hass, mock_stretch)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
state = hass.states.get("switch.koelkast_92c4a") state = hass.states.get("switch.koelkast_92c4a")
assert str(state.state) == "on" assert str(state.state) == "on"
@ -92,7 +92,7 @@ async def test_stretch_switch_entities(hass, mock_stretch):
async def test_stretch_switch_changes(hass, mock_stretch): async def test_stretch_switch_changes(hass, mock_stretch):
"""Test changing of power related switch entities.""" """Test changing of power related switch entities."""
entry = await async_init_integration(hass, mock_stretch) entry = await async_init_integration(hass, mock_stretch)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.services.async_call( await hass.services.async_call(
"switch", "switch",

View file

@ -3,6 +3,7 @@ from unittest.mock import call
import pytest import pytest
from homeassistant import config_entries
from homeassistant.components.rfxtrx import DOMAIN from homeassistant.components.rfxtrx import DOMAIN
from homeassistant.core import State from homeassistant.core import State
@ -168,4 +169,4 @@ async def test_unknown_event_code(hass, rfxtrx):
assert len(conf_entries) == 1 assert len(conf_entries) == 1
entry = conf_entries[0] entry = conf_entries[0]
assert entry.state == "loaded" assert entry.state == config_entries.ConfigEntryState.LOADED

View file

@ -2,11 +2,7 @@
from unittest.mock import patch from unittest.mock import patch
from homeassistant.components.roku.const import DOMAIN from homeassistant.components.roku.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from tests.components.roku import setup_integration from tests.components.roku import setup_integration
@ -19,7 +15,7 @@ async def test_config_entry_not_ready(
"""Test the Roku configuration entry not ready.""" """Test the Roku configuration entry not ready."""
entry = await setup_integration(hass, aioclient_mock, error=True) entry = await setup_integration(hass, aioclient_mock, error=True)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_config_entry( async def test_unload_config_entry(
@ -36,10 +32,10 @@ async def test_unload_config_entry(
entry = await setup_integration(hass, aioclient_mock) entry = await setup_integration(hass, aioclient_mock)
assert hass.data[DOMAIN][entry.entry_id] assert hass.data[DOMAIN][entry.entry_id]
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.entry_id not in hass.data[DOMAIN] assert entry.entry_id not in hass.data[DOMAIN]
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED

View file

@ -14,11 +14,7 @@ from homeassistant.components.ruckus_unleashed import (
DOMAIN, DOMAIN,
MANUFACTURER, MANUFACTURER,
) )
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
@ -56,7 +52,7 @@ async def test_setup_entry_connection_error(hass):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_router_device_setup(hass): async def test_router_device_setup(hass):
@ -84,12 +80,12 @@ async def test_unload_entry(hass):
entry = await init_integration(hass) entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)
@ -113,4 +109,4 @@ async def test_config_not_ready_during_setup(hass):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY

View file

@ -6,12 +6,7 @@ from homeassistant.components.homeassistant import (
SERVICE_UPDATE_ENTITY, SERVICE_UPDATE_ENTITY,
) )
from homeassistant.components.smart_meter_texas.const import DOMAIN from homeassistant.components.smart_meter_texas.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import ATTR_ENTITY_ID from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -31,14 +26,14 @@ async def test_auth_failure(hass, config_entry, aioclient_mock):
"""Test if user's username or password is not accepted.""" """Test if user's username or password is not accepted."""
await setup_integration(hass, config_entry, aioclient_mock, auth_fail=True) await setup_integration(hass, config_entry, aioclient_mock, auth_fail=True)
assert config_entry.state == ENTRY_STATE_SETUP_ERROR assert config_entry.state is ConfigEntryState.SETUP_ERROR
async def test_api_timeout(hass, config_entry, aioclient_mock): async def test_api_timeout(hass, config_entry, aioclient_mock):
"""Test that a timeout results in ConfigEntryNotReady.""" """Test that a timeout results in ConfigEntryNotReady."""
await setup_integration(hass, config_entry, aioclient_mock, auth_timeout=True) await setup_integration(hass, config_entry, aioclient_mock, auth_timeout=True)
assert config_entry.state == ENTRY_STATE_SETUP_RETRY assert config_entry.state is ConfigEntryState.SETUP_RETRY
async def test_update_failure(hass, config_entry, aioclient_mock): async def test_update_failure(hass, config_entry, aioclient_mock):
@ -64,9 +59,9 @@ async def test_unload_config_entry(hass, config_entry, aioclient_mock):
config_entries = hass.config_entries.async_entries(DOMAIN) config_entries = hass.config_entries.async_entries(DOMAIN)
assert len(config_entries) == 1 assert len(config_entries) == 1
assert config_entries[0] is config_entry assert config_entries[0] is config_entry
assert config_entry.state == ENTRY_STATE_LOADED assert config_entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(config_entry.entry_id) await hass.config_entries.async_unload(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_NOT_LOADED assert config_entry.state is ConfigEntryState.NOT_LOADED

View file

@ -7,11 +7,7 @@ from smarttub import LoginFailed
from homeassistant.components import smarttub from homeassistant.components import smarttub
from homeassistant.components.smarttub.const import DOMAIN from homeassistant.components.smarttub.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
ENTRY_STATE_SETUP_ERROR,
ENTRY_STATE_SETUP_RETRY,
SOURCE_REAUTH,
)
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -30,7 +26,7 @@ async def test_setup_entry_not_ready(setup_component, hass, config_entry, smartt
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
assert config_entry.state == ENTRY_STATE_SETUP_RETRY assert config_entry.state is ConfigEntryState.SETUP_RETRY
async def test_setup_auth_failed(setup_component, hass, config_entry, smarttub_api): async def test_setup_auth_failed(setup_component, hass, config_entry, smarttub_api):
@ -40,7 +36,7 @@ async def test_setup_auth_failed(setup_component, hass, config_entry, smarttub_a
config_entry.add_to_hass(hass) config_entry.add_to_hass(hass)
with patch.object(hass.config_entries.flow, "async_init") as mock_flow_init: with patch.object(hass.config_entries.flow, "async_init") as mock_flow_init:
await hass.config_entries.async_setup(config_entry.entry_id) await hass.config_entries.async_setup(config_entry.entry_id)
assert config_entry.state == ENTRY_STATE_SETUP_ERROR assert config_entry.state is ConfigEntryState.SETUP_ERROR
mock_flow_init.assert_called_with( mock_flow_init.assert_called_with(
DOMAIN, DOMAIN,
context={ context={

View file

@ -97,10 +97,10 @@ async def test_full_flow(
assert DOMAIN in hass.config.components assert DOMAIN in hass.config.components
entry = hass.config_entries.async_entries(DOMAIN)[0] entry = hass.config_entries.async_entries(DOMAIN)[0]
assert entry.state == config_entries.ENTRY_STATE_LOADED assert entry.state is config_entries.ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert entry.state is config_entries.ConfigEntryState.NOT_LOADED
async def test_abort_if_authorization_timeout(hass, current_request_with_host): async def test_abort_if_authorization_timeout(hass, current_request_with_host):

View file

@ -2,13 +2,7 @@
from unittest.mock import patch from unittest.mock import patch
from homeassistant.components.sonarr.const import DOMAIN from homeassistant.components.sonarr.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
ENTRY_STATE_SETUP_RETRY,
SOURCE_REAUTH,
)
from homeassistant.const import CONF_SOURCE from homeassistant.const import CONF_SOURCE
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -21,7 +15,7 @@ async def test_config_entry_not_ready(
) -> None: ) -> None:
"""Test the configuration entry not ready.""" """Test the configuration entry not ready."""
entry = await setup_integration(hass, aioclient_mock, connection_error=True) entry = await setup_integration(hass, aioclient_mock, connection_error=True)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_config_entry_reauth( async def test_config_entry_reauth(
@ -31,7 +25,7 @@ async def test_config_entry_reauth(
with patch.object(hass.config_entries.flow, "async_init") as mock_flow_init: with patch.object(hass.config_entries.flow, "async_init") as mock_flow_init:
entry = await setup_integration(hass, aioclient_mock, invalid_auth=True) entry = await setup_integration(hass, aioclient_mock, invalid_auth=True)
assert entry.state == ENTRY_STATE_SETUP_ERROR assert entry.state is ConfigEntryState.SETUP_ERROR
mock_flow_init.assert_called_once_with( mock_flow_init.assert_called_once_with(
DOMAIN, DOMAIN,
@ -56,10 +50,10 @@ async def test_unload_config_entry(
assert hass.data[DOMAIN] assert hass.data[DOMAIN]
assert entry.entry_id in hass.data[DOMAIN] assert entry.entry_id in hass.data[DOMAIN]
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.entry_id not in hass.data[DOMAIN] assert entry.entry_id not in hass.data[DOMAIN]
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED

View file

@ -38,7 +38,7 @@ async def test_successful_config_entry(hass):
) as forward_entry_setup: ) as forward_entry_setup:
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == config_entries.ENTRY_STATE_LOADED assert entry.state is config_entries.ConfigEntryState.LOADED
assert forward_entry_setup.mock_calls[0][1] == ( assert forward_entry_setup.mock_calls[0][1] == (
entry, entry,
"sensor", "sensor",
@ -58,7 +58,7 @@ async def test_setup_failed(hass):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == config_entries.ENTRY_STATE_SETUP_RETRY assert entry.state is config_entries.ConfigEntryState.SETUP_RETRY
async def test_unload_entry(hass): async def test_unload_entry(hass):
@ -75,5 +75,5 @@ async def test_unload_entry(hass):
assert await hass.config_entries.async_unload(entry.entry_id) assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED assert entry.state is config_entries.ConfigEntryState.NOT_LOADED
assert speedtestdotnet.DOMAIN not in hass.data assert speedtestdotnet.DOMAIN not in hass.data

View file

@ -1,4 +1,5 @@
"""Tests for Srp Energy component Init.""" """Tests for Srp Energy component Init."""
from homeassistant import config_entries
from homeassistant.components import srp_energy from homeassistant.components import srp_energy
from tests.components.srp_energy import init_integration from tests.components.srp_energy import init_integration
@ -7,7 +8,7 @@ from tests.components.srp_energy import init_integration
async def test_setup_entry(hass): async def test_setup_entry(hass):
"""Test setup entry fails if deCONZ is not available.""" """Test setup entry fails if deCONZ is not available."""
config_entry = await init_integration(hass) config_entry = await init_integration(hass)
assert config_entry.state == "loaded" assert config_entry.state == config_entries.ConfigEntryState.LOADED
assert hass.data[srp_energy.SRP_ENERGY_DOMAIN] assert hass.data[srp_energy.SRP_ENERGY_DOMAIN]

View file

@ -18,7 +18,7 @@ from homeassistant.components.subaru.const import (
VEHICLE_HAS_SAFETY_SERVICE, VEHICLE_HAS_SAFETY_SERVICE,
VEHICLE_NAME, VEHICLE_NAME,
) )
from homeassistant.config_entries import ENTRY_STATE_LOADED from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_DEVICE_ID, CONF_PASSWORD, CONF_PIN, CONF_USERNAME from homeassistant.const import CONF_DEVICE_ID, CONF_PASSWORD, CONF_PIN, CONF_USERNAME
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
@ -144,5 +144,5 @@ async def ev_entry(hass):
assert DOMAIN in hass.config_entries.async_domains() assert DOMAIN in hass.config_entries.async_domains()
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert hass.config_entries.async_get_entry(entry.entry_id) assert hass.config_entries.async_get_entry(entry.entry_id)
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
return entry return entry

View file

@ -8,12 +8,7 @@ from homeassistant.components.homeassistant import (
SERVICE_UPDATE_ENTITY, SERVICE_UPDATE_ENTITY,
) )
from homeassistant.components.subaru.const import DOMAIN from homeassistant.components.subaru.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_ERROR,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import ATTR_ENTITY_ID from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -44,7 +39,7 @@ async def test_setup_ev(hass, ev_entry):
"""Test setup with an EV vehicle.""" """Test setup with an EV vehicle."""
check_entry = hass.config_entries.async_get_entry(ev_entry.entry_id) check_entry = hass.config_entries.async_get_entry(ev_entry.entry_id)
assert check_entry assert check_entry
assert check_entry.state == ENTRY_STATE_LOADED assert check_entry.state is ConfigEntryState.LOADED
async def test_setup_g2(hass): async def test_setup_g2(hass):
@ -57,7 +52,7 @@ async def test_setup_g2(hass):
) )
check_entry = hass.config_entries.async_get_entry(entry.entry_id) check_entry = hass.config_entries.async_get_entry(entry.entry_id)
assert check_entry assert check_entry
assert check_entry.state == ENTRY_STATE_LOADED assert check_entry.state is ConfigEntryState.LOADED
async def test_setup_g1(hass): async def test_setup_g1(hass):
@ -67,7 +62,7 @@ async def test_setup_g1(hass):
) )
check_entry = hass.config_entries.async_get_entry(entry.entry_id) check_entry = hass.config_entries.async_get_entry(entry.entry_id)
assert check_entry assert check_entry
assert check_entry.state == ENTRY_STATE_LOADED assert check_entry.state is ConfigEntryState.LOADED
async def test_unsuccessful_connect(hass): async def test_unsuccessful_connect(hass):
@ -81,7 +76,7 @@ async def test_unsuccessful_connect(hass):
) )
check_entry = hass.config_entries.async_get_entry(entry.entry_id) check_entry = hass.config_entries.async_get_entry(entry.entry_id)
assert check_entry assert check_entry
assert check_entry.state == ENTRY_STATE_SETUP_RETRY assert check_entry.state is ConfigEntryState.SETUP_RETRY
async def test_invalid_credentials(hass): async def test_invalid_credentials(hass):
@ -95,7 +90,7 @@ async def test_invalid_credentials(hass):
) )
check_entry = hass.config_entries.async_get_entry(entry.entry_id) check_entry = hass.config_entries.async_get_entry(entry.entry_id)
assert check_entry assert check_entry
assert check_entry.state == ENTRY_STATE_SETUP_ERROR assert check_entry.state is ConfigEntryState.SETUP_ERROR
async def test_update_skip_unsubscribed(hass): async def test_update_skip_unsubscribed(hass):
@ -147,7 +142,7 @@ async def test_fetch_failed(hass):
async def test_unload_entry(hass, ev_entry): async def test_unload_entry(hass, ev_entry):
"""Test that entry is unloaded.""" """Test that entry is unloaded."""
assert ev_entry.state == ENTRY_STATE_LOADED assert ev_entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(ev_entry.entry_id) assert await hass.config_entries.async_unload(ev_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert ev_entry.state == ENTRY_STATE_NOT_LOADED assert ev_entry.state is ConfigEntryState.NOT_LOADED

View file

@ -2,7 +2,7 @@
from unittest.mock import patch from unittest.mock import patch
from homeassistant.components.totalconnect.const import DOMAIN from homeassistant.components.totalconnect.const import DOMAIN
from homeassistant.config_entries import ENTRY_STATE_SETUP_ERROR from homeassistant.config_entries import ConfigEntryState
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from .common import CONFIG_DATA from .common import CONFIG_DATA
@ -26,4 +26,4 @@ async def test_reauth_started(hass):
assert await async_setup_component(hass, DOMAIN, {}) assert await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert mock_entry.state == ENTRY_STATE_SETUP_ERROR assert mock_entry.state is ConfigEntryState.SETUP_ERROR

View file

@ -11,7 +11,7 @@ from homeassistant.components.vera import (
CONF_LIGHTS, CONF_LIGHTS,
DOMAIN, DOMAIN,
) )
from homeassistant.config_entries import ENTRY_STATE_NOT_LOADED from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
@ -148,7 +148,7 @@ async def test_unload(
for config_entry in entries: for config_entry in entries:
assert await hass.config_entries.async_unload(config_entry.entry_id) assert await hass.config_entries.async_unload(config_entry.entry_id)
assert config_entry.state == ENTRY_STATE_NOT_LOADED assert config_entry.state is ConfigEntryState.NOT_LOADED
async def test_async_setup_entry_error( async def test_async_setup_entry_error(

View file

@ -242,7 +242,7 @@ async def test_discovery_updates_unique_id(hass):
"name": "dummy", "name": "dummy",
"id": TEST_DISCOVERY_RESULT["id"], "id": TEST_DISCOVERY_RESULT["id"],
}, },
state=config_entries.ENTRY_STATE_SETUP_RETRY, state=config_entries.ConfigEntryState.SETUP_RETRY,
) )
entry.add_to_hass(hass) entry.add_to_hass(hass)

View file

@ -5,11 +5,7 @@ import pytest
import pywilight import pywilight
from pywilight.const import DOMAIN from pywilight.const import DOMAIN
from homeassistant.config_entries import ( from homeassistant.config_entries import ConfigEntryState
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from tests.components.wilight import ( from tests.components.wilight import (
@ -47,7 +43,7 @@ async def test_config_entry_not_ready(hass: HomeAssistant) -> None:
"""Test the WiLight configuration entry not ready.""" """Test the WiLight configuration entry not ready."""
entry = await setup_integration(hass) entry = await setup_integration(hass)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_config_entry(hass: HomeAssistant, dummy_device_from_host) -> None: async def test_unload_config_entry(hass: HomeAssistant, dummy_device_from_host) -> None:
@ -55,11 +51,11 @@ async def test_unload_config_entry(hass: HomeAssistant, dummy_device_from_host)
entry = await setup_integration(hass) entry = await setup_integration(hass)
assert entry.entry_id in hass.data[DOMAIN] assert entry.entry_id in hass.data[DOMAIN]
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
if DOMAIN in hass.data: if DOMAIN in hass.data:
assert entry.entry_id not in hass.data[DOMAIN] assert entry.entry_id not in hass.data[DOMAIN]
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED

View file

@ -4,7 +4,7 @@ from unittest.mock import MagicMock, patch
from wled import WLEDConnectionError from wled import WLEDConnectionError
from homeassistant.components.wled.const import DOMAIN from homeassistant.components.wled.const import DOMAIN
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from tests.components.wled import init_integration from tests.components.wled import init_integration
@ -17,7 +17,7 @@ async def test_config_entry_not_ready(
) -> None: ) -> None:
"""Test the WLED configuration entry not ready.""" """Test the WLED configuration entry not ready."""
entry = await init_integration(hass, aioclient_mock) entry = await init_integration(hass, aioclient_mock)
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_unload_config_entry( async def test_unload_config_entry(

View file

@ -11,7 +11,7 @@ from homeassistant.components.yeelight import (
DOMAIN, DOMAIN,
NIGHTLIGHT_SWITCH_TYPE_LIGHT, NIGHTLIGHT_SWITCH_TYPE_LIGHT,
) )
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import ( from homeassistant.const import (
CONF_DEVICES, CONF_DEVICES,
CONF_HOST, CONF_HOST,
@ -110,7 +110,7 @@ async def test_ip_changes_id_missing_cannot_fallback(hass: HomeAssistant):
assert not await hass.config_entries.async_setup(config_entry.entry_id) assert not await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ENTRY_STATE_SETUP_RETRY assert config_entry.state is ConfigEntryState.SETUP_RETRY
async def test_setup_discovery(hass: HomeAssistant): async def test_setup_discovery(hass: HomeAssistant):

View file

@ -9,12 +9,7 @@ from zwave_js_server.model.node import Node
from homeassistant.components.hassio.handler import HassioAPIError from homeassistant.components.hassio.handler import HassioAPIError
from homeassistant.components.zwave_js.const import DOMAIN from homeassistant.components.zwave_js.const import DOMAIN
from homeassistant.components.zwave_js.helpers import get_device_id from homeassistant.components.zwave_js.helpers import get_device_id
from homeassistant.config_entries import ( from homeassistant.config_entries import DISABLED_USER, ConfigEntryState
DISABLED_USER,
ENTRY_STATE_LOADED,
ENTRY_STATE_NOT_LOADED,
ENTRY_STATE_SETUP_RETRY,
)
from homeassistant.const import STATE_UNAVAILABLE from homeassistant.const import STATE_UNAVAILABLE
from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers import device_registry as dr, entity_registry as er
@ -39,12 +34,12 @@ async def test_entry_setup_unload(hass, client, integration):
entry = integration entry = integration
assert client.connect.call_count == 1 assert client.connect.call_count == 1
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(entry.entry_id) await hass.config_entries.async_unload(entry.entry_id)
assert client.disconnect.call_count == 1 assert client.disconnect.call_count == 1
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
async def test_home_assistant_stop(hass, client, integration): async def test_home_assistant_stop(hass, client, integration):
@ -62,7 +57,7 @@ async def test_initialized_timeout(hass, client, connect_timeout):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_enabled_statistics(hass, client): async def test_enabled_statistics(hass, client):
@ -130,7 +125,7 @@ async def test_listen_failure(hass, client, error):
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_on_node_added_ready( async def test_on_node_added_ready(
@ -590,7 +585,7 @@ async def test_start_addon(
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
assert install_addon.call_count == 0 assert install_addon.call_count == 0
assert set_addon_options.call_count == 1 assert set_addon_options.call_count == 1
assert set_addon_options.call_args == call( assert set_addon_options.call_args == call(
@ -621,7 +616,7 @@ async def test_install_addon(
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
assert install_addon.call_count == 1 assert install_addon.call_count == 1
assert install_addon.call_args == call(hass, "core_zwave_js") assert install_addon.call_args == call(hass, "core_zwave_js")
assert set_addon_options.call_count == 1 assert set_addon_options.call_count == 1
@ -654,7 +649,7 @@ async def test_addon_info_failure(
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
assert install_addon.call_count == 0 assert install_addon.call_count == 0
assert start_addon.call_count == 0 assert start_addon.call_count == 0
@ -708,7 +703,7 @@ async def test_update_addon(
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
assert create_shapshot.call_count == snapshot_calls assert create_shapshot.call_count == snapshot_calls
assert update_addon.call_count == update_calls assert update_addon.call_count == update_calls
@ -716,8 +711,8 @@ async def test_update_addon(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"stop_addon_side_effect, entry_state", "stop_addon_side_effect, entry_state",
[ [
(None, ENTRY_STATE_NOT_LOADED), (None, ConfigEntryState.NOT_LOADED),
(HassioAPIError("Boom"), ENTRY_STATE_LOADED), (HassioAPIError("Boom"), ConfigEntryState.LOADED),
], ],
) )
async def test_stop_addon( async def test_stop_addon(
@ -749,7 +744,7 @@ async def test_stop_addon(
await hass.config_entries.async_setup(entry.entry_id) await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry.state == ENTRY_STATE_LOADED assert entry.state is ConfigEntryState.LOADED
await hass.config_entries.async_set_disabled_by(entry.entry_id, DISABLED_USER) await hass.config_entries.async_set_disabled_by(entry.entry_id, DISABLED_USER)
await hass.async_block_till_done() await hass.async_block_till_done()
@ -770,12 +765,12 @@ async def test_remove_entry(
data={"integration_created_addon": False}, data={"integration_created_addon": False},
) )
entry.add_to_hass(hass) entry.add_to_hass(hass)
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
await hass.config_entries.async_remove(entry.entry_id) await hass.config_entries.async_remove(entry.entry_id)
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 0 assert len(hass.config_entries.async_entries(DOMAIN)) == 0
# test successful remove with created add-on # test successful remove with created add-on
@ -799,7 +794,7 @@ async def test_remove_entry(
) )
assert uninstall_addon.call_count == 1 assert uninstall_addon.call_count == 1
assert uninstall_addon.call_args == call(hass, "core_zwave_js") assert uninstall_addon.call_args == call(hass, "core_zwave_js")
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 0 assert len(hass.config_entries.async_entries(DOMAIN)) == 0
stop_addon.reset_mock() stop_addon.reset_mock()
create_shapshot.reset_mock() create_shapshot.reset_mock()
@ -816,7 +811,7 @@ async def test_remove_entry(
assert stop_addon.call_args == call(hass, "core_zwave_js") assert stop_addon.call_args == call(hass, "core_zwave_js")
assert create_shapshot.call_count == 0 assert create_shapshot.call_count == 0
assert uninstall_addon.call_count == 0 assert uninstall_addon.call_count == 0
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 0 assert len(hass.config_entries.async_entries(DOMAIN)) == 0
assert "Failed to stop the Z-Wave JS add-on" in caplog.text assert "Failed to stop the Z-Wave JS add-on" in caplog.text
stop_addon.side_effect = None stop_addon.side_effect = None
@ -840,7 +835,7 @@ async def test_remove_entry(
partial=True, partial=True,
) )
assert uninstall_addon.call_count == 0 assert uninstall_addon.call_count == 0
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 0 assert len(hass.config_entries.async_entries(DOMAIN)) == 0
assert "Failed to create a snapshot of the Z-Wave JS add-on" in caplog.text assert "Failed to create a snapshot of the Z-Wave JS add-on" in caplog.text
create_shapshot.side_effect = None create_shapshot.side_effect = None
@ -865,7 +860,7 @@ async def test_remove_entry(
) )
assert uninstall_addon.call_count == 1 assert uninstall_addon.call_count == 1
assert uninstall_addon.call_args == call(hass, "core_zwave_js") assert uninstall_addon.call_args == call(hass, "core_zwave_js")
assert entry.state == ENTRY_STATE_NOT_LOADED assert entry.state is ConfigEntryState.NOT_LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 0 assert len(hass.config_entries.async_entries(DOMAIN)) == 0
assert "Failed to uninstall the Z-Wave JS add-on" in caplog.text assert "Failed to uninstall the Z-Wave JS add-on" in caplog.text

Some files were not shown because too many files have changed in this diff Show more