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:
parent
0e7409e617
commit
19d25cd901
101 changed files with 557 additions and 688 deletions
|
@ -385,7 +385,7 @@ def entry_json(entry: config_entries.ConfigEntry) -> dict:
|
|||
"domain": entry.domain,
|
||||
"title": entry.title,
|
||||
"source": entry.source,
|
||||
"state": entry.state,
|
||||
"state": entry.state.value,
|
||||
"supports_options": supports_options,
|
||||
"supports_unload": entry.supports_unload,
|
||||
"disabled_by": entry.disabled_by,
|
||||
|
|
|
@ -149,8 +149,8 @@ class DSMRFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
and reload_on_update
|
||||
and entry.state
|
||||
in (
|
||||
config_entries.ENTRY_STATE_LOADED,
|
||||
config_entries.ENTRY_STATE_SETUP_RETRY,
|
||||
config_entries.ConfigEntryState.LOADED,
|
||||
config_entries.ConfigEntryState.SETUP_RETRY,
|
||||
)
|
||||
):
|
||||
self.hass.async_create_task(
|
||||
|
|
|
@ -22,7 +22,7 @@ from openzwavemqtt.util.mqtt_client import MQTTClient
|
|||
|
||||
from homeassistant.components import mqtt
|
||||
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.core import HomeAssistant, callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
@ -92,7 +92,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): # noqa: C
|
|||
|
||||
else:
|
||||
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")
|
||||
return False
|
||||
|
||||
|
@ -100,7 +100,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): # noqa: C
|
|||
|
||||
@callback
|
||||
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")
|
||||
return
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ class DomainConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
mqtt_entries = self.hass.config_entries.async_entries("mqtt")
|
||||
if (
|
||||
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_create_entry_from_vars()
|
||||
|
|
|
@ -14,7 +14,7 @@ from plexwebsocket import (
|
|||
import requests.exceptions
|
||||
|
||||
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.core import callback
|
||||
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}
|
||||
)
|
||||
except requests.exceptions.ConnectionError as error:
|
||||
if entry.state != ENTRY_STATE_SETUP_RETRY:
|
||||
if entry.state is not ConfigEntryState.SETUP_RETRY:
|
||||
_LOGGER.error(
|
||||
"Plex server (%s) could not be reached: [%s]",
|
||||
server_config[CONF_URL],
|
||||
|
|
|
@ -144,7 +144,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||
async def async_step_init(self, user_input=None):
|
||||
"""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")
|
||||
return self.async_abort(reason="cannot_connect")
|
||||
|
||||
|
|
|
@ -245,7 +245,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
|
|||
async def async_step_init(self, user_input=None):
|
||||
"""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")
|
||||
return self.async_abort(reason=RESULT_CONN_ERROR)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from pyvizio.util import gen_apps_list_from_url
|
|||
import voluptuous as vol
|
||||
|
||||
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.helpers import config_validation as cv
|
||||
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
|
||||
if not any(
|
||||
entry.state == ENTRY_STATE_LOADED
|
||||
entry.state is ConfigEntryState.LOADED
|
||||
and entry.entry_id != config_entry.entry_id
|
||||
and entry.data[CONF_DEVICE_CLASS] == DEVICE_CLASS_TV
|
||||
for entry in hass.config_entries.async_entries(DOMAIN)
|
||||
|
|
|
@ -25,7 +25,7 @@ from homeassistant.components.websocket_api.const import (
|
|||
ERR_NOT_SUPPORTED,
|
||||
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.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
|
@ -85,7 +85,7 @@ def async_get_entry(orig_func: Callable) -> Callable:
|
|||
)
|
||||
return
|
||||
|
||||
if entry.state != ENTRY_STATE_LOADED:
|
||||
if entry.state is not ConfigEntryState.LOADED:
|
||||
connection.send_error(
|
||||
msg[ID], ERR_NOT_LOADED, f"Config entry {entry_id} not loaded"
|
||||
)
|
||||
|
|
|
@ -4,6 +4,7 @@ from __future__ import annotations
|
|||
import asyncio
|
||||
from collections.abc import Iterable, Mapping
|
||||
from contextvars import ContextVar
|
||||
from enum import Enum
|
||||
import functools
|
||||
import logging
|
||||
from types import MappingProxyType, MethodType
|
||||
|
@ -63,20 +64,37 @@ PATH_CONFIG = ".config_entries.json"
|
|||
|
||||
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"
|
||||
DISCOVERY_NOTIFICATION_ID = "config_entry_discovery"
|
||||
|
@ -156,7 +174,7 @@ class ConfigEntry:
|
|||
options: Mapping[str, Any] | None = None,
|
||||
unique_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,
|
||||
) -> None:
|
||||
"""Initialize a config entry."""
|
||||
|
@ -237,7 +255,7 @@ class ConfigEntry:
|
|||
err,
|
||||
)
|
||||
if self.domain == integration.domain:
|
||||
self.state = ENTRY_STATE_SETUP_ERROR
|
||||
self.state = ConfigEntryState.SETUP_ERROR
|
||||
self.reason = "Import error"
|
||||
return
|
||||
|
||||
|
@ -251,13 +269,13 @@ class ConfigEntry:
|
|||
self.domain,
|
||||
err,
|
||||
)
|
||||
self.state = ENTRY_STATE_SETUP_ERROR
|
||||
self.state = ConfigEntryState.SETUP_ERROR
|
||||
self.reason = "Import error"
|
||||
return
|
||||
|
||||
# Perform migration
|
||||
if not await self.async_migrate(hass):
|
||||
self.state = ENTRY_STATE_MIGRATION_ERROR
|
||||
self.state = ConfigEntryState.MIGRATION_ERROR
|
||||
self.reason = None
|
||||
return
|
||||
|
||||
|
@ -288,7 +306,7 @@ class ConfigEntry:
|
|||
self.async_start_reauth(hass)
|
||||
result = False
|
||||
except ConfigEntryNotReady as ex:
|
||||
self.state = ENTRY_STATE_SETUP_RETRY
|
||||
self.state = ConfigEntryState.SETUP_RETRY
|
||||
self.reason = str(ex) or None
|
||||
wait_time = 2 ** min(tries, 4) * 5
|
||||
tries += 1
|
||||
|
@ -337,10 +355,10 @@ class ConfigEntry:
|
|||
return
|
||||
|
||||
if result:
|
||||
self.state = ENTRY_STATE_LOADED
|
||||
self.state = ConfigEntryState.LOADED
|
||||
self.reason = None
|
||||
else:
|
||||
self.state = ENTRY_STATE_SETUP_ERROR
|
||||
self.state = ConfigEntryState.SETUP_ERROR
|
||||
self.reason = error_reason
|
||||
|
||||
async def async_shutdown(self) -> None:
|
||||
|
@ -362,7 +380,7 @@ class ConfigEntry:
|
|||
Returns if unload is possible and was successful.
|
||||
"""
|
||||
if self.source == SOURCE_IGNORE:
|
||||
self.state = ENTRY_STATE_NOT_LOADED
|
||||
self.state = ConfigEntryState.NOT_LOADED
|
||||
self.reason = None
|
||||
return True
|
||||
|
||||
|
@ -374,20 +392,20 @@ class ConfigEntry:
|
|||
# that was uninstalled, or an integration
|
||||
# that has been renamed without removing the config
|
||||
# entry.
|
||||
self.state = ENTRY_STATE_NOT_LOADED
|
||||
self.state = ConfigEntryState.NOT_LOADED
|
||||
self.reason = None
|
||||
return True
|
||||
|
||||
component = integration.get_component()
|
||||
|
||||
if integration.domain == self.domain:
|
||||
if self.state in UNRECOVERABLE_STATES:
|
||||
if not self.state.recoverable:
|
||||
return False
|
||||
|
||||
if self.state != ENTRY_STATE_LOADED:
|
||||
if self.state is not ConfigEntryState.LOADED:
|
||||
self.async_cancel_retry_setup()
|
||||
|
||||
self.state = ENTRY_STATE_NOT_LOADED
|
||||
self.state = ConfigEntryState.NOT_LOADED
|
||||
self.reason = None
|
||||
return True
|
||||
|
||||
|
@ -395,7 +413,7 @@ class ConfigEntry:
|
|||
|
||||
if not supports_unload:
|
||||
if integration.domain == self.domain:
|
||||
self.state = ENTRY_STATE_FAILED_UNLOAD
|
||||
self.state = ConfigEntryState.FAILED_UNLOAD
|
||||
self.reason = "Unload not supported"
|
||||
return False
|
||||
|
||||
|
@ -406,7 +424,7 @@ class ConfigEntry:
|
|||
|
||||
# Only adjust state if we unloaded the component
|
||||
if result and integration.domain == self.domain:
|
||||
self.state = ENTRY_STATE_NOT_LOADED
|
||||
self.state = ConfigEntryState.NOT_LOADED
|
||||
self.reason = None
|
||||
|
||||
self._async_process_on_unload()
|
||||
|
@ -417,7 +435,7 @@ class ConfigEntry:
|
|||
"Error unloading entry %s for %s", self.title, integration.domain
|
||||
)
|
||||
if integration.domain == self.domain:
|
||||
self.state = ENTRY_STATE_FAILED_UNLOAD
|
||||
self.state = ConfigEntryState.FAILED_UNLOAD
|
||||
self.reason = "Unknown error"
|
||||
return False
|
||||
|
||||
|
@ -620,10 +638,7 @@ class ConfigEntriesFlowManager(data_entry_flow.FlowManager):
|
|||
# Unload the entry before setting up the new one.
|
||||
# We will remove it only after the other one is set up,
|
||||
# so that device customizations are not getting lost.
|
||||
if (
|
||||
existing_entry is not None
|
||||
and existing_entry.state not in UNRECOVERABLE_STATES
|
||||
):
|
||||
if existing_entry is not None and existing_entry.state.recoverable:
|
||||
await self.config_entries.async_unload(existing_entry.entry_id)
|
||||
|
||||
entry = ConfigEntry(
|
||||
|
@ -770,8 +785,8 @@ class ConfigEntries:
|
|||
if entry is None:
|
||||
raise UnknownEntry
|
||||
|
||||
if entry.state in UNRECOVERABLE_STATES:
|
||||
unload_success = entry.state != ENTRY_STATE_FAILED_UNLOAD
|
||||
if not entry.state.recoverable:
|
||||
unload_success = entry.state is not ConfigEntryState.FAILED_UNLOAD
|
||||
else:
|
||||
unload_success = await self.async_unload(entry_id)
|
||||
|
||||
|
@ -855,7 +870,7 @@ class ConfigEntries:
|
|||
if entry is None:
|
||||
raise UnknownEntry
|
||||
|
||||
if entry.state != ENTRY_STATE_NOT_LOADED:
|
||||
if entry.state is not ConfigEntryState.NOT_LOADED:
|
||||
raise OperationNotAllowed
|
||||
|
||||
# Setup Component if not set up yet
|
||||
|
@ -870,7 +885,7 @@ class ConfigEntries:
|
|||
if not 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:
|
||||
"""Unload a config entry."""
|
||||
|
@ -879,7 +894,7 @@ class ConfigEntries:
|
|||
if entry is None:
|
||||
raise UnknownEntry
|
||||
|
||||
if entry.state in UNRECOVERABLE_STATES:
|
||||
if not entry.state.recoverable:
|
||||
raise OperationNotAllowed
|
||||
|
||||
return await entry.async_unload(self.hass)
|
||||
|
@ -1115,7 +1130,8 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
|||
if (
|
||||
changed
|
||||
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.config_entries.async_reload(entry.entry_id)
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.abode import (
|
|||
SERVICE_TRIGGER_AUTOMATION,
|
||||
)
|
||||
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 .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):
|
||||
"""Config entry state is ENTRY_STATE_SETUP_RETRY when abode is offline."""
|
||||
"""Config entry state is SETUP_RETRY when abode is offline."""
|
||||
with patch(
|
||||
"homeassistant.components.abode.Abode",
|
||||
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)
|
||||
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() == []
|
||||
|
|
|
@ -6,11 +6,7 @@ from unittest.mock import patch
|
|||
from accuweather import ApiError
|
||||
|
||||
from homeassistant.components.accuweather.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
|
@ -48,7 +44,7 @@ async def test_config_not_ready(hass):
|
|||
):
|
||||
entry.add_to_hass(hass)
|
||||
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):
|
||||
|
@ -56,12 +52,12 @@ async def test_unload_entry(hass):
|
|||
entry = await init_integration(hass)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
|
||||
|
@ -69,7 +65,7 @@ async def test_update_interval(hass):
|
|||
"""Test correct update interval."""
|
||||
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"))
|
||||
future = utcnow() + timedelta(minutes=40)
|
||||
|
@ -91,7 +87,7 @@ async def test_update_interval_forecast(hass):
|
|||
"""Test correct update interval when forecast is 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"))
|
||||
forecast = json.loads(load_fixture("accuweather/forecast_data.json"))
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
"""Test the Advantage Air Initialization."""
|
||||
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
|
||||
from tests.components.advantage_air import (
|
||||
TEST_SYSTEM_DATA,
|
||||
|
@ -22,11 +18,11 @@ async def test_async_setup_entry(hass, aioclient_mock):
|
|||
)
|
||||
|
||||
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)
|
||||
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):
|
||||
|
@ -38,4 +34,4 @@ async def test_async_setup_entry_failure(hass, aioclient_mock):
|
|||
)
|
||||
|
||||
entry = await add_mock_config(hass)
|
||||
assert entry.state == ENTRY_STATE_SETUP_RETRY
|
||||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
|
|
@ -6,7 +6,7 @@ import requests_mock
|
|||
|
||||
from homeassistant import data_entry_flow
|
||||
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
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
|
@ -47,7 +47,7 @@ async def test_form(hass):
|
|||
|
||||
conf_entries = hass.config_entries.async_entries(DOMAIN)
|
||||
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["title"] == CONFIG[CONF_NAME]
|
||||
|
@ -75,7 +75,7 @@ async def test_form_options(hass):
|
|||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
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)
|
||||
|
||||
|
@ -93,7 +93,7 @@ async def test_form_options(hass):
|
|||
|
||||
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)
|
||||
|
||||
|
@ -111,7 +111,7 @@ async def test_form_options(hass):
|
|||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entry.state == "loaded"
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
|
||||
|
||||
async def test_form_duplicated_id(hass):
|
||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
|||
import requests_mock
|
||||
|
||||
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
|
||||
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)
|
||||
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.async_block_till_done()
|
||||
assert config_entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert config_entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -5,11 +5,7 @@ import pytest
|
|||
|
||||
from homeassistant.components.airly import set_update_interval
|
||||
from homeassistant.components.airly.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
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())
|
||||
entry.add_to_hass(hass)
|
||||
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):
|
||||
|
@ -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"))
|
||||
entry.add_to_hass(hass)
|
||||
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"
|
||||
|
||||
|
||||
|
@ -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"))
|
||||
entry.add_to_hass(hass)
|
||||
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):
|
||||
|
@ -127,7 +123,7 @@ async def test_update_interval(hass, aioclient_mock):
|
|||
|
||||
assert aioclient_mock.call_count == 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)
|
||||
future = utcnow() + update_interval
|
||||
|
@ -164,7 +160,7 @@ async def test_update_interval(hass, aioclient_mock):
|
|||
|
||||
assert aioclient_mock.call_count == 3
|
||||
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)
|
||||
future = utcnow() + update_interval
|
||||
|
@ -181,12 +177,12 @@ async def test_unload_entry(hass, aioclient_mock):
|
|||
entry = await init_integration(hass, aioclient_mock)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ async def test_set_up_oauth_remote_url(hass, aioclient_mock):
|
|||
):
|
||||
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")
|
||||
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:
|
||||
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
|
||||
|
||||
|
||||
|
@ -90,7 +90,7 @@ async def test_set_up_hassio(hass, aioclient_mock):
|
|||
with patch("pyalmond.WebAlmondAPI.async_create_device") as mock_create_device:
|
||||
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
|
||||
|
||||
|
||||
|
@ -112,5 +112,5 @@ async def test_set_up_local(hass, aioclient_mock):
|
|||
with patch("pyalmond.WebAlmondAPI.async_create_device") as mock_create_device:
|
||||
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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Tests for the ATAG integration."""
|
||||
|
||||
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 . import init_integration, mock_connection
|
||||
|
@ -15,7 +15,7 @@ async def test_config_entry_not_ready(
|
|||
"""Test configuration entry not ready on library error."""
|
||||
mock_connection(aioclient_mock, conn_error=True)
|
||||
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(
|
||||
|
|
|
@ -9,11 +9,7 @@ from yalexs.exceptions import AugustApiAIOHTTPError
|
|||
from homeassistant import setup
|
||||
from homeassistant.components.august.const import DOMAIN
|
||||
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
SERVICE_LOCK,
|
||||
|
@ -36,7 +32,7 @@ from tests.components.august.mocks import (
|
|||
|
||||
|
||||
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(
|
||||
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.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):
|
||||
|
@ -141,7 +137,7 @@ async def test_lock_has_doorsense(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(
|
||||
domain=DOMAIN,
|
||||
|
@ -159,7 +155,7 @@ async def test_auth_fails(hass):
|
|||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
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()
|
||||
|
||||
|
@ -167,7 +163,7 @@ async def test_auth_fails(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(
|
||||
domain=DOMAIN,
|
||||
|
@ -187,7 +183,7 @@ async def test_bad_password(hass):
|
|||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
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()
|
||||
|
||||
|
@ -195,7 +191,7 @@ async def test_bad_password(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(
|
||||
domain=DOMAIN,
|
||||
|
@ -213,13 +209,13 @@ async def test_http_failure(hass):
|
|||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
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() == []
|
||||
|
||||
|
||||
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(
|
||||
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.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()
|
||||
|
||||
|
@ -245,7 +241,7 @@ async def test_unknown_auth_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(
|
||||
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.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 hass.config_entries.flow.async_progress()[0]["context"]["source"] == "reauth"
|
||||
|
||||
|
||||
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(
|
||||
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.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()
|
||||
|
||||
|
@ -306,7 +302,7 @@ async def test_load_unload(hass):
|
|||
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.async_block_till_done()
|
||||
|
|
|
@ -173,7 +173,7 @@ async def test_async_setup_entry(hass, valid_feature_mock):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
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):
|
||||
|
@ -189,4 +189,4 @@ async def test_async_remove_entry(hass, valid_feature_mock):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.config_entries.async_entries() == []
|
||||
assert config.state == config_entries.ENTRY_STATE_NOT_LOADED
|
||||
assert config.state is config_entries.ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -5,7 +5,7 @@ import logging
|
|||
import blebox_uniapi
|
||||
|
||||
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
|
||||
|
||||
|
@ -23,7 +23,7 @@ async def test_setup_failure(hass, caplog):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
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):
|
||||
|
@ -39,7 +39,7 @@ async def test_setup_failure_on_connection(hass, caplog):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
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):
|
||||
|
@ -57,4 +57,4 @@ async def test_unload_config_entry(hass):
|
|||
await hass.async_block_till_done()
|
||||
assert not hass.data.get(DOMAIN)
|
||||
|
||||
assert entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -5,11 +5,7 @@ from aiohttp import ClientConnectionError, ClientResponseError
|
|||
from bond_api import DeviceType
|
||||
|
||||
from homeassistant.components.bond.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
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()):
|
||||
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):
|
||||
|
@ -75,7 +71,7 @@ async def test_async_setup_entry_sets_up_hub_and_supported_domains(hass: HomeAss
|
|||
await hass.async_block_till_done()
|
||||
|
||||
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"
|
||||
|
||||
# verify hub device is registered correctly
|
||||
|
@ -115,7 +111,7 @@ async def test_unload_config_entry(hass: HomeAssistant):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
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):
|
||||
|
@ -159,7 +155,7 @@ async def test_old_identifiers_are_removed(hass: HomeAssistant):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
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"
|
||||
|
||||
# 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()
|
||||
|
||||
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"
|
||||
|
||||
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()
|
||||
|
||||
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"
|
||||
|
||||
device_registry = dr.async_get(hass)
|
||||
|
|
|
@ -5,12 +5,7 @@ import broadlink.exceptions as blke
|
|||
|
||||
from homeassistant.components.broadlink.const import DOMAIN
|
||||
from homeassistant.components.broadlink.device import get_domains
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.helpers.entity_registry import async_entries_for_device
|
||||
|
||||
from . import get_device
|
||||
|
@ -29,7 +24,7 @@ async def test_device_setup(hass):
|
|||
) as mock_init:
|
||||
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.get_fwversion.call_count == 1
|
||||
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:
|
||||
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_forward.call_count == 0
|
||||
assert mock_init.call_count == 1
|
||||
|
@ -76,7 +71,7 @@ async def test_device_setup_network_timeout(hass):
|
|||
) as mock_init:
|
||||
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_forward.call_count == 0
|
||||
assert mock_init.call_count == 0
|
||||
|
@ -95,7 +90,7 @@ async def test_device_setup_os_error(hass):
|
|||
) as mock_init:
|
||||
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_forward.call_count == 0
|
||||
assert mock_init.call_count == 0
|
||||
|
@ -114,7 +109,7 @@ async def test_device_setup_broadlink_exception(hass):
|
|||
) as mock_init:
|
||||
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_forward.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:
|
||||
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.check_sensors.call_count == 1
|
||||
assert mock_forward.call_count == 0
|
||||
|
@ -156,7 +151,7 @@ async def test_device_setup_update_authorization_error(hass):
|
|||
) as mock_init:
|
||||
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.check_sensors.call_count == 2
|
||||
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:
|
||||
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.check_sensors.call_count == 1
|
||||
assert mock_forward.call_count == 0
|
||||
|
@ -205,7 +200,7 @@ async def test_device_setup_update_broadlink_exception(hass):
|
|||
) as mock_init:
|
||||
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.check_sensors.call_count == 1
|
||||
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:
|
||||
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}
|
||||
domains = get_domains(mock_api.type)
|
||||
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:
|
||||
_, 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}
|
||||
domains = get_domains(mock_api.type)
|
||||
assert mock_forward.call_count == len(domains)
|
||||
|
@ -279,7 +274,7 @@ async def test_device_unload_works(hass):
|
|||
) as mock_forward:
|
||||
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}
|
||||
domains = get_domains(mock_api.type)
|
||||
assert mock_forward.call_count == len(domains)
|
||||
|
@ -302,7 +297,7 @@ async def test_device_unload_authentication_error(hass):
|
|||
) as mock_forward:
|
||||
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
|
||||
|
||||
|
||||
|
@ -320,7 +315,7 @@ async def test_device_unload_update_failed(hass):
|
|||
) as mock_forward:
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.brother.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_HOST, CONF_TYPE, STATE_UNAVAILABLE
|
||||
|
||||
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()):
|
||||
entry.add_to_hass(hass)
|
||||
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):
|
||||
|
@ -43,10 +39,10 @@ async def test_unload_entry(hass):
|
|||
entry = await init_integration(hass)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import aiohttp
|
||||
|
||||
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 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)
|
||||
assert entry.state == ENTRY_STATE_SETUP_RETRY
|
||||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
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)
|
||||
assert entry.state == ENTRY_STATE_SETUP_RETRY
|
||||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
|
|
@ -3,6 +3,7 @@ from unittest.mock import patch
|
|||
|
||||
from homeassistant import setup
|
||||
from homeassistant.components.buienradar.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
|
||||
from homeassistant.helpers.entity_registry import async_get_registry
|
||||
|
||||
|
@ -39,7 +40,7 @@ async def test_import_all(hass):
|
|||
|
||||
entry = conf_entries[0]
|
||||
|
||||
assert entry.state == "loaded"
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
assert entry.data == {
|
||||
"latitude": hass.config.latitude,
|
||||
"longitude": hass.config.longitude,
|
||||
|
@ -77,7 +78,7 @@ async def test_import_camera(hass):
|
|||
|
||||
entry = conf_entries[0]
|
||||
|
||||
assert entry.state == "loaded"
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
assert entry.data == {
|
||||
"latitude": hass.config.latitude,
|
||||
"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.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.async_block_till_done()
|
||||
|
||||
assert entry.state == "not_loaded"
|
||||
assert entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -5,11 +5,7 @@ from requests import ConnectTimeout
|
|||
|
||||
from homeassistant.components.camera.const import DOMAIN as CAMERA_DOMAIN
|
||||
from homeassistant.components.canary.const import CONF_FFMPEG_ARGUMENTS, DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_TIMEOUT, CONF_USERNAME
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
@ -64,12 +60,12 @@ async def test_unload_entry(hass, canary):
|
|||
|
||||
assert entry
|
||||
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)
|
||||
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)
|
||||
|
||||
|
||||
|
@ -79,4 +75,4 @@ async def test_async_setup_raises_entry_not_ready(hass, canary):
|
|||
|
||||
entry = await init_integration(hass)
|
||||
assert entry
|
||||
assert entry.state == ENTRY_STATE_SETUP_RETRY
|
||||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
|||
|
||||
from homeassistant.components.cert_expiry.const import 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 (
|
||||
CONF_HOST,
|
||||
CONF_PORT,
|
||||
|
@ -63,7 +63,7 @@ async def test_update_unique_id(hass):
|
|||
assert await async_setup_component(hass, DOMAIN, {}) is True
|
||||
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}"
|
||||
|
||||
|
||||
|
@ -89,7 +89,7 @@ async def test_unload_config_entry(mock_now, hass):
|
|||
assert await async_setup_component(hass, DOMAIN, {}) is True
|
||||
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")
|
||||
assert state.state == timestamp.isoformat()
|
||||
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)
|
||||
|
||||
assert entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert entry.state is ConfigEntryState.NOT_LOADED
|
||||
state = hass.states.get("sensor.cert_expiry_timestamp_example_com")
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import ssl
|
|||
from unittest.mock import patch
|
||||
|
||||
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.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
|
||||
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)
|
||||
async_fire_time_changed(hass, next_update)
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
from pycfdns.exceptions import CloudflareConnectionException
|
||||
|
||||
from homeassistant.components.cloudflare.const import DOMAIN, SERVICE_UPDATE_RECORDS
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
|
||||
from . import ENTRY_CONFIG, init_integration
|
||||
|
||||
|
@ -18,12 +14,12 @@ async def test_unload_entry(hass, cfupdate):
|
|||
entry = await init_integration(hass)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
|
||||
|
@ -37,7 +33,7 @@ async def test_async_setup_raises_entry_not_ready(hass, cfupdate):
|
|||
instance.get_zone_id.side_effect = CloudflareConnectionException()
|
||||
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):
|
||||
|
@ -45,7 +41,7 @@ async def test_integration_services(hass, cfupdate):
|
|||
instance = cfupdate.return_value
|
||||
|
||||
entry = await init_integration(hass)
|
||||
assert entry.state == ENTRY_STATE_LOADED
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
|
|
|
@ -64,7 +64,7 @@ async def test_get_entries(hass, client):
|
|||
domain="comp2",
|
||||
title="Test 2",
|
||||
source="bla2",
|
||||
state=core_ce.ENTRY_STATE_SETUP_ERROR,
|
||||
state=core_ce.ConfigEntryState.SETUP_ERROR,
|
||||
reason="Unsupported API",
|
||||
).add_to_hass(hass)
|
||||
MockConfigEntry(
|
||||
|
@ -84,7 +84,7 @@ async def test_get_entries(hass, client):
|
|||
"domain": "comp1",
|
||||
"title": "Test 1",
|
||||
"source": "bla",
|
||||
"state": "not_loaded",
|
||||
"state": core_ce.ConfigEntryState.NOT_LOADED.value,
|
||||
"supports_options": True,
|
||||
"supports_unload": True,
|
||||
"disabled_by": None,
|
||||
|
@ -94,7 +94,7 @@ async def test_get_entries(hass, client):
|
|||
"domain": "comp2",
|
||||
"title": "Test 2",
|
||||
"source": "bla2",
|
||||
"state": "setup_error",
|
||||
"state": core_ce.ConfigEntryState.SETUP_ERROR.value,
|
||||
"supports_options": False,
|
||||
"supports_unload": False,
|
||||
"disabled_by": None,
|
||||
|
@ -104,7 +104,7 @@ async def test_get_entries(hass, client):
|
|||
"domain": "comp3",
|
||||
"title": "Test 3",
|
||||
"source": "bla3",
|
||||
"state": "not_loaded",
|
||||
"state": core_ce.ConfigEntryState.NOT_LOADED.value,
|
||||
"supports_options": False,
|
||||
"supports_unload": False,
|
||||
"disabled_by": core_ce.DISABLED_USER,
|
||||
|
@ -115,7 +115,7 @@ async def test_get_entries(hass, client):
|
|||
|
||||
async def test_remove_entry(hass, client):
|
||||
"""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)
|
||||
resp = await client.delete(f"/api/config/config_entries/entry/{entry.entry_id}")
|
||||
assert resp.status == 200
|
||||
|
@ -126,7 +126,7 @@ async def test_remove_entry(hass, client):
|
|||
|
||||
async def test_reload_entry(hass, client):
|
||||
"""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)
|
||||
resp = await client.post(
|
||||
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):
|
||||
"""Test removing an entry via the API."""
|
||||
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)
|
||||
resp = await client.delete(f"/api/config/config_entries/entry/{entry.entry_id}")
|
||||
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):
|
||||
"""Test reloading an entry via the API."""
|
||||
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)
|
||||
resp = await client.post(
|
||||
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):
|
||||
"""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)
|
||||
resp = await client.post(
|
||||
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",
|
||||
"entry_id": entries[0].entry_id,
|
||||
"source": core_ce.SOURCE_USER,
|
||||
"state": "loaded",
|
||||
"state": core_ce.ConfigEntryState.LOADED.value,
|
||||
"supports_options": False,
|
||||
"supports_unload": False,
|
||||
"title": "Test Entry",
|
||||
|
@ -396,7 +396,7 @@ async def test_two_step_flow(hass, client, enable_custom_integrations):
|
|||
"domain": "test",
|
||||
"entry_id": entries[0].entry_id,
|
||||
"source": core_ce.SOURCE_USER,
|
||||
"state": "loaded",
|
||||
"state": core_ce.ConfigEntryState.LOADED.value,
|
||||
"supports_options": False,
|
||||
"supports_unload": False,
|
||||
"title": "user-title",
|
||||
|
@ -788,7 +788,7 @@ async def test_disable_entry(hass, hass_ws_client):
|
|||
assert await async_setup_component(hass, "config", {})
|
||||
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)
|
||||
assert entry.disabled_by is None
|
||||
|
||||
|
@ -806,7 +806,7 @@ async def test_disable_entry(hass, hass_ws_client):
|
|||
assert response["success"]
|
||||
assert response["result"] == {"require_restart": True}
|
||||
assert entry.disabled_by == core_ce.DISABLED_USER
|
||||
assert entry.state == "failed_unload"
|
||||
assert entry.state is core_ce.ConfigEntryState.FAILED_UNLOAD
|
||||
|
||||
# Enable
|
||||
await ws_client.send_json(
|
||||
|
@ -822,7 +822,7 @@ async def test_disable_entry(hass, hass_ws_client):
|
|||
assert response["success"]
|
||||
assert response["result"] == {"require_restart": True}
|
||||
assert entry.disabled_by is None
|
||||
assert entry.state == "failed_unload"
|
||||
assert entry.state == core_ce.ConfigEntryState.FAILED_UNLOAD
|
||||
|
||||
# Enable again -> no op
|
||||
await ws_client.send_json(
|
||||
|
@ -838,7 +838,7 @@ async def test_disable_entry(hass, hass_ws_client):
|
|||
assert response["success"]
|
||||
assert response["result"] == {"require_restart": False}
|
||||
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):
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import MagicMock, patch
|
|||
from aiohttp import ClientError
|
||||
|
||||
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.helpers import entity_registry as er
|
||||
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, {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entry.state == ENTRY_STATE_SETUP_RETRY
|
||||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
|
|
@ -4,12 +4,7 @@ from unittest.mock import patch
|
|||
from devolo_home_control_api.exceptions.gateway import GatewayOfflineError
|
||||
import pytest
|
||||
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.components.devolo_home_control import configure_integration
|
||||
|
@ -20,7 +15,7 @@ async def test_setup_entry(hass: HomeAssistant):
|
|||
entry = configure_integration(hass)
|
||||
with patch("homeassistant.components.devolo_home_control.HomeControl"):
|
||||
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
|
||||
|
@ -28,7 +23,7 @@ async def test_setup_entry_credentials_invalid(hass: HomeAssistant):
|
|||
"""Test setup entry fails if credentials are invalid."""
|
||||
entry = configure_integration(hass)
|
||||
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
|
||||
|
@ -36,7 +31,7 @@ async def test_setup_entry_maintenance(hass: HomeAssistant):
|
|||
"""Test setup entry fails if mydevolo is in maintenance mode."""
|
||||
entry = configure_integration(hass)
|
||||
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):
|
||||
|
@ -47,7 +42,7 @@ async def test_setup_gateway_offline(hass: HomeAssistant):
|
|||
side_effect=GatewayOfflineError,
|
||||
):
|
||||
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):
|
||||
|
@ -57,4 +52,4 @@ async def test_unload_entry(hass: HomeAssistant):
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
assert entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
|||
from pydexcom import AccountError, SessionError
|
||||
|
||||
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.components.dexcom import CONFIG, init_integration
|
||||
|
@ -55,10 +55,10 @@ async def test_unload_entry(hass):
|
|||
entry = await init_integration(hass)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
"""Tests for the DirecTV integration."""
|
||||
from homeassistant.components.directv.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
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."""
|
||||
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(
|
||||
|
@ -29,10 +25,10 @@ async def test_unload_config_entry(
|
|||
entry = await setup_integration(hass, aioclient_mock)
|
||||
|
||||
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.async_block_till_done()
|
||||
|
||||
assert entry.entry_id not in hass.data[DOMAIN]
|
||||
assert entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -11,6 +11,7 @@ from decimal import Decimal
|
|||
from itertools import chain, repeat
|
||||
from unittest.mock import DEFAULT, MagicMock
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.dsmr.const import DOMAIN
|
||||
from homeassistant.components.dsmr.sensor import DerivativeDSMREntity
|
||||
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]
|
||||
|
||||
assert entry.state == "loaded"
|
||||
assert entry.state == config_entries.ConfigEntryState.LOADED
|
||||
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)
|
||||
|
||||
assert mock_entry.state == "not_loaded"
|
||||
assert mock_entry.state == config_entries.ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -13,9 +13,9 @@ from tests.common import MockConfigEntry
|
|||
@pytest.mark.parametrize(
|
||||
"first_con, second_con,exp_type, exp_result, exp_reason",
|
||||
[
|
||||
(True, True, "create_entry", "loaded", ""),
|
||||
(False, False, "abort", "", "no_connection"),
|
||||
(True, False, "create_entry", "setup_retry", ""),
|
||||
(True, True, "create_entry", config_entries.ConfigEntryState.LOADED, ""),
|
||||
(False, False, "abort", None, "no_connection"),
|
||||
(True, False, "create_entry", config_entries.ConfigEntryState.SETUP_RETRY, ""),
|
||||
],
|
||||
)
|
||||
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},
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["result"].state == "loaded"
|
||||
assert result["result"].state == config_entries.ConfigEntryState.LOADED
|
||||
|
|
|
@ -35,7 +35,7 @@ async def async_setup_test_fixture(hass, mock_get_station, initial_value):
|
|||
entry.add_to_hass(hass)
|
||||
|
||||
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()
|
||||
|
||||
async def poll(value):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import aiohttp
|
||||
|
||||
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 tests.components.elgato import init_integration
|
||||
|
@ -18,7 +18,7 @@ async def test_config_entry_not_ready(
|
|||
)
|
||||
|
||||
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(
|
||||
|
|
|
@ -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.sensor import DOMAIN as SENSOR_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.core import HomeAssistant
|
||||
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
|
||||
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)
|
||||
assert state_dt
|
||||
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)
|
||||
|
||||
assert entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert entry.state is ConfigEntryState.NOT_LOADED
|
||||
state_dt = hass.states.get(entity_id_dt)
|
||||
assert state_dt.state == STATE_UNAVAILABLE
|
||||
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()
|
||||
|
||||
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)
|
||||
assert state_dt is None
|
||||
state_sensor = hass.states.get(entity_id_sensor)
|
||||
|
|
|
@ -8,11 +8,7 @@ from requests.exceptions import HTTPError
|
|||
|
||||
from homeassistant.components.fritzbox.const import DOMAIN as FB_DOMAIN
|
||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICES,
|
||||
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)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entry.state == ENTRY_STATE_LOADED
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
state = hass.states.get(entity_id)
|
||||
assert state
|
||||
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
|
||||
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)
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
|
@ -109,13 +105,13 @@ async def test_unload_remove(hass: HomeAssistant, fritz: Mock):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
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)
|
||||
assert state is None
|
||||
|
||||
|
||||
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(
|
||||
domain=FB_DOMAIN,
|
||||
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()
|
||||
config_entry = entries[0]
|
||||
assert config_entry.state == ENTRY_STATE_SETUP_ERROR
|
||||
assert config_entry.state is ConfigEntryState.SETUP_ERROR
|
||||
|
|
|
@ -3,11 +3,7 @@ import json
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.gios.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
|
||||
from . import STATIONS
|
||||
|
@ -41,7 +37,7 @@ async def test_config_not_ready(hass):
|
|||
):
|
||||
entry.add_to_hass(hass)
|
||||
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):
|
||||
|
@ -49,12 +45,12 @@ async def test_unload_entry(hass):
|
|||
entry = await init_integration(hass)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from unittest.mock import patch
|
||||
|
||||
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 tests.common import MockConfigEntry
|
||||
|
@ -25,7 +25,7 @@ async def test_setup_simple(hass):
|
|||
|
||||
assert len(climate_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
|
||||
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.async_block_till_done()
|
||||
|
||||
assert entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -36,7 +36,7 @@ async def test_loading(hass, mock_config_entry):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
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):
|
||||
|
@ -44,7 +44,7 @@ async def test_loading_with_no_config(hass, mock_config_entry):
|
|||
mock_config_entry.add_to_hass(hass)
|
||||
await setup.async_setup_component(hass, DOMAIN, {})
|
||||
# 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):
|
||||
|
@ -68,8 +68,8 @@ async def test_unloading(hass, mock_config_entry):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
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
|
||||
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
|
||||
|
|
|
@ -388,7 +388,7 @@ async def test_initial_api_error(
|
|||
assert len(mock_check.mock_calls) == 1
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
# 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
|
||||
entity_assertions(
|
||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.components.climate.const import (
|
|||
SUPPORT_TARGET_TEMPERATURE,
|
||||
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 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
|
||||
# failing then we have to fail the config entry setup.
|
||||
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")
|
||||
assert climate is None
|
||||
|
|
|
@ -18,7 +18,7 @@ from homeassistant.components.homematicip_cloud.hap import (
|
|||
HomematicipAuth,
|
||||
HomematicipHAP,
|
||||
)
|
||||
from homeassistant.config_entries import ENTRY_STATE_NOT_LOADED
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
||||
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
|
||||
await hass.config_entries.async_unload(config_entries[0].entry_id)
|
||||
# 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] == {}
|
||||
|
||||
|
||||
|
|
|
@ -13,12 +13,7 @@ from homeassistant.components.homematicip_cloud.const import (
|
|||
HMIPC_NAME,
|
||||
)
|
||||
from homeassistant.components.homematicip_cloud.hap import HomematicipHAP
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_NAME
|
||||
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 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):
|
||||
|
@ -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 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):
|
||||
|
@ -157,9 +152,9 @@ async def test_unload_entry(hass):
|
|||
assert hass.data[HMIPC_DOMAIN]["ABC123"]
|
||||
config_entries = hass.config_entries.async_entries(HMIPC_DOMAIN)
|
||||
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)
|
||||
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"
|
||||
# entry is unloaded
|
||||
assert hass.data[HMIPC_DOMAIN] == {}
|
||||
|
|
|
@ -4,11 +4,7 @@ from unittest.mock import patch
|
|||
from huisbaasje import HuisbaasjeException
|
||||
|
||||
from homeassistant.components import huisbaasje
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME, STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -49,12 +45,12 @@ async def test_setup_entry(hass: HomeAssistant):
|
|||
)
|
||||
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)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# 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.data
|
||||
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)
|
||||
|
||||
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.async_block_till_done()
|
||||
|
||||
# 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 entities are not loaded
|
||||
|
@ -133,13 +129,13 @@ async def test_unload_entry(hass: HomeAssistant):
|
|||
# Load config entry
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
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")
|
||||
assert len(entities) == 14
|
||||
|
||||
# Unload config entry
|
||||
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")
|
||||
assert len(entities) == 14
|
||||
for entity in entities:
|
||||
|
|
|
@ -25,10 +25,10 @@ from homeassistant.components.light import (
|
|||
DOMAIN as LIGHT_DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
RELOAD_AFTER_UPDATE_DELAY,
|
||||
SOURCE_REAUTH,
|
||||
ConfigEntry,
|
||||
ConfigEntryState,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
|
@ -900,7 +900,7 @@ async def test_setup_entry_no_token_reauth(hass: HomeAssistant) -> None:
|
|||
},
|
||||
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:
|
||||
|
@ -928,7 +928,7 @@ async def test_setup_entry_bad_token_reauth(hass: HomeAssistant) -> None:
|
|||
},
|
||||
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(
|
||||
|
|
|
@ -5,11 +5,7 @@ from uuid import uuid4
|
|||
import pytest
|
||||
|
||||
from homeassistant.components.ialarm.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
@ -41,7 +37,7 @@ async def test_setup_entry(hass, ialarm_api, mock_config_entry):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
ialarm_api.return_value.get_mac.assert_called_once()
|
||||
assert mock_config_entry.state == ENTRY_STATE_LOADED
|
||||
assert mock_config_entry.state is ConfigEntryState.LOADED
|
||||
|
||||
|
||||
async def test_setup_not_ready(hass, ialarm_api, mock_config_entry):
|
||||
|
@ -51,7 +47,7 @@ async def test_setup_not_ready(hass, ialarm_api, mock_config_entry):
|
|||
mock_config_entry.add_to_hass(hass)
|
||||
assert not await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert mock_config_entry.state == ENTRY_STATE_SETUP_RETRY
|
||||
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
async def test_unload_entry(hass, ialarm_api, mock_config_entry):
|
||||
|
@ -62,6 +58,6 @@ async def test_unload_entry(hass, ialarm_api, mock_config_entry):
|
|||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert mock_config_entry.state == ENTRY_STATE_LOADED
|
||||
assert mock_config_entry.state is ConfigEntryState.LOADED
|
||||
assert await hass.config_entries.async_unload(mock_config_entry.entry_id)
|
||||
assert mock_config_entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert mock_config_entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -110,7 +110,7 @@ async def test_fail_on_existing(hass: HomeAssistant):
|
|||
options={},
|
||||
)
|
||||
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(
|
||||
DOMAIN,
|
||||
|
@ -276,7 +276,7 @@ async def test_import_existing(hass: HomeAssistant):
|
|||
options={},
|
||||
)
|
||||
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(
|
||||
hass, {**MOCK_IMPORT_MINIMUM_HUB_V2, CONF_PORT: 25105, CONF_HUB_VERSION: 2}
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
"""Tests for the IPP integration."""
|
||||
from homeassistant.components.ipp.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.components.ipp import init_integration
|
||||
|
@ -16,7 +12,7 @@ async def test_config_entry_not_ready(
|
|||
) -> None:
|
||||
"""Test the IPP configuration entry not ready."""
|
||||
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(
|
||||
|
@ -27,10 +23,10 @@ async def test_unload_config_entry(
|
|||
|
||||
assert 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.async_block_till_done()
|
||||
|
||||
assert entry.entry_id not in hass.data[DOMAIN]
|
||||
assert entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -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.async_block_till_done()
|
||||
|
||||
assert entry.state == config_entries.ENTRY_STATE_LOADED
|
||||
assert entry.state is config_entries.ConfigEntryState.LOADED
|
||||
assert entry.options == {
|
||||
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.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):
|
||||
|
@ -93,7 +93,7 @@ async def test_unload_entry(hass, legacy_patchable_time):
|
|||
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ from aiohttp import ClientConnectorError, ClientResponseError
|
|||
|
||||
from homeassistant import config_entries, data_entry_flow, setup
|
||||
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
|
||||
|
||||
|
@ -65,7 +65,7 @@ async def test_form_options(hass, aioclient_mock):
|
|||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
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)
|
||||
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()
|
||||
|
||||
assert config_entry.state == "loaded"
|
||||
assert config_entry.state == config_entries.ConfigEntryState.LOADED
|
||||
|
||||
|
||||
async def test_form_invalid_auth(hass):
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
import asyncio
|
||||
|
||||
from homeassistant.components.kmtronic.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
|
||||
from 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.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.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):
|
||||
|
@ -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.async_block_till_done()
|
||||
|
||||
assert config_entry.state == ENTRY_STATE_SETUP_RETRY
|
||||
assert config_entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from unittest.mock import patch
|
||||
|
||||
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
|
||||
|
||||
|
@ -16,10 +16,10 @@ async def test_unload_entry(hass):
|
|||
entry = await init_integration(hass)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
|
|
@ -10,10 +10,7 @@ from homeassistant.components.vacuum import (
|
|||
SERVICE_START,
|
||||
STATE_DOCKED,
|
||||
)
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
|
||||
from .common import CONFIG, VACUUM_ENTITY_ID
|
||||
|
@ -46,8 +43,8 @@ async def test_unload_entry(hass, mock_account):
|
|||
@pytest.mark.parametrize(
|
||||
"side_effect,expected_state",
|
||||
(
|
||||
(LitterRobotLoginException, ENTRY_STATE_SETUP_ERROR),
|
||||
(LitterRobotException, ENTRY_STATE_SETUP_RETRY),
|
||||
(LitterRobotLoginException, ConfigEntryState.SETUP_ERROR),
|
||||
(LitterRobotException, ConfigEntryState.SETUP_RETRY),
|
||||
),
|
||||
)
|
||||
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,
|
||||
):
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
assert entry.state == expected_state
|
||||
assert entry.state is expected_state
|
||||
|
|
|
@ -109,7 +109,7 @@ async def test_full_flow(
|
|||
|
||||
assert DOMAIN in hass.config.components
|
||||
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(mock_setup.mock_calls) == 1
|
||||
|
|
|
@ -6,12 +6,7 @@ from unittest.mock import patch
|
|||
from pymazda import MazdaAuthenticationException, MazdaException
|
||||
|
||||
from homeassistant.components.mazda.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import (
|
||||
CONF_EMAIL,
|
||||
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.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):
|
||||
|
@ -61,7 +56,7 @@ async def test_init_auth_failure(hass: HomeAssistant):
|
|||
|
||||
entries = hass.config_entries.async_entries(DOMAIN)
|
||||
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()
|
||||
assert len(flows) == 1
|
||||
|
@ -93,7 +88,7 @@ async def test_update_auth_failure(hass: HomeAssistant):
|
|||
|
||||
entries = hass.config_entries.async_entries(DOMAIN)
|
||||
assert len(entries) == 1
|
||||
assert entries[0].state == ENTRY_STATE_LOADED
|
||||
assert entries[0].state is ConfigEntryState.LOADED
|
||||
|
||||
with patch(
|
||||
"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)
|
||||
assert len(entries) == 1
|
||||
assert entries[0].state == ENTRY_STATE_LOADED
|
||||
assert entries[0].state is ConfigEntryState.LOADED
|
||||
|
||||
with patch(
|
||||
"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)
|
||||
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.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):
|
||||
|
|
|
@ -5,11 +5,7 @@ from homeassistant.components.met.const import (
|
|||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config import async_process_ha_core_config
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
|
||||
from . import init_integration
|
||||
|
||||
|
@ -19,12 +15,12 @@ async def test_unload_entry(hass):
|
|||
entry = await init_integration(hass)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
|
||||
|
@ -41,7 +37,7 @@ async def test_fail_default_home_entry(hass, caplog):
|
|||
entry = await init_integration(hass, track_home=True)
|
||||
|
||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||
assert entry.state == ENTRY_STATE_SETUP_ERROR
|
||||
assert entry.state is ConfigEntryState.SETUP_ERROR
|
||||
|
||||
assert (
|
||||
"Skip setting up met.no integration; No Home location has been set"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Test the Met Éireann integration init."""
|
||||
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
|
||||
|
||||
|
@ -10,10 +10,10 @@ async def test_unload_entry(hass):
|
|||
entry = await init_integration(hass)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
|
|
@ -86,7 +86,7 @@ async def test_hub_setup_failed(hass):
|
|||
|
||||
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
|
||||
config_entry = MockConfigEntry(domain=mikrotik.DOMAIN, data=MOCK_DATA)
|
||||
|
|
|
@ -4,11 +4,7 @@ from unittest.mock import patch
|
|||
from nettigo_air_monitor import ApiError
|
||||
|
||||
from homeassistant.components.nam.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
@ -40,7 +36,7 @@ async def test_config_not_ready(hass):
|
|||
):
|
||||
entry.add_to_hass(hass)
|
||||
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):
|
||||
|
@ -48,10 +44,10 @@ async def test_unload_entry(hass):
|
|||
entry = await init_integration(hass)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
|
|
@ -152,6 +152,6 @@ async def test_reauth(
|
|||
|
||||
assert result3["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
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(mock_setup.mock_calls) == 1
|
||||
|
|
|
@ -11,12 +11,7 @@ from unittest.mock import patch
|
|||
from google_nest_sdm.exceptions import AuthException, GoogleNestException
|
||||
|
||||
from homeassistant.components.nest import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
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)
|
||||
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):
|
||||
|
@ -54,7 +49,7 @@ async def test_setup_configuration_failure(hass, caplog):
|
|||
|
||||
entries = hass.config_entries.async_entries(DOMAIN)
|
||||
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
|
||||
# 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)
|
||||
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):
|
||||
|
@ -89,7 +84,7 @@ async def test_setup_device_manager_failure(hass, caplog):
|
|||
|
||||
entries = hass.config_entries.async_entries(DOMAIN)
|
||||
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):
|
||||
|
@ -103,7 +98,7 @@ async def test_subscriber_auth_failure(hass, caplog):
|
|||
|
||||
entries = hass.config_entries.async_entries(DOMAIN)
|
||||
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()
|
||||
assert len(flows) == 1
|
||||
|
@ -121,7 +116,7 @@ async def test_setup_missing_subscriber_id(hass, caplog):
|
|||
|
||||
entries = hass.config_entries.async_entries(DOMAIN)
|
||||
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):
|
||||
|
|
|
@ -85,7 +85,7 @@ async def test_setup_component(hass):
|
|||
mock_impl.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 len(hass.states.async_all()) > 0
|
||||
|
||||
|
|
|
@ -4,11 +4,7 @@ from unittest.mock import patch
|
|||
from aiohttp import ClientError
|
||||
|
||||
from homeassistant.components.nightscout.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_URL
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
@ -20,12 +16,12 @@ async def test_unload_entry(hass):
|
|||
entry = await init_integration(hass)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
|
||||
|
@ -42,4 +38,4 @@ async def test_async_setup_raises_entry_not_ready(hass):
|
|||
side_effect=ClientError(),
|
||||
):
|
||||
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
|
||||
|
|
|
@ -4,11 +4,7 @@ from unittest.mock import patch
|
|||
from pynzbgetapi import NZBGetAPIException
|
||||
|
||||
from homeassistant.components.nzbget.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
@ -44,12 +40,12 @@ async def test_unload_entry(hass, nzbget_api):
|
|||
entry = await init_integration(hass)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
|
||||
|
@ -64,4 +60,4 @@ async def test_async_setup_raises_entry_not_ready(hass):
|
|||
):
|
||||
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
|
||||
|
|
|
@ -5,12 +5,7 @@ from pyownet.protocol import ConnError, OwnetError
|
|||
|
||||
from homeassistant.components.onewire.const import CONF_TYPE_OWSERVER, DOMAIN
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
SOURCE_USER,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_USER, ConfigEntryState
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TYPE
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -48,7 +43,7 @@ async def test_owserver_connect_failure(hass):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
@ -81,15 +76,15 @@ async def test_unload_entry(hass):
|
|||
config_entry_sysbus = await setup_onewire_sysbus_integration(hass)
|
||||
|
||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 2
|
||||
assert config_entry_owserver.state == ENTRY_STATE_LOADED
|
||||
assert config_entry_sysbus.state == ENTRY_STATE_LOADED
|
||||
assert config_entry_owserver.state is ConfigEntryState.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_sysbus.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert config_entry_owserver.state == ENTRY_STATE_NOT_LOADED
|
||||
assert config_entry_sysbus.state == ENTRY_STATE_NOT_LOADED
|
||||
assert config_entry_owserver.state is ConfigEntryState.NOT_LOADED
|
||||
assert config_entry_sysbus.state is ConfigEntryState.NOT_LOADED
|
||||
assert not hass.data.get(DOMAIN)
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from homeassistant.components.openweathermap.const import (
|
|||
DEFAULT_LANGUAGE,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.config_entries import SOURCE_USER, ConfigEntryState
|
||||
from homeassistant.const import (
|
||||
CONF_API_KEY,
|
||||
CONF_LATITUDE,
|
||||
|
@ -57,11 +57,11 @@ async def test_form(hass):
|
|||
|
||||
conf_entries = hass.config_entries.async_entries(DOMAIN)
|
||||
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.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["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)
|
||||
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)
|
||||
|
||||
|
@ -105,7 +105,7 @@ async def test_form_options(hass):
|
|||
|
||||
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)
|
||||
|
||||
|
@ -124,7 +124,7 @@ async def test_form_options(hass):
|
|||
|
||||
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):
|
||||
|
|
|
@ -10,7 +10,9 @@ from tests.common import MockConfigEntry
|
|||
|
||||
async def setup_ozw(hass, entry=None, fixture=None):
|
||||
"""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)
|
||||
|
||||
if entry is None:
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import patch
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.config_entries import ENTRY_STATE_LOADED
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
|
||||
from .common import MQTTMessage
|
||||
|
||||
|
@ -275,6 +275,6 @@ def mock_get_addon_discovery_info():
|
|||
@pytest.fixture(name="mqtt")
|
||||
async def mock_mqtt_fixture(hass):
|
||||
"""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)
|
||||
return mqtt_entry
|
||||
|
|
|
@ -65,16 +65,16 @@ async def test_unload_entry(hass, generic_data, switch_msg, caplog):
|
|||
title="Z-Wave",
|
||||
)
|
||||
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)
|
||||
|
||||
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
|
||||
|
||||
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")
|
||||
assert len(entities) == 1
|
||||
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 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
|
||||
for record in caplog.records:
|
||||
assert record.levelname != "ERROR"
|
||||
|
@ -113,12 +113,12 @@ async def test_remove_entry(hass, stop_addon, uninstall_addon, caplog):
|
|||
data={"integration_created_addon": False},
|
||||
)
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
# 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 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
|
||||
stop_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 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 "Failed to stop the OpenZWave add-on" in caplog.text
|
||||
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 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 "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 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(
|
||||
|
@ -224,15 +224,15 @@ async def test_unload_entry_with_addon(
|
|||
)
|
||||
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:
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
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)
|
||||
|
||||
assert entry.state == config_entries.ENTRY_STATE_NOT_LOADED
|
||||
assert entry.state is config_entries.ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -7,7 +7,7 @@ from homeassistant.components.panasonic_viera.const import (
|
|||
DEFAULT_NAME,
|
||||
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.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.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_remote = hass.states.get("remote.panasonic_viera_tv")
|
||||
|
|
|
@ -23,10 +23,10 @@ from homeassistant.components.plex.const import (
|
|||
SERVERS,
|
||||
)
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
SOURCE_INTEGRATION_DISCOVERY,
|
||||
SOURCE_REAUTH,
|
||||
SOURCE_USER,
|
||||
ConfigEntryState,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
|
@ -354,7 +354,7 @@ async def test_all_available_servers_configured(
|
|||
async def test_option_flow(hass, entry, mock_plex_server):
|
||||
"""Test config options flow selection."""
|
||||
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(
|
||||
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):
|
||||
"""Test config options flow selection when no options stored."""
|
||||
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(
|
||||
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 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):
|
||||
|
@ -707,7 +707,7 @@ async def test_trigger_reauth(
|
|||
"""Test setup and reauthorization of a Plex token."""
|
||||
await async_setup_component(hass, "persistent_notification", {})
|
||||
|
||||
assert entry.state == ENTRY_STATE_LOADED
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
|
||||
with patch(
|
||||
"plexapi.server.PlexServer.clients", side_effect=plexapi.exceptions.Unauthorized
|
||||
|
@ -716,7 +716,7 @@ async def test_trigger_reauth(
|
|||
await wait_for_debouncer(hass)
|
||||
|
||||
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()
|
||||
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.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_IDENTIFIER] == mock_plex_server.machine_identifier
|
||||
assert entry.data[PLEX_SERVER_CONFIG][CONF_URL] == PLEX_DIRECT_URL
|
||||
|
|
|
@ -13,12 +13,7 @@ from homeassistant.components.plex.models import (
|
|||
TRANSIENT_SECTION,
|
||||
UNKNOWN_SECTION,
|
||||
)
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import (
|
||||
CONF_TOKEN,
|
||||
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):
|
||||
"""Test updating missing unique_id from config entry."""
|
||||
assert len(hass.config_entries.async_entries(const.DOMAIN)) == 1
|
||||
assert entry.state == ENTRY_STATE_LOADED
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
|
||||
assert (
|
||||
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()
|
||||
|
||||
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(
|
||||
"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()
|
||||
|
||||
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):
|
||||
|
@ -80,7 +75,7 @@ async def test_setup_with_insecure_config_entry(hass, entry, setup_plex_server):
|
|||
await setup_plex_server(config_entry=entry)
|
||||
|
||||
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):
|
||||
|
@ -88,7 +83,7 @@ async def test_unload_config_entry(hass, entry, mock_plex_server):
|
|||
config_entries = hass.config_entries.async_entries(const.DOMAIN)
|
||||
assert len(config_entries) == 1
|
||||
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
|
||||
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]
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
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):
|
||||
|
@ -105,7 +100,7 @@ async def test_setup_with_photo_session(hass, entry, setup_plex_server):
|
|||
await setup_plex_server(session_type="photo")
|
||||
|
||||
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()
|
||||
|
||||
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")
|
||||
|
||||
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()
|
||||
|
||||
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")
|
||||
|
||||
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()
|
||||
|
||||
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")
|
||||
|
||||
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()
|
||||
|
||||
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
|
||||
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)
|
||||
|
||||
# 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
|
||||
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)
|
||||
|
||||
# Test with success
|
||||
|
@ -249,7 +244,7 @@ async def test_setup_when_certificate_changed(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
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
|
||||
|
||||
|
@ -261,7 +256,7 @@ async def test_tokenless_server(entry, setup_plex_server):
|
|||
entry.data = TOKENLESS_DATA
|
||||
|
||||
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(
|
||||
|
@ -272,7 +267,7 @@ async def test_bad_token_with_tokenless_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
|
||||
trigger_plex_update(mock_websocket)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""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 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):
|
||||
"""Test creation of climate related binary_sensor entities."""
|
||||
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")
|
||||
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):
|
||||
"""Test change of climate related binary_sensor entities."""
|
||||
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, {})
|
||||
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):
|
||||
"""Test change of climate related binary_sensor entities."""
|
||||
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")
|
||||
assert str(state.state) == STATE_ON
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
from plugwise.exceptions import PlugwiseException
|
||||
|
||||
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
|
||||
|
||||
|
@ -11,7 +11,7 @@ from tests.components.plugwise.common import async_init_integration
|
|||
async def test_adam_climate_entity_attributes(hass, mock_smile_adam):
|
||||
"""Test creation of adam climate device environment."""
|
||||
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")
|
||||
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_temperature.side_effect = PlugwiseException
|
||||
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(
|
||||
"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):
|
||||
"""Test handling of user requests in adam climate device environment."""
|
||||
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(
|
||||
"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):
|
||||
"""Test creation of anna climate device environment."""
|
||||
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")
|
||||
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):
|
||||
"""Test handling of user requests in anna climate device environment."""
|
||||
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(
|
||||
"climate",
|
||||
|
|
|
@ -5,11 +5,7 @@ import asyncio
|
|||
from plugwise.exceptions import XMLDataMissingError
|
||||
|
||||
from homeassistant.components.plugwise.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
|
||||
from tests.common import AsyncMock, MockConfigEntry
|
||||
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):
|
||||
"""Test failing unauthorization by Smile."""
|
||||
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):
|
||||
"""Test server error handling by Smile."""
|
||||
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):
|
||||
"""Connection failure error handling by Smile."""
|
||||
mock_smile_notconnect.connect.return_value = False
|
||||
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):
|
||||
"""Timeout error handling by Smile."""
|
||||
mock_smile_notconnect.connect.side_effect = asyncio.TimeoutError
|
||||
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):
|
||||
"""Detect malformed XML by Smile in Adam environment."""
|
||||
mock_smile_adam.full_update_device.side_effect = XMLDataMissingError
|
||||
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):
|
||||
|
@ -55,7 +51,7 @@ async def test_unload_entry(hass, mock_smile_adam):
|
|||
mock_smile_adam.async_reset = AsyncMock(return_value=True)
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
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]
|
||||
|
||||
|
||||
|
@ -66,4 +62,4 @@ async def test_async_setup_entry_fail(hass):
|
|||
entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert entry.state == ENTRY_STATE_SETUP_ERROR
|
||||
assert entry.state is ConfigEntryState.SETUP_ERROR
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""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.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):
|
||||
"""Test creation of climate related sensor entities."""
|
||||
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")
|
||||
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):
|
||||
"""Test creation of climate related sensor entities."""
|
||||
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")
|
||||
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."""
|
||||
mock_smile_anna.single_master_thermostat.side_effect = Mock(return_value=False)
|
||||
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")
|
||||
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):
|
||||
"""Test creation of power related sensor entities."""
|
||||
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")
|
||||
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):
|
||||
"""Test creation of power related sensor entities."""
|
||||
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")
|
||||
assert float(state.state) == 50.5
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
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
|
||||
|
||||
|
@ -10,7 +10,7 @@ from tests.components.plugwise.common import async_init_integration
|
|||
async def test_adam_climate_switch_entities(hass, mock_smile_adam):
|
||||
"""Test creation of climate related switch entities."""
|
||||
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")
|
||||
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."""
|
||||
mock_smile_adam.set_relay_state.side_effect = PlugwiseException
|
||||
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(
|
||||
"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):
|
||||
"""Test changing of climate related switch entities."""
|
||||
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(
|
||||
"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):
|
||||
"""Test creation of climate related switch entities."""
|
||||
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")
|
||||
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):
|
||||
"""Test changing of power related switch entities."""
|
||||
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(
|
||||
"switch",
|
||||
|
|
|
@ -3,6 +3,7 @@ from unittest.mock import call
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.rfxtrx import DOMAIN
|
||||
from homeassistant.core import State
|
||||
|
||||
|
@ -168,4 +169,4 @@ async def test_unknown_event_code(hass, rfxtrx):
|
|||
assert len(conf_entries) == 1
|
||||
|
||||
entry = conf_entries[0]
|
||||
assert entry.state == "loaded"
|
||||
assert entry.state == config_entries.ConfigEntryState.LOADED
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.roku.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
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."""
|
||||
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(
|
||||
|
@ -36,10 +32,10 @@ async def test_unload_config_entry(
|
|||
entry = await setup_integration(hass, aioclient_mock)
|
||||
|
||||
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.async_block_till_done()
|
||||
|
||||
assert entry.entry_id not in hass.data[DOMAIN]
|
||||
assert entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -14,11 +14,7 @@ from homeassistant.components.ruckus_unleashed import (
|
|||
DOMAIN,
|
||||
MANUFACTURER,
|
||||
)
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
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.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):
|
||||
|
@ -84,12 +80,12 @@ async def test_unload_entry(hass):
|
|||
entry = await init_integration(hass)
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
|
||||
|
@ -113,4 +109,4 @@ async def test_config_not_ready_during_setup(hass):
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entry.state == ENTRY_STATE_SETUP_RETRY
|
||||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
|
|
@ -6,12 +6,7 @@ from homeassistant.components.homeassistant import (
|
|||
SERVICE_UPDATE_ENTITY,
|
||||
)
|
||||
from homeassistant.components.smart_meter_texas.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
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."""
|
||||
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):
|
||||
"""Test that a timeout results in ConfigEntryNotReady."""
|
||||
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):
|
||||
|
@ -64,9 +59,9 @@ async def test_unload_config_entry(hass, config_entry, aioclient_mock):
|
|||
config_entries = hass.config_entries.async_entries(DOMAIN)
|
||||
assert len(config_entries) == 1
|
||||
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.async_block_till_done()
|
||||
|
||||
assert config_entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert config_entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -7,11 +7,7 @@ from smarttub import LoginFailed
|
|||
|
||||
from homeassistant.components import smarttub
|
||||
from homeassistant.components.smarttub.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
SOURCE_REAUTH,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
|
||||
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)
|
||||
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):
|
||||
|
@ -40,7 +36,7 @@ async def test_setup_auth_failed(setup_component, hass, config_entry, smarttub_a
|
|||
config_entry.add_to_hass(hass)
|
||||
with patch.object(hass.config_entries.flow, "async_init") as mock_flow_init:
|
||||
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(
|
||||
DOMAIN,
|
||||
context={
|
||||
|
|
|
@ -97,10 +97,10 @@ async def test_full_flow(
|
|||
|
||||
assert DOMAIN in hass.config.components
|
||||
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 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):
|
||||
|
|
|
@ -2,13 +2,7 @@
|
|||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.components.sonarr.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
SOURCE_REAUTH,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState
|
||||
from homeassistant.const import CONF_SOURCE
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
@ -21,7 +15,7 @@ async def test_config_entry_not_ready(
|
|||
) -> None:
|
||||
"""Test the configuration entry not ready."""
|
||||
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(
|
||||
|
@ -31,7 +25,7 @@ async def test_config_entry_reauth(
|
|||
with patch.object(hass.config_entries.flow, "async_init") as mock_flow_init:
|
||||
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(
|
||||
DOMAIN,
|
||||
|
@ -56,10 +50,10 @@ async def test_unload_config_entry(
|
|||
|
||||
assert 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.async_block_till_done()
|
||||
|
||||
assert entry.entry_id not in hass.data[DOMAIN]
|
||||
assert entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -38,7 +38,7 @@ async def test_successful_config_entry(hass):
|
|||
) as forward_entry_setup:
|
||||
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] == (
|
||||
entry,
|
||||
"sensor",
|
||||
|
@ -58,7 +58,7 @@ async def test_setup_failed(hass):
|
|||
|
||||
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):
|
||||
|
@ -75,5 +75,5 @@ async def test_unload_entry(hass):
|
|||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"""Tests for Srp Energy component Init."""
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import srp_energy
|
||||
|
||||
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):
|
||||
"""Test setup entry fails if deCONZ is not available."""
|
||||
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]
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ from homeassistant.components.subaru.const import (
|
|||
VEHICLE_HAS_SAFETY_SERVICE,
|
||||
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.setup import async_setup_component
|
||||
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 len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||
assert hass.config_entries.async_get_entry(entry.entry_id)
|
||||
assert entry.state == ENTRY_STATE_LOADED
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
return entry
|
||||
|
|
|
@ -8,12 +8,7 @@ from homeassistant.components.homeassistant import (
|
|||
SERVICE_UPDATE_ENTITY,
|
||||
)
|
||||
from homeassistant.components.subaru.const import DOMAIN
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_ERROR,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
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."""
|
||||
check_entry = hass.config_entries.async_get_entry(ev_entry.entry_id)
|
||||
assert check_entry
|
||||
assert check_entry.state == ENTRY_STATE_LOADED
|
||||
assert check_entry.state is ConfigEntryState.LOADED
|
||||
|
||||
|
||||
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)
|
||||
assert check_entry
|
||||
assert check_entry.state == ENTRY_STATE_LOADED
|
||||
assert check_entry.state is ConfigEntryState.LOADED
|
||||
|
||||
|
||||
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)
|
||||
assert check_entry
|
||||
assert check_entry.state == ENTRY_STATE_LOADED
|
||||
assert check_entry.state is ConfigEntryState.LOADED
|
||||
|
||||
|
||||
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)
|
||||
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):
|
||||
|
@ -95,7 +90,7 @@ async def test_invalid_credentials(hass):
|
|||
)
|
||||
check_entry = hass.config_entries.async_get_entry(entry.entry_id)
|
||||
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):
|
||||
|
@ -147,7 +142,7 @@ async def test_fetch_failed(hass):
|
|||
|
||||
async def test_unload_entry(hass, ev_entry):
|
||||
"""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)
|
||||
await hass.async_block_till_done()
|
||||
assert ev_entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert ev_entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from unittest.mock import patch
|
||||
|
||||
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 .common import CONFIG_DATA
|
||||
|
@ -26,4 +26,4 @@ async def test_reauth_started(hass):
|
|||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert mock_entry.state == ENTRY_STATE_SETUP_ERROR
|
||||
assert mock_entry.state is ConfigEntryState.SETUP_ERROR
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.vera import (
|
|||
CONF_LIGHTS,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import ENTRY_STATE_NOT_LOADED
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
|
@ -148,7 +148,7 @@ async def test_unload(
|
|||
|
||||
for config_entry in entries:
|
||||
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(
|
||||
|
|
|
@ -242,7 +242,7 @@ async def test_discovery_updates_unique_id(hass):
|
|||
"name": "dummy",
|
||||
"id": TEST_DISCOVERY_RESULT["id"],
|
||||
},
|
||||
state=config_entries.ENTRY_STATE_SETUP_RETRY,
|
||||
state=config_entries.ConfigEntryState.SETUP_RETRY,
|
||||
)
|
||||
|
||||
entry.add_to_hass(hass)
|
||||
|
|
|
@ -5,11 +5,7 @@ import pytest
|
|||
import pywilight
|
||||
from pywilight.const import DOMAIN
|
||||
|
||||
from homeassistant.config_entries import (
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
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."""
|
||||
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:
|
||||
|
@ -55,11 +51,11 @@ async def test_unload_config_entry(hass: HomeAssistant, dummy_device_from_host)
|
|||
entry = await setup_integration(hass)
|
||||
|
||||
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.async_block_till_done()
|
||||
|
||||
if DOMAIN in hass.data:
|
||||
assert entry.entry_id not in hass.data[DOMAIN]
|
||||
assert entry.state == ENTRY_STATE_NOT_LOADED
|
||||
assert entry.state is ConfigEntryState.NOT_LOADED
|
||||
|
|
|
@ -4,7 +4,7 @@ from unittest.mock import MagicMock, patch
|
|||
from wled import WLEDConnectionError
|
||||
|
||||
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 tests.components.wled import init_integration
|
||||
|
@ -17,7 +17,7 @@ async def test_config_entry_not_ready(
|
|||
) -> None:
|
||||
"""Test the WLED configuration entry not ready."""
|
||||
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(
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.yeelight import (
|
|||
DOMAIN,
|
||||
NIGHTLIGHT_SWITCH_TYPE_LIGHT,
|
||||
)
|
||||
from homeassistant.config_entries import ENTRY_STATE_SETUP_RETRY
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICES,
|
||||
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)
|
||||
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):
|
||||
|
|
|
@ -9,12 +9,7 @@ from zwave_js_server.model.node import Node
|
|||
from homeassistant.components.hassio.handler import HassioAPIError
|
||||
from homeassistant.components.zwave_js.const import DOMAIN
|
||||
from homeassistant.components.zwave_js.helpers import get_device_id
|
||||
from homeassistant.config_entries import (
|
||||
DISABLED_USER,
|
||||
ENTRY_STATE_LOADED,
|
||||
ENTRY_STATE_NOT_LOADED,
|
||||
ENTRY_STATE_SETUP_RETRY,
|
||||
)
|
||||
from homeassistant.config_entries import DISABLED_USER, ConfigEntryState
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
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):
|
||||
|
@ -62,7 +57,7 @@ async def test_initialized_timeout(hass, client, connect_timeout):
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
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):
|
||||
|
@ -130,7 +125,7 @@ async def test_listen_failure(hass, client, error):
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
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(
|
||||
|
@ -590,7 +585,7 @@ async def test_start_addon(
|
|||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
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 set_addon_options.call_count == 1
|
||||
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.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_args == call(hass, "core_zwave_js")
|
||||
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.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 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.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 update_addon.call_count == update_calls
|
||||
|
||||
|
@ -716,8 +711,8 @@ async def test_update_addon(
|
|||
@pytest.mark.parametrize(
|
||||
"stop_addon_side_effect, entry_state",
|
||||
[
|
||||
(None, ENTRY_STATE_NOT_LOADED),
|
||||
(HassioAPIError("Boom"), ENTRY_STATE_LOADED),
|
||||
(None, ConfigEntryState.NOT_LOADED),
|
||||
(HassioAPIError("Boom"), ConfigEntryState.LOADED),
|
||||
],
|
||||
)
|
||||
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.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.async_block_till_done()
|
||||
|
@ -770,12 +765,12 @@ async def test_remove_entry(
|
|||
data={"integration_created_addon": False},
|
||||
)
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
# 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_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
|
||||
stop_addon.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 create_shapshot.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 "Failed to stop the Z-Wave JS add-on" in caplog.text
|
||||
stop_addon.side_effect = None
|
||||
|
@ -840,7 +835,7 @@ async def test_remove_entry(
|
|||
partial=True,
|
||||
)
|
||||
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 "Failed to create a snapshot of the Z-Wave JS add-on" in caplog.text
|
||||
create_shapshot.side_effect = None
|
||||
|
@ -865,7 +860,7 @@ async def test_remove_entry(
|
|||
)
|
||||
assert uninstall_addon.call_count == 1
|
||||
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 "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
Loading…
Add table
Reference in a new issue