From 0b01326f9fd36371f47b3e7028aae5d6df34c8d9 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:16:55 +0200 Subject: [PATCH] Use is in ConfigEntryState enum comparison in tests (A-M) (#114925) --- tests/components/agent_dvr/test_init.py | 6 +++--- .../components/aladdin_connect/test_cover.py | 2 +- tests/components/aladdin_connect/test_init.py | 12 +++++------ .../analytics_insights/test_init.py | 4 ++-- .../components/android_ip_webcam/test_init.py | 6 +++--- .../components/androidtv/test_media_player.py | 2 +- tests/components/anthemav/test_init.py | 8 ++++---- tests/components/asuswrt/test_diagnostics.py | 2 +- tests/components/automation/test_blueprint.py | 4 ++-- tests/components/automation/test_init.py | 4 ++-- tests/components/axis/test_init.py | 10 +++++----- tests/components/azure_devops/test_init.py | 10 +++++----- tests/components/azure_event_hub/conftest.py | 4 ++-- tests/components/azure_event_hub/test_init.py | 4 ++-- tests/components/baf/test_init.py | 2 +- tests/components/balboa/test_init.py | 8 ++++---- tests/components/blebox/test_config_flow.py | 5 +++-- tests/components/blue_current/test_init.py | 4 ++-- tests/components/bluetooth/test_init.py | 10 +++++----- tests/components/bluetooth/test_scanner.py | 4 ++-- tests/components/bring/test_init.py | 4 ++-- tests/components/caldav/test_init.py | 8 ++++---- tests/components/coinbase/test_init.py | 6 +++--- tests/components/daikin/test_init.py | 4 ++-- .../components/device_automation/test_init.py | 19 +++++++++--------- .../device_tracker/test_config_entry.py | 8 ++++---- .../devolo_home_control/test_diagnostics.py | 2 +- .../devolo_home_network/test_diagnostics.py | 2 +- tests/components/dlink/test_init.py | 6 +++--- tests/components/dnsip/test_config_flow.py | 3 ++- tests/components/dnsip/test_init.py | 7 +++---- .../components/dremel_3d_printer/test_init.py | 6 +++--- tests/components/dsmr/test_sensor.py | 4 ++-- .../dwd_weather_warnings/test_init.py | 2 +- tests/components/dynalite/test_config_flow.py | 9 +++++---- tests/components/eafm/test_sensor.py | 4 ++-- tests/components/efergy/test_init.py | 6 +++--- .../energenie_power_sockets/test_init.py | 2 +- .../energenie_power_sockets/test_switch.py | 2 +- tests/components/esphome/test_dashboard.py | 8 ++++---- .../components/evil_genius_labs/test_init.py | 4 ++-- tests/components/fastdotcom/test_init.py | 10 +++++----- tests/components/fitbit/test_init.py | 20 +++++++++---------- tests/components/flexit_bacnet/test_init.py | 4 ++-- tests/components/flipr/test_init.py | 2 +- tests/components/flux_led/test_init.py | 16 +++++++-------- .../components/forecast_solar/test_energy.py | 2 +- tests/components/forecast_solar/test_init.py | 2 +- tests/components/freedompro/test_init.py | 6 +++--- tests/components/fritz/test_button.py | 12 +++++------ tests/components/fritz/test_diagnostics.py | 2 +- tests/components/fritz/test_image.py | 6 +++--- tests/components/fritz/test_init.py | 10 +++++----- tests/components/fritz/test_sensor.py | 2 +- tests/components/fritz/test_switch.py | 2 +- tests/components/fritz/test_update.py | 8 ++++---- tests/components/generic/test_config_flow.py | 7 ++++--- tests/components/github/common.py | 4 ++-- tests/components/glances/test_init.py | 4 ++-- tests/components/goalzero/test_init.py | 6 +++--- tests/components/google/test_init.py | 4 ++-- tests/components/google_tasks/test_init.py | 2 +- tests/components/hardkernel/test_init.py | 2 +- tests/components/hassio/test_sensor.py | 3 ++- tests/components/holiday/test_init.py | 4 ++-- .../homeassistant_green/test_init.py | 2 +- .../homeassistant_sky_connect/test_init.py | 6 +++--- .../homeassistant_yellow/test_init.py | 6 +++--- tests/components/homekit/test_init.py | 2 +- .../homekit_controller/test_device_trigger.py | 4 ++-- .../homekit_controller/test_init.py | 8 ++++---- .../husqvarna_automower/test_init.py | 10 +++++----- tests/components/insteon/test_config_flow.py | 3 ++- tests/components/iotawatt/test_init.py | 4 ++-- .../islamic_prayer_times/test_init.py | 10 +++++----- tests/components/kmtronic/test_config_flow.py | 2 +- tests/components/knx/test_init.py | 4 ++-- tests/components/lacrosse_view/test_init.py | 14 ++++++------- tests/components/lacrosse_view/test_sensor.py | 12 +++++------ .../components/lamarzocco/test_config_flow.py | 4 ++-- tests/components/laundrify/test_init.py | 8 ++++---- tests/components/lawn_mower/test_init.py | 4 ++-- tests/components/lcn/test_init.py | 14 ++++++------- tests/components/lidarr/test_init.py | 6 +++--- tests/components/lifx/test_init.py | 12 +++++------ .../linear_garage_door/test_coordinator.py | 4 ++-- .../linear_garage_door/test_cover.py | 2 +- .../linear_garage_door/test_init.py | 4 ++-- tests/components/local_calendar/test_init.py | 6 +++--- tests/components/local_ip/test_init.py | 6 +++--- tests/components/local_todo/test_init.py | 6 +++--- tests/components/lyric/test_config_flow.py | 3 ++- tests/components/matter/test_init.py | 8 ++++---- tests/components/mikrotik/test_init.py | 8 ++++---- .../components/minecraft_server/test_init.py | 16 +++++++-------- tests/components/modem_callerid/test_init.py | 4 ++-- tests/components/mqtt/test_util.py | 16 +++++++-------- tests/components/mystrom/test_init.py | 8 ++++---- tests/components/myuplink/test_init.py | 4 ++-- 99 files changed, 302 insertions(+), 295 deletions(-) diff --git a/tests/components/agent_dvr/test_init.py b/tests/components/agent_dvr/test_init.py index 5b360430b78..7f546a190a7 100644 --- a/tests/components/agent_dvr/test_init.py +++ b/tests/components/agent_dvr/test_init.py @@ -31,7 +31,7 @@ async def test_setup_config_and_unload( ) -> None: """Test setup and unload.""" entry = await init_integration(hass, aioclient_mock) - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert entry.data == CONF_DATA @@ -50,7 +50,7 @@ async def test_async_setup_entry_not_ready(hass: HomeAssistant) -> None: side_effect=AgentError, ): await hass.config_entries.async_setup(entry.entry_id) - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY with _patch_init_agent(await _create_mocked_agent(available=False)): await hass.config_entries.async_reload(entry.entry_id) - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY diff --git a/tests/components/aladdin_connect/test_cover.py b/tests/components/aladdin_connect/test_cover.py index 9ad9febc762..082ade75ab9 100644 --- a/tests/components/aladdin_connect/test_cover.py +++ b/tests/components/aladdin_connect/test_cover.py @@ -114,7 +114,7 @@ async def test_cover_operation( await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert COVER_DOMAIN in hass.config.components diff --git a/tests/components/aladdin_connect/test_init.py b/tests/components/aladdin_connect/test_init.py index c995fb5074d..623c121957b 100644 --- a/tests/components/aladdin_connect/test_init.py +++ b/tests/components/aladdin_connect/test_init.py @@ -93,7 +93,7 @@ async def test_setup_component_no_error(hass: HomeAssistant) -> None: assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert len(hass.config_entries.async_entries(DOMAIN)) == 1 @@ -135,12 +135,12 @@ async def test_load_and_unload( await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert await config_entry.async_unload(hass) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED async def test_stale_device_removal( @@ -190,7 +190,7 @@ async def test_stale_device_removal( assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert len(hass.config_entries.async_entries(DOMAIN)) == 1 device_registry = dr.async_get(hass) @@ -220,7 +220,7 @@ async def test_stale_device_removal( assert await config_entry.async_unload(hass) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED mock_aladdinconnect_api.get_doors = AsyncMock(return_value=[DEVICE_CONFIG_OPEN]) with patch( @@ -230,7 +230,7 @@ async def test_stale_device_removal( assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert len(hass.config_entries.async_entries(DOMAIN)) == 1 device_entries = dr.async_entries_for_config_entry( diff --git a/tests/components/analytics_insights/test_init.py b/tests/components/analytics_insights/test_init.py index 4f1ca7cda95..8543a02c025 100644 --- a/tests/components/analytics_insights/test_init.py +++ b/tests/components/analytics_insights/test_init.py @@ -21,9 +21,9 @@ async def test_load_unload_entry( await setup_integration(hass, mock_config_entry) entry = hass.config_entries.async_entries(DOMAIN)[0] - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED await hass.config_entries.async_remove(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED diff --git a/tests/components/android_ip_webcam/test_init.py b/tests/components/android_ip_webcam/test_init.py index 9aa677b8708..70ecdc9271e 100644 --- a/tests/components/android_ip_webcam/test_init.py +++ b/tests/components/android_ip_webcam/test_init.py @@ -30,7 +30,7 @@ async def test_successful_config_entry( await hass.config_entries.async_setup(entry.entry_id) - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED async def test_setup_failed_connection_error( @@ -47,7 +47,7 @@ async def test_setup_failed_connection_error( await hass.config_entries.async_setup(entry.entry_id) - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY async def test_setup_failed_invalid_auth( @@ -64,7 +64,7 @@ async def test_setup_failed_invalid_auth( await hass.config_entries.async_setup(entry.entry_id) - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY async def test_unload_entry(hass: HomeAssistant, aioclient_mock_fixture) -> None: diff --git a/tests/components/androidtv/test_media_player.py b/tests/components/androidtv/test_media_player.py index 63923a57996..fe6b9962d14 100644 --- a/tests/components/androidtv/test_media_player.py +++ b/tests/components/androidtv/test_media_player.py @@ -591,7 +591,7 @@ async def test_setup_fail( await async_update_entity(hass, entity_id) state = hass.states.get(entity_id) - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY assert state is None diff --git a/tests/components/anthemav/test_init.py b/tests/components/anthemav/test_init.py index 6989ffc69c5..45614a1d885 100644 --- a/tests/components/anthemav/test_init.py +++ b/tests/components/anthemav/test_init.py @@ -6,7 +6,7 @@ from unittest.mock import ANY, AsyncMock, patch from anthemav.device_error import DeviceError import pytest -from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant @@ -24,13 +24,13 @@ async def test_load_unload_config_entry( mock_connection_create.assert_called_with( host="1.1.1.1", port=14999, update_callback=ANY ) - assert init_integration.state == config_entries.ConfigEntryState.LOADED + assert init_integration.state is ConfigEntryState.LOADED # unload await hass.config_entries.async_unload(init_integration.entry_id) await hass.async_block_till_done() # assert unload and avr is closed - assert init_integration.state == config_entries.ConfigEntryState.NOT_LOADED + assert init_integration.state is ConfigEntryState.NOT_LOADED mock_anthemav.close.assert_called_once() @@ -46,7 +46,7 @@ async def test_config_entry_not_ready_when_oserror( mock_config_entry.add_to_hass(hass) await hass.config_entries.async_setup(mock_config_entry.entry_id) await hass.async_block_till_done() - assert mock_config_entry.state is config_entries.ConfigEntryState.SETUP_RETRY + assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY async def test_anthemav_dispatcher_signal( diff --git a/tests/components/asuswrt/test_diagnostics.py b/tests/components/asuswrt/test_diagnostics.py index 1c09dd29adc..207f3ba25f0 100644 --- a/tests/components/asuswrt/test_diagnostics.py +++ b/tests/components/asuswrt/test_diagnostics.py @@ -30,7 +30,7 @@ async def test_diagnostics( await hass.config_entries.async_setup(mock_config_entry.entry_id) await hass.async_block_till_done() - assert mock_config_entry.state == ConfigEntryState.LOADED + assert mock_config_entry.state is ConfigEntryState.LOADED entry_dict = async_redact_data(mock_config_entry.as_dict(), TO_REDACT) diff --git a/tests/components/automation/test_blueprint.py b/tests/components/automation/test_blueprint.py index 24d77800508..7e29c134462 100644 --- a/tests/components/automation/test_blueprint.py +++ b/tests/components/automation/test_blueprint.py @@ -8,9 +8,9 @@ from unittest.mock import patch import pytest -from homeassistant import config_entries from homeassistant.components import automation from homeassistant.components.blueprint import models +from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import device_registry as dr from homeassistant.setup import async_setup_component @@ -48,7 +48,7 @@ async def test_notify_leaving_zone( ) -> None: """Test notifying leaving a zone blueprint.""" config_entry = MockConfigEntry(domain="fake_integration", data={}) - config_entry.mock_state(hass, config_entries.ConfigEntryState.LOADED) + config_entry.mock_state(hass, ConfigEntryState.LOADED) config_entry.add_to_hass(hass) device = device_registry.async_get_or_create( diff --git a/tests/components/automation/test_init.py b/tests/components/automation/test_init.py index 3e569586a2a..31e74529777 100644 --- a/tests/components/automation/test_init.py +++ b/tests/components/automation/test_init.py @@ -8,7 +8,6 @@ from unittest.mock import Mock, patch import pytest -from homeassistant import config_entries from homeassistant.components import automation from homeassistant.components.automation import ( ATTR_SOURCE, @@ -18,6 +17,7 @@ from homeassistant.components.automation import ( SERVICE_TRIGGER, AutomationEntity, ) +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_NAME, @@ -1615,7 +1615,7 @@ async def test_extraction_functions( ) -> None: """Test extraction functions.""" config_entry = MockConfigEntry(domain="fake_integration", data={}) - config_entry.mock_state(hass, config_entries.ConfigEntryState.LOADED) + config_entry.mock_state(hass, ConfigEntryState.LOADED) config_entry.add_to_hass(hass) condition_device = device_registry.async_get_or_create( diff --git a/tests/components/axis/test_init.py b/tests/components/axis/test_init.py index 7a22597197b..607508b985a 100644 --- a/tests/components/axis/test_init.py +++ b/tests/components/axis/test_init.py @@ -11,7 +11,7 @@ from homeassistant.core import HomeAssistant async def test_setup_entry(hass: HomeAssistant, setup_config_entry) -> None: """Test successful setup of entry.""" - assert setup_config_entry.state == ConfigEntryState.LOADED + assert setup_config_entry.state is ConfigEntryState.LOADED async def test_setup_entry_fails(hass: HomeAssistant, config_entry) -> None: @@ -24,15 +24,15 @@ async def test_setup_entry_fails(hass: HomeAssistant, config_entry) -> None: assert not await hass.config_entries.async_setup(config_entry.entry_id) - assert config_entry.state == ConfigEntryState.SETUP_ERROR + assert config_entry.state is ConfigEntryState.SETUP_ERROR async def test_unload_entry(hass: HomeAssistant, setup_config_entry) -> None: """Test successful unload of entry.""" - assert setup_config_entry.state == ConfigEntryState.LOADED + assert setup_config_entry.state is ConfigEntryState.LOADED assert await hass.config_entries.async_unload(setup_config_entry.entry_id) - assert setup_config_entry.state == ConfigEntryState.NOT_LOADED + assert setup_config_entry.state is ConfigEntryState.NOT_LOADED @pytest.mark.parametrize("config_entry_version", [1]) @@ -49,5 +49,5 @@ async def test_migrate_entry(hass: HomeAssistant, config_entry) -> None: with patch("homeassistant.components.axis.async_setup_entry", return_value=True): assert await hass.config_entries.async_setup(config_entry.entry_id) - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert config_entry.version == 3 diff --git a/tests/components/azure_devops/test_init.py b/tests/components/azure_devops/test_init.py index 58e3621914d..a35acb375ec 100644 --- a/tests/components/azure_devops/test_init.py +++ b/tests/components/azure_devops/test_init.py @@ -24,12 +24,12 @@ async def test_load_unload_entry( assert mock_devops_client.authorize.call_count == 1 assert mock_devops_client.get_builds.call_count == 2 - assert mock_config_entry.state == ConfigEntryState.LOADED + assert mock_config_entry.state is ConfigEntryState.LOADED await hass.config_entries.async_remove(mock_config_entry.entry_id) await hass.async_block_till_done() - assert mock_config_entry.state == ConfigEntryState.NOT_LOADED + assert mock_config_entry.state is ConfigEntryState.NOT_LOADED async def test_auth_failed( @@ -45,7 +45,7 @@ async def test_auth_failed( assert not mock_devops_client.authorized - assert mock_config_entry.state == ConfigEntryState.SETUP_ERROR + assert mock_config_entry.state is ConfigEntryState.SETUP_ERROR async def test_update_failed( @@ -60,7 +60,7 @@ async def test_update_failed( assert mock_devops_client.get_builds.call_count == 1 - assert mock_config_entry.state == ConfigEntryState.SETUP_RETRY + assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY async def test_no_builds( @@ -75,4 +75,4 @@ async def test_no_builds( assert mock_devops_client.get_builds.call_count == 1 - assert mock_config_entry.state == ConfigEntryState.SETUP_RETRY + assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY diff --git a/tests/components/azure_event_hub/conftest.py b/tests/components/azure_event_hub/conftest.py index 622b11000d7..99bf054dbb1 100644 --- a/tests/components/azure_event_hub/conftest.py +++ b/tests/components/azure_event_hub/conftest.py @@ -52,7 +52,7 @@ async def mock_entry_fixture(hass, filter_schema, mock_create_batch, mock_send_b assert await async_setup_component( hass, DOMAIN, {DOMAIN: {CONF_FILTER: filter_schema}} ) - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED # Clear the component_loaded event from the queue. async_fire_time_changed( @@ -70,7 +70,7 @@ async def mock_entry_fixture(hass, filter_schema, mock_create_batch, mock_send_b @pytest.fixture(name="entry_with_one_event") async def mock_entry_with_one_event(hass, entry): """Use the entry and add a single test event to the queue.""" - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED hass.states.async_set("sensor.test", STATE_ON) return entry diff --git a/tests/components/azure_event_hub/test_init.py b/tests/components/azure_event_hub/test_init.py index 0d5cfff80e9..1440bc2ede9 100644 --- a/tests/components/azure_event_hub/test_init.py +++ b/tests/components/azure_event_hub/test_init.py @@ -69,7 +69,7 @@ async def test_unload_entry(hass: HomeAssistant, entry, mock_create_batch) -> No """ assert await hass.config_entries.async_unload(entry.entry_id) mock_create_batch.add.assert_not_called() - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED async def test_failed_test_connection( @@ -85,7 +85,7 @@ async def test_failed_test_connection( entry.add_to_hass(hass) mock_get_eventhub_properties.side_effect = EventHubError("Test") await hass.config_entries.async_setup(entry.entry_id) - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY async def test_send_batch_error( diff --git a/tests/components/baf/test_init.py b/tests/components/baf/test_init.py index f2616fdd96d..9de2fc03ed0 100644 --- a/tests/components/baf/test_init.py +++ b/tests/components/baf/test_init.py @@ -37,7 +37,7 @@ async def test_config_entry_wrong_uuid( with _patch_device_init(DeviceUUIDMismatchError): await async_setup_component(hass, DOMAIN, {DOMAIN: {}}) await hass.async_block_till_done() - assert already_migrated_config_entry.state == ConfigEntryState.SETUP_RETRY + assert already_migrated_config_entry.state is ConfigEntryState.SETUP_RETRY assert ( "Unexpected device found at 127.0.0.1; expected 12340, found 1234" in caplog.text diff --git a/tests/components/balboa/test_init.py b/tests/components/balboa/test_init.py index 867339c56ef..ecbadac0c09 100644 --- a/tests/components/balboa/test_init.py +++ b/tests/components/balboa/test_init.py @@ -16,9 +16,9 @@ async def test_setup_entry( hass: HomeAssistant, client: MagicMock, integration: MockConfigEntry ) -> None: """Validate that setup entry also configure the client.""" - assert integration.state == ConfigEntryState.LOADED + assert integration.state is ConfigEntryState.LOADED await hass.config_entries.async_unload(integration.entry_id) - assert integration.state == ConfigEntryState.NOT_LOADED + assert integration.state is ConfigEntryState.NOT_LOADED async def test_setup_entry_fails(hass: HomeAssistant, client: MagicMock) -> None: @@ -36,7 +36,7 @@ async def test_setup_entry_fails(hass: HomeAssistant, client: MagicMock) -> None await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY client.connect.return_value = True client.async_configuration_loaded.return_value = False @@ -44,4 +44,4 @@ async def test_setup_entry_fails(hass: HomeAssistant, client: MagicMock) -> None await hass.config_entries.async_reload(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY diff --git a/tests/components/blebox/test_config_flow.py b/tests/components/blebox/test_config_flow.py index 7213b33555c..fd6d0ce8fb2 100644 --- a/tests/components/blebox/test_config_flow.py +++ b/tests/components/blebox/test_config_flow.py @@ -9,6 +9,7 @@ import pytest from homeassistant import config_entries from homeassistant.components import zeroconf from homeassistant.components.blebox import config_flow +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import CONF_IP_ADDRESS from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -203,7 +204,7 @@ async def test_async_setup_entry(hass: HomeAssistant, valid_feature_mock) -> Non await hass.async_block_till_done() assert hass.config_entries.async_entries() == [config] - assert config.state is config_entries.ConfigEntryState.LOADED + assert config.state is ConfigEntryState.LOADED async def test_async_remove_entry(hass: HomeAssistant, valid_feature_mock) -> None: @@ -219,7 +220,7 @@ async def test_async_remove_entry(hass: HomeAssistant, valid_feature_mock) -> No await hass.async_block_till_done() assert hass.config_entries.async_entries() == [] - assert config.state is config_entries.ConfigEntryState.NOT_LOADED + assert config.state is ConfigEntryState.NOT_LOADED async def test_flow_with_zeroconf(hass: HomeAssistant) -> None: diff --git a/tests/components/blue_current/test_init.py b/tests/components/blue_current/test_init.py index 06cc6b27c26..723dd993006 100644 --- a/tests/components/blue_current/test_init.py +++ b/tests/components/blue_current/test_init.py @@ -41,11 +41,11 @@ async def test_load_unload_entry( config_entry.add_to_hass(hass) await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.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 == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED @pytest.mark.parametrize( diff --git a/tests/components/bluetooth/test_init.py b/tests/components/bluetooth/test_init.py index e9198362d8f..65962ac8f21 100644 --- a/tests/components/bluetooth/test_init.py +++ b/tests/components/bluetooth/test_init.py @@ -288,14 +288,14 @@ async def test_setup_and_retry_adapter_not_yet_available( assert "Failed to start Bluetooth" in caplog.text assert len(bluetooth.async_discovered_service_info(hass)) == 0 - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY with patch( "habluetooth.scanner.OriginalBleakScanner.start", ): async_fire_time_changed(hass, dt_util.utcnow() + timedelta(minutes=10)) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED with patch( "habluetooth.scanner.OriginalBleakScanner.stop", @@ -327,7 +327,7 @@ async def test_no_race_during_manual_reload_in_retry_state( assert "Failed to start Bluetooth" in caplog.text assert len(bluetooth.async_discovered_service_info(hass)) == 0 - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY with patch( "habluetooth.scanner.OriginalBleakScanner.start", @@ -335,7 +335,7 @@ async def test_no_race_during_manual_reload_in_retry_state( await hass.config_entries.async_reload(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED with patch( "habluetooth.scanner.OriginalBleakScanner.stop", @@ -2866,7 +2866,7 @@ async def test_three_adapters_one_missing( entry.add_to_hass(hass) assert not await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY async def test_auto_detect_bluetooth_adapters_linux( diff --git a/tests/components/bluetooth/test_scanner.py b/tests/components/bluetooth/test_scanner.py index 504122fb671..523364e0dfd 100644 --- a/tests/components/bluetooth/test_scanner.py +++ b/tests/components/bluetooth/test_scanner.py @@ -48,7 +48,7 @@ async def test_config_entry_can_be_reloaded_when_stop_raises( ) -> None: """Test we can reload if stopping the scanner raises.""" entry = hass.config_entries.async_entries(bluetooth.DOMAIN)[0] - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED with patch( "habluetooth.scanner.OriginalBleakScanner.stop", @@ -57,7 +57,7 @@ async def test_config_entry_can_be_reloaded_when_stop_raises( await hass.config_entries.async_reload(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert "Error stopping scanner" in caplog.text diff --git a/tests/components/bring/test_init.py b/tests/components/bring/test_init.py index 6bf9fd1cb54..8604648d916 100644 --- a/tests/components/bring/test_init.py +++ b/tests/components/bring/test_init.py @@ -37,10 +37,10 @@ async def test_load_unload( entries = hass.config_entries.async_entries(DOMAIN) assert len(entries) == 1 - assert bring_config_entry.state == ConfigEntryState.LOADED + assert bring_config_entry.state is ConfigEntryState.LOADED assert await hass.config_entries.async_unload(bring_config_entry.entry_id) - assert bring_config_entry.state == ConfigEntryState.NOT_LOADED + assert bring_config_entry.state is ConfigEntryState.NOT_LOADED @pytest.mark.parametrize( diff --git a/tests/components/caldav/test_init.py b/tests/components/caldav/test_init.py index 192c18ef81a..f49b1275dca 100644 --- a/tests/components/caldav/test_init.py +++ b/tests/components/caldav/test_init.py @@ -23,15 +23,15 @@ async def test_load_unload( config_entry: MockConfigEntry, ) -> None: """Test loading and unloading of the config entry.""" - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED with patch("homeassistant.components.caldav.config_flow.caldav.DAVClient"): await hass.config_entries.async_setup(config_entry.entry_id) - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert await hass.config_entries.async_unload(config_entry.entry_id) - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED @pytest.mark.parametrize( @@ -57,7 +57,7 @@ async def test_client_failure( ) -> None: """Test CalDAV client failures in setup.""" - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED with patch( "homeassistant.components.caldav.config_flow.caldav.DAVClient" diff --git a/tests/components/coinbase/test_init.py b/tests/components/coinbase/test_init.py index 5af762f557a..99b6bb4a9bd 100644 --- a/tests/components/coinbase/test_init.py +++ b/tests/components/coinbase/test_init.py @@ -2,13 +2,13 @@ from unittest.mock import patch -from homeassistant import config_entries from homeassistant.components.coinbase.const import ( API_TYPE_VAULT, CONF_CURRENCIES, CONF_EXCHANGE_RATES, DOMAIN, ) +from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er @@ -45,12 +45,12 @@ async def test_unload_entry(hass: HomeAssistant) -> None: entry = await init_mock_coinbase(hass) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert entry.state == config_entries.ConfigEntryState.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 == config_entries.ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED assert not hass.data.get(DOMAIN) diff --git a/tests/components/daikin/test_init.py b/tests/components/daikin/test_init.py index 01b21ebb6fd..d7d754dacd2 100644 --- a/tests/components/daikin/test_init.py +++ b/tests/components/daikin/test_init.py @@ -212,7 +212,7 @@ async def test_client_connection_error(hass: HomeAssistant, mock_daikin) -> None await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY async def test_timeout_error(hass: HomeAssistant, mock_daikin) -> None: @@ -228,4 +228,4 @@ async def test_timeout_error(hass: HomeAssistant, mock_daikin) -> None: await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY diff --git a/tests/components/device_automation/test_init.py b/tests/components/device_automation/test_init.py index 32e624f1c8c..ac5e490b738 100644 --- a/tests/components/device_automation/test_init.py +++ b/tests/components/device_automation/test_init.py @@ -7,13 +7,14 @@ import pytest from pytest_unordered import unordered import voluptuous as vol -from homeassistant import config_entries, loader +from homeassistant import loader from homeassistant.components import automation, device_automation from homeassistant.components.device_automation import ( InvalidDeviceAutomationConfig, toggle_entity, ) from homeassistant.components.websocket_api.const import TYPE_RESULT +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant from homeassistant.helpers import device_registry as dr, entity_registry as er @@ -976,7 +977,7 @@ async def test_automation_with_dynamically_validated_action( module.async_validate_action_config = AsyncMock() config_entry = MockConfigEntry(domain="fake_integration", data={}) - config_entry.mock_state(hass, config_entries.ConfigEntryState.LOADED) + config_entry.mock_state(hass, ConfigEntryState.LOADED) config_entry.add_to_hass(hass) device_entry = device_registry.async_get_or_create( config_entry_id=config_entry.entry_id, @@ -1078,7 +1079,7 @@ async def test_automation_with_dynamically_validated_condition( module.async_validate_condition_config = AsyncMock() config_entry = MockConfigEntry(domain="fake_integration", data={}) - config_entry.mock_state(hass, config_entries.ConfigEntryState.LOADED) + config_entry.mock_state(hass, ConfigEntryState.LOADED) config_entry.add_to_hass(hass) device_entry = device_registry.async_get_or_create( config_entry_id=config_entry.entry_id, @@ -1192,7 +1193,7 @@ async def test_automation_with_dynamically_validated_trigger( module.async_validate_trigger_config = AsyncMock(wraps=lambda hass, config: config) config_entry = MockConfigEntry(domain="fake_integration", data={}) - config_entry.mock_state(hass, config_entries.ConfigEntryState.LOADED) + config_entry.mock_state(hass, ConfigEntryState.LOADED) config_entry.add_to_hass(hass) device_entry = device_registry.async_get_or_create( config_entry_id=config_entry.entry_id, @@ -1293,7 +1294,7 @@ async def test_automation_with_bad_action( ) -> None: """Test automation with bad device action.""" config_entry = MockConfigEntry(domain="fake_integration", data={}) - config_entry.mock_state(hass, config_entries.ConfigEntryState.LOADED) + config_entry.mock_state(hass, ConfigEntryState.LOADED) config_entry.add_to_hass(hass) device_registry.async_get_or_create( config_entry_id=config_entry.entry_id, @@ -1327,7 +1328,7 @@ async def test_automation_with_bad_condition_action( ) -> None: """Test automation with bad device action.""" config_entry = MockConfigEntry(domain="fake_integration", data={}) - config_entry.mock_state(hass, config_entries.ConfigEntryState.LOADED) + config_entry.mock_state(hass, ConfigEntryState.LOADED) config_entry.add_to_hass(hass) device_registry.async_get_or_create( config_entry_id=config_entry.entry_id, @@ -1360,7 +1361,7 @@ async def test_automation_with_bad_condition( ) -> None: """Test automation with bad device condition.""" config_entry = MockConfigEntry(domain="fake_integration", data={}) - config_entry.mock_state(hass, config_entries.ConfigEntryState.LOADED) + config_entry.mock_state(hass, ConfigEntryState.LOADED) config_entry.add_to_hass(hass) device_registry.async_get_or_create( config_entry_id=config_entry.entry_id, @@ -1525,7 +1526,7 @@ async def test_automation_with_bad_sub_condition( ) -> None: """Test automation with bad device condition under and/or conditions.""" config_entry = MockConfigEntry(domain="fake_integration", data={}) - config_entry.mock_state(hass, config_entries.ConfigEntryState.LOADED) + config_entry.mock_state(hass, ConfigEntryState.LOADED) config_entry.add_to_hass(hass) device_registry.async_get_or_create( config_entry_id=config_entry.entry_id, @@ -1563,7 +1564,7 @@ async def test_automation_with_bad_trigger( ) -> None: """Test automation with bad device trigger.""" config_entry = MockConfigEntry(domain="fake_integration", data={}) - config_entry.mock_state(hass, config_entries.ConfigEntryState.LOADED) + config_entry.mock_state(hass, ConfigEntryState.LOADED) config_entry.add_to_hass(hass) device_registry.async_get_or_create( config_entry_id=config_entry.entry_id, diff --git a/tests/components/device_tracker/test_config_entry.py b/tests/components/device_tracker/test_config_entry.py index 6a1731d5a77..077e964f0af 100644 --- a/tests/components/device_tracker/test_config_entry.py +++ b/tests/components/device_tracker/test_config_entry.py @@ -336,14 +336,14 @@ async def test_load_unload_entry( ) -> None: """Test loading and unloading a config entry with a device tracker entity.""" config_entry = await create_mock_platform(hass, config_entry, [tracker_entity]) - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED state = hass.states.get(entity_id) assert state assert await hass.config_entries.async_unload(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED state = hass.states.get(entity_id) assert not state @@ -436,7 +436,7 @@ async def test_tracker_entity_state( ) -> None: """Test tracker entity state and state attributes.""" config_entry = await create_mock_platform(hass, config_entry, [tracker_entity]) - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED hass.states.async_set( "zone.home", "0", @@ -482,7 +482,7 @@ async def test_scanner_entity_state( ) config_entry = await create_mock_platform(hass, config_entry, [scanner_entity]) - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED entity_state = hass.states.get(entity_id) assert entity_state diff --git a/tests/components/devolo_home_control/test_diagnostics.py b/tests/components/devolo_home_control/test_diagnostics.py index e31bc360845..f52a9d49017 100644 --- a/tests/components/devolo_home_control/test_diagnostics.py +++ b/tests/components/devolo_home_control/test_diagnostics.py @@ -32,7 +32,7 @@ async def test_entry_diagnostics( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED result = await get_diagnostics_for_config_entry(hass, hass_client, entry) assert result == snapshot diff --git a/tests/components/devolo_home_network/test_diagnostics.py b/tests/components/devolo_home_network/test_diagnostics.py index 75794250908..a3580cac954 100644 --- a/tests/components/devolo_home_network/test_diagnostics.py +++ b/tests/components/devolo_home_network/test_diagnostics.py @@ -25,7 +25,7 @@ async def test_entry_diagnostics( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED result = await get_diagnostics_for_config_entry(hass, hass_client, entry) assert result == snapshot diff --git a/tests/components/dlink/test_init.py b/tests/components/dlink/test_init.py index 484927340fa..43055b681e0 100644 --- a/tests/components/dlink/test_init.py +++ b/tests/components/dlink/test_init.py @@ -19,7 +19,7 @@ async def test_setup_config_and_unload( await setup_integration() entry = hass.config_entries.async_entries(DOMAIN)[0] - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert entry.data == CONF_DATA @@ -37,7 +37,7 @@ async def test_legacy_setup_config_and_unload( await setup_integration_legacy() entry = hass.config_entries.async_entries(DOMAIN)[0] - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert entry.data == CONF_DATA @@ -56,7 +56,7 @@ async def test_async_setup_entry_not_ready( """Test that it throws ConfigEntryNotReady when exception occurs during legacy setup.""" with patch_setup(mocked_plug_legacy_no_auth): await hass.config_entries.async_setup(config_entry_with_uid.entry_id) - assert config_entry_with_uid.state == ConfigEntryState.SETUP_RETRY + assert config_entry_with_uid.state is ConfigEntryState.SETUP_RETRY async def test_device_info( diff --git a/tests/components/dnsip/test_config_flow.py b/tests/components/dnsip/test_config_flow.py index 29c8d81dd2d..ff089be0e1e 100644 --- a/tests/components/dnsip/test_config_flow.py +++ b/tests/components/dnsip/test_config_flow.py @@ -17,6 +17,7 @@ from homeassistant.components.dnsip.const import ( CONF_RESOLVER_IPV6, DOMAIN, ) +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import CONF_NAME from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -227,7 +228,7 @@ async def test_options_flow(hass: HomeAssistant) -> None: "resolver_ipv6": "2001:4860:4860::8888", } - assert entry.state == config_entries.ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED async def test_options_flow_empty_return(hass: HomeAssistant) -> None: diff --git a/tests/components/dnsip/test_init.py b/tests/components/dnsip/test_init.py index 37595444c44..3d816bebe60 100644 --- a/tests/components/dnsip/test_init.py +++ b/tests/components/dnsip/test_init.py @@ -4,7 +4,6 @@ from __future__ import annotations from unittest.mock import patch -from homeassistant import config_entries from homeassistant.components.dnsip.const import ( CONF_HOSTNAME, CONF_IPV4, @@ -13,7 +12,7 @@ from homeassistant.components.dnsip.const import ( CONF_RESOLVER_IPV6, DOMAIN, ) -from homeassistant.config_entries import SOURCE_USER +from homeassistant.config_entries import SOURCE_USER, ConfigEntryState from homeassistant.const import CONF_NAME from homeassistant.core import HomeAssistant @@ -49,7 +48,7 @@ async def test_load_unload_entry(hass: HomeAssistant) -> None: await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == config_entries.ConfigEntryState.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 is config_entries.ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED diff --git a/tests/components/dremel_3d_printer/test_init.py b/tests/components/dremel_3d_printer/test_init.py index 8216054587d..6b008c7fac1 100644 --- a/tests/components/dremel_3d_printer/test_init.py +++ b/tests/components/dremel_3d_printer/test_init.py @@ -27,7 +27,7 @@ async def test_setup( with patch(MOCKED_MODEL, return_value=model) as mock: await hass.config_entries.async_setup(config_entry.entry_id) assert await async_setup_component(hass, DOMAIN, {}) - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert mock.called with patch(MOCKED_MODEL, return_value=model) as mock: @@ -50,7 +50,7 @@ async def test_async_setup_entry_not_ready( await hass.config_entries.async_setup(config_entry.entry_id) assert await async_setup_component(hass, DOMAIN, {}) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY assert not hass.data.get(DOMAIN) @@ -60,7 +60,7 @@ async def test_update_failed( """Test coordinator throws UpdateFailed after failed update.""" await hass.config_entries.async_setup(config_entry.entry_id) assert await async_setup_component(hass, DOMAIN, {}) - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED with patch( "homeassistant.components.dremel_3d_printer.Dremel3DPrinter.refresh", diff --git a/tests/components/dsmr/test_sensor.py b/tests/components/dsmr/test_sensor.py index f63422e0543..7a38e3010d8 100644 --- a/tests/components/dsmr/test_sensor.py +++ b/tests/components/dsmr/test_sensor.py @@ -13,13 +13,13 @@ from unittest.mock import DEFAULT, MagicMock import pytest -from homeassistant import config_entries from homeassistant.components.sensor import ( ATTR_OPTIONS, ATTR_STATE_CLASS, SensorDeviceClass, SensorStateClass, ) +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import ( ATTR_DEVICE_CLASS, ATTR_FRIENDLY_NAME, @@ -1325,7 +1325,7 @@ async def test_reconnect(hass: HomeAssistant, dsmr_connection_fixture) -> None: await hass.config_entries.async_unload(mock_entry.entry_id) - assert mock_entry.state == config_entries.ConfigEntryState.NOT_LOADED + assert mock_entry.state is ConfigEntryState.NOT_LOADED async def test_gas_meter_providing_energy_reading( diff --git a/tests/components/dwd_weather_warnings/test_init.py b/tests/components/dwd_weather_warnings/test_init.py index 6967f2ca6b1..db7afaadec9 100644 --- a/tests/components/dwd_weather_warnings/test_init.py +++ b/tests/components/dwd_weather_warnings/test_init.py @@ -28,7 +28,7 @@ async def test_load_unload_entry(hass: HomeAssistant) -> None: await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert entry.entry_id in hass.data[DOMAIN] assert await hass.config_entries.async_unload(entry.entry_id) diff --git a/tests/components/dynalite/test_config_flow.py b/tests/components/dynalite/test_config_flow.py index bdbd03faa22..2b56786e4e0 100644 --- a/tests/components/dynalite/test_config_flow.py +++ b/tests/components/dynalite/test_config_flow.py @@ -6,6 +6,7 @@ import pytest from homeassistant import config_entries from homeassistant.components import dynalite +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import CONF_PORT from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -21,9 +22,9 @@ from tests.common import MockConfigEntry @pytest.mark.parametrize( ("first_con", "second_con", "exp_type", "exp_result", "exp_reason"), [ - (True, True, "create_entry", config_entries.ConfigEntryState.LOADED, ""), + (True, True, "create_entry", ConfigEntryState.LOADED, ""), (False, False, "abort", None, "cannot_connect"), - (True, False, "create_entry", config_entries.ConfigEntryState.SETUP_RETRY, ""), + (True, False, "create_entry", ConfigEntryState.SETUP_RETRY, ""), ], ) async def test_flow( @@ -138,7 +139,7 @@ async def test_two_entries(hass: HomeAssistant) -> None: data={dynalite.CONF_HOST: host2}, ) assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["result"].state == config_entries.ConfigEntryState.LOADED + assert result["result"].state is ConfigEntryState.LOADED async def test_setup_user(hass): @@ -163,7 +164,7 @@ async def test_setup_user(hass): ) assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["result"].state == config_entries.ConfigEntryState.LOADED + assert result["result"].state is ConfigEntryState.LOADED assert result["title"] == host assert result["data"] == { "host": host, diff --git a/tests/components/eafm/test_sensor.py b/tests/components/eafm/test_sensor.py index 380e1df5f37..082c4e08908 100644 --- a/tests/components/eafm/test_sensor.py +++ b/tests/components/eafm/test_sensor.py @@ -5,7 +5,7 @@ import datetime import aiohttp import pytest -from homeassistant import config_entries +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, STATE_UNAVAILABLE from homeassistant.core import HomeAssistant from homeassistant.setup import async_setup_component @@ -37,7 +37,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 is config_entries.ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED await hass.async_block_till_done() async def poll(value): diff --git a/tests/components/efergy/test_init.py b/tests/components/efergy/test_init.py index 5c72e1a5cfd..151cd50fbc6 100644 --- a/tests/components/efergy/test_init.py +++ b/tests/components/efergy/test_init.py @@ -16,7 +16,7 @@ from tests.test_util.aiohttp import AiohttpClientMocker async def test_setup(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker) -> None: """Test unload.""" entry = await init_integration(hass, aioclient_mock) - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert await hass.config_entries.async_unload(entry.entry_id) await hass.async_block_till_done() @@ -32,7 +32,7 @@ async def test_async_setup_entry_not_ready(hass: HomeAssistant) -> None: efergymock.side_effect = (exceptions.ConnectError, exceptions.DataError) await hass.config_entries.async_setup(entry.entry_id) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY assert not hass.data.get(DOMAIN) @@ -43,7 +43,7 @@ async def test_async_setup_entry_auth_failed(hass: HomeAssistant) -> None: efergymock.side_effect = exceptions.InvalidAuth await hass.config_entries.async_setup(entry.entry_id) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert entry.state == ConfigEntryState.SETUP_ERROR + assert entry.state is ConfigEntryState.SETUP_ERROR assert not hass.data.get(DOMAIN) diff --git a/tests/components/energenie_power_sockets/test_init.py b/tests/components/energenie_power_sockets/test_init.py index a60949c34cc..4e2fe51665b 100644 --- a/tests/components/energenie_power_sockets/test_init.py +++ b/tests/components/energenie_power_sockets/test_init.py @@ -23,7 +23,7 @@ async def test_load_unload_entry( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert entry.entry_id in hass.data[DOMAIN] assert await hass.config_entries.async_unload(entry.entry_id) diff --git a/tests/components/energenie_power_sockets/test_switch.py b/tests/components/energenie_power_sockets/test_switch.py index b98a3e07f56..4cd2bd60028 100644 --- a/tests/components/energenie_power_sockets/test_switch.py +++ b/tests/components/energenie_power_sockets/test_switch.py @@ -117,7 +117,7 @@ async def test_switch_setup( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert entry.entry_id in hass.data[DOMAIN] state = hass.states.get(f"switch.{entity_name}") diff --git a/tests/components/esphome/test_dashboard.py b/tests/components/esphome/test_dashboard.py index e6fca268880..01c1553cf42 100644 --- a/tests/components/esphome/test_dashboard.py +++ b/tests/components/esphome/test_dashboard.py @@ -60,7 +60,7 @@ async def test_restore_dashboard_storage_end_to_end( ) as mock_dashboard_api: await hass.config_entries.async_setup(mock_config_entry.entry_id) await hass.async_block_till_done() - assert mock_config_entry.state == ConfigEntryState.LOADED + assert mock_config_entry.state is ConfigEntryState.LOADED assert mock_dashboard_api.mock_calls[0][1][0] == "http://new-host:6052" @@ -74,7 +74,7 @@ async def test_setup_dashboard_fails( await hass.config_entries.async_setup(mock_config_entry.entry_id) await hass.async_block_till_done() await dashboard.async_set_dashboard_info(hass, "test-slug", "test-host", 6052) - assert mock_config_entry.state == ConfigEntryState.LOADED + assert mock_config_entry.state is ConfigEntryState.LOADED assert mock_get_devices.call_count == 1 # The dashboard addon might recover later so we still @@ -109,7 +109,7 @@ async def test_setup_dashboard_fails_when_already_setup( await dashboard.async_set_dashboard_info(hass, "test-slug", "test-host", 6052) await hass.async_block_till_done() - assert mock_config_entry.state == ConfigEntryState.LOADED + assert mock_config_entry.state is ConfigEntryState.LOADED assert mock_get_devices.call_count == 1 # We still setup, and reload, but we do not do the reauths assert dashboard.STORAGE_KEY in hass_storage @@ -120,7 +120,7 @@ async def test_new_info_reload_config_entries( hass: HomeAssistant, init_integration, mock_dashboard ) -> None: """Test config entries are reloaded when new info is set.""" - assert init_integration.state == ConfigEntryState.LOADED + assert init_integration.state is ConfigEntryState.LOADED with patch("homeassistant.components.esphome.async_setup_entry") as mock_setup: await dashboard.async_set_dashboard_info(hass, "test-slug", "test-host", 6052) diff --git a/tests/components/evil_genius_labs/test_init.py b/tests/components/evil_genius_labs/test_init.py index 71b8a6164a6..10b773ead61 100644 --- a/tests/components/evil_genius_labs/test_init.py +++ b/tests/components/evil_genius_labs/test_init.py @@ -2,8 +2,8 @@ import pytest -from homeassistant import config_entries from homeassistant.components.evil_genius_labs import PLATFORMS +from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant @@ -14,4 +14,4 @@ async def test_setup_unload_entry( """Test setting up and unloading a config entry.""" assert len(hass.states.async_entity_ids()) == 1 assert await hass.config_entries.async_unload(config_entry.entry_id) - assert config_entry.state == config_entries.ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED diff --git a/tests/components/fastdotcom/test_init.py b/tests/components/fastdotcom/test_init.py index 12e3902d874..c17b455057b 100644 --- a/tests/components/fastdotcom/test_init.py +++ b/tests/components/fastdotcom/test_init.py @@ -6,8 +6,8 @@ from unittest.mock import patch from freezegun.api import FrozenDateTimeFactory -from homeassistant import config_entries from homeassistant.components.fastdotcom.const import DEFAULT_NAME, DOMAIN +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import EVENT_HOMEASSISTANT_STARTED, STATE_UNKNOWN from homeassistant.core import CoreState, HomeAssistant from homeassistant.helpers import issue_registry as ir @@ -31,10 +31,10 @@ async def test_unload_entry(hass: HomeAssistant) -> None: await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == config_entries.ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert await hass.config_entries.async_unload(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state is config_entries.ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED async def test_from_import(hass: HomeAssistant) -> None: @@ -72,7 +72,7 @@ async def test_delayed_speedtest_during_startup( await hass.async_block_till_done() hass.set_state(original_state) - assert config_entry.state == config_entries.ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED state = hass.states.get("sensor.fast_com_download") # Assert state is Unknown as fast.com isn't starting until HA has started assert state.state is STATE_UNKNOWN @@ -87,7 +87,7 @@ async def test_delayed_speedtest_during_startup( assert state is not None assert state.state == "5.0" - assert config_entry.state == config_entries.ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED async def test_service_deprecated( diff --git a/tests/components/fitbit/test_init.py b/tests/components/fitbit/test_init.py index 74312348af1..a4794a63162 100644 --- a/tests/components/fitbit/test_init.py +++ b/tests/components/fitbit/test_init.py @@ -34,15 +34,15 @@ async def test_setup( setup_credentials: None, ) -> None: """Test setting up the integration.""" - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED assert await integration_setup() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert await hass.config_entries.async_unload(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED @pytest.mark.parametrize( @@ -68,7 +68,7 @@ async def test_token_refresh_failure( ) assert not await integration_setup() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY @pytest.mark.parametrize("token_expiration_time", [12345]) @@ -88,7 +88,7 @@ async def test_token_refresh_success( ) assert await integration_setup() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED # Verify token request assert len(aioclient_mock.mock_calls) == 1 @@ -132,7 +132,7 @@ async def test_token_requires_reauth( ) assert not await integration_setup() - assert config_entry.state == ConfigEntryState.SETUP_ERROR + assert config_entry.state is ConfigEntryState.SETUP_ERROR flows = hass.config_entries.flow.async_progress() assert len(flows) == 1 @@ -147,7 +147,7 @@ async def test_device_update_coordinator_failure( requests_mock: Mocker, ) -> None: """Test case where the device update coordinator fails on the first request.""" - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED requests_mock.register_uri( "GET", @@ -156,7 +156,7 @@ async def test_device_update_coordinator_failure( ) assert not await integration_setup() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY async def test_device_update_coordinator_reauth( @@ -167,7 +167,7 @@ async def test_device_update_coordinator_reauth( requests_mock: Mocker, ) -> None: """Test case where the device update coordinator fails on the first request.""" - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED requests_mock.register_uri( "GET", @@ -179,7 +179,7 @@ async def test_device_update_coordinator_reauth( ) assert not await integration_setup() - assert config_entry.state == ConfigEntryState.SETUP_ERROR + assert config_entry.state is ConfigEntryState.SETUP_ERROR flows = hass.config_entries.flow.async_progress() assert len(flows) == 1 diff --git a/tests/components/flexit_bacnet/test_init.py b/tests/components/flexit_bacnet/test_init.py index 0741120c1ad..4ff52a3bcfc 100644 --- a/tests/components/flexit_bacnet/test_init.py +++ b/tests/components/flexit_bacnet/test_init.py @@ -18,7 +18,7 @@ async def test_loading_and_unloading_config_entry( await setup_with_selected_platforms(hass, mock_config_entry, [Platform.CLIMATE]) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert mock_config_entry.state == ConfigEntryState.LOADED + assert mock_config_entry.state is ConfigEntryState.LOADED assert await hass.config_entries.async_unload(mock_config_entry.entry_id) await hass.async_block_till_done() @@ -33,4 +33,4 @@ async def test_failed_initialization( mock_flexit_bacnet.update.side_effect = DecodingError mock_config_entry.add_to_hass(hass) assert not await hass.config_entries.async_setup(mock_config_entry.entry_id) - assert mock_config_entry.state == ConfigEntryState.SETUP_RETRY + assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY diff --git a/tests/components/flipr/test_init.py b/tests/components/flipr/test_init.py index 8300ac185ba..6a49b5b7200 100644 --- a/tests/components/flipr/test_init.py +++ b/tests/components/flipr/test_init.py @@ -26,4 +26,4 @@ async def test_unload_entry(hass: HomeAssistant) -> None: 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 == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED diff --git a/tests/components/flux_led/test_init.py b/tests/components/flux_led/test_init.py index a42ba5dff37..8e3bb03dca2 100644 --- a/tests/components/flux_led/test_init.py +++ b/tests/components/flux_led/test_init.py @@ -98,10 +98,10 @@ async def test_config_entry_reload(hass: HomeAssistant) -> None: with _patch_discovery(), _patch_wifibulb(): await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}}) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.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 == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED async def test_config_entry_retry(hass: HomeAssistant) -> None: @@ -113,7 +113,7 @@ async def test_config_entry_retry(hass: HomeAssistant) -> None: with _patch_discovery(no_device=True), _patch_wifibulb(no_device=True): await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}}) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY async def test_config_entry_retry_right_away_on_discovery(hass: HomeAssistant) -> None: @@ -125,7 +125,7 @@ async def test_config_entry_retry_right_away_on_discovery(hass: HomeAssistant) - with _patch_discovery(no_device=True), _patch_wifibulb(no_device=True): await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}}) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY with _patch_discovery(), _patch_wifibulb(): await hass.config_entries.flow.async_init( @@ -134,7 +134,7 @@ async def test_config_entry_retry_right_away_on_discovery(hass: HomeAssistant) - data=DHCP_DISCOVERY, ) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED async def test_coordinator_retry_right_away_on_discovery_already_setup( @@ -152,7 +152,7 @@ async def test_coordinator_retry_right_away_on_discovery_already_setup( await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}}) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED entity_id = "light.bulb_rgbcw_ddeeff" assert entity_registry.async_get(entity_id).unique_id == MAC_ADDRESS @@ -219,7 +219,7 @@ async def test_config_entry_fills_unique_id_with_directed_discovery( ): await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}}) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert config_entry.unique_id == MAC_ADDRESS assert config_entry.title == title @@ -235,7 +235,7 @@ async def test_time_sync_startup_and_next_day(hass: HomeAssistant) -> None: with _patch_discovery(), _patch_wifibulb(device=bulb): await async_setup_component(hass, flux_led.DOMAIN, {flux_led.DOMAIN: {}}) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert len(bulb.async_set_time.mock_calls) == 1 async_fire_time_changed(hass, utcnow() + timedelta(hours=24)) diff --git a/tests/components/forecast_solar/test_energy.py b/tests/components/forecast_solar/test_energy.py index 246ed866506..1ae3c22c870 100644 --- a/tests/components/forecast_solar/test_energy.py +++ b/tests/components/forecast_solar/test_energy.py @@ -25,7 +25,7 @@ async def test_energy_solar_forecast( await hass.config_entries.async_setup(mock_config_entry.entry_id) await hass.async_block_till_done() - assert mock_config_entry.state == ConfigEntryState.LOADED + assert mock_config_entry.state is ConfigEntryState.LOADED assert await energy.async_get_solar_forecast(hass, mock_config_entry.entry_id) == { "wh_hours": { diff --git a/tests/components/forecast_solar/test_init.py b/tests/components/forecast_solar/test_init.py index b581888547d..481ec3c0c9d 100644 --- a/tests/components/forecast_solar/test_init.py +++ b/tests/components/forecast_solar/test_init.py @@ -29,7 +29,7 @@ async def test_load_unload_config_entry( mock_config_entry.add_to_hass(hass) await async_setup_component(hass, "forecast_solar", {}) - assert mock_config_entry.state == ConfigEntryState.LOADED + assert mock_config_entry.state is ConfigEntryState.LOADED await hass.config_entries.async_unload(mock_config_entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/freedompro/test_init.py b/tests/components/freedompro/test_init.py index 58f9c493582..fd8034818b1 100644 --- a/tests/components/freedompro/test_init.py +++ b/tests/components/freedompro/test_init.py @@ -43,7 +43,7 @@ async def test_config_not_ready(hass: HomeAssistant) -> None: ): entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY async def test_unload_entry( @@ -53,9 +53,9 @@ async def test_unload_entry( entry = init_integration assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert entry.state == ConfigEntryState.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 == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED diff --git a/tests/components/fritz/test_button.py b/tests/components/fritz/test_button.py index f6546296d44..14aa46f30a7 100644 --- a/tests/components/fritz/test_button.py +++ b/tests/components/fritz/test_button.py @@ -26,7 +26,7 @@ async def test_button_setup(hass: HomeAssistant, fc_class_mock, fh_class_mock) - await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED buttons = hass.states.async_all(BUTTON_DOMAIN) assert len(buttons) == 4 @@ -57,7 +57,7 @@ async def test_buttons( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED button = hass.states.get(entity_id) assert button @@ -91,7 +91,7 @@ async def test_wol_button( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED button = hass.states.get("button.printer_wake_on_lan") assert button @@ -125,7 +125,7 @@ async def test_wol_button_new_device( mesh_data = copy.deepcopy(MOCK_MESH_DATA) await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert hass.states.get("button.printer_wake_on_lan") assert not hass.states.get("button.server_wake_on_lan") @@ -156,7 +156,7 @@ async def test_wol_button_absent_for_mesh_slave( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED button = hass.states.get("button.printer_wake_on_lan") assert button is None @@ -182,7 +182,7 @@ async def test_wol_button_absent_for_non_lan_device( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED button = hass.states.get("button.printer_wake_on_lan") assert button is None diff --git a/tests/components/fritz/test_diagnostics.py b/tests/components/fritz/test_diagnostics.py index 9dc50cc3378..35d50ff4572 100644 --- a/tests/components/fritz/test_diagnostics.py +++ b/tests/components/fritz/test_diagnostics.py @@ -28,7 +28,7 @@ async def test_entry_diagnostics( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED entry_dict = entry.as_dict() for key in TO_REDACT: diff --git a/tests/components/fritz/test_image.py b/tests/components/fritz/test_image.py index 5d6b9265760..45afe34b6aa 100644 --- a/tests/components/fritz/test_image.py +++ b/tests/components/fritz/test_image.py @@ -105,7 +105,7 @@ async def test_image_entity( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED # test image entity is generated as expected states = hass.states.async_all(IMAGE_DOMAIN) @@ -155,7 +155,7 @@ async def test_image_update( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED client = await hass_client() resp = await client.get("/api/image_proxy/image.mock_title_guestwifi") @@ -191,7 +191,7 @@ async def test_image_update_unavailable( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED state = hass.states.get("image.mock_title_guestwifi") assert state diff --git a/tests/components/fritz/test_init.py b/tests/components/fritz/test_init.py index 0a525192778..be45698e160 100644 --- a/tests/components/fritz/test_init.py +++ b/tests/components/fritz/test_init.py @@ -29,10 +29,10 @@ async def test_setup(hass: HomeAssistant, fc_class_mock, fh_class_mock) -> None: await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED await hass.config_entries.async_unload(entry.entry_id) - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED async def test_options_reload( @@ -53,7 +53,7 @@ async def test_options_reload( ) as mock_reload: await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED result = await hass.config_entries.options.async_init(entry.entry_id) await hass.async_block_till_done() @@ -82,7 +82,7 @@ async def test_setup_auth_fail(hass: HomeAssistant, error) -> None: await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.SETUP_ERROR + assert entry.state is ConfigEntryState.SETUP_ERROR @pytest.mark.parametrize( @@ -102,4 +102,4 @@ async def test_setup_fail(hass: HomeAssistant, error) -> None: await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY diff --git a/tests/components/fritz/test_sensor.py b/tests/components/fritz/test_sensor.py index 37116e66719..f8114238376 100644 --- a/tests/components/fritz/test_sensor.py +++ b/tests/components/fritz/test_sensor.py @@ -107,7 +107,7 @@ async def test_sensor_setup(hass: HomeAssistant, fc_class_mock, fh_class_mock) - await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED sensors = hass.states.async_all(SENSOR_DOMAIN) assert len(sensors) == len(SENSOR_TYPES) diff --git a/tests/components/fritz/test_switch.py b/tests/components/fritz/test_switch.py index 91d2d42106b..adb5c3f6799 100644 --- a/tests/components/fritz/test_switch.py +++ b/tests/components/fritz/test_switch.py @@ -180,7 +180,7 @@ async def test_switch_setup( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED switches = hass.states.async_all(Platform.SWITCH) assert len(switches) == 3 diff --git a/tests/components/fritz/test_update.py b/tests/components/fritz/test_update.py index 991b67e6285..c39dd24de02 100644 --- a/tests/components/fritz/test_update.py +++ b/tests/components/fritz/test_update.py @@ -40,7 +40,7 @@ async def test_update_entities_initialized( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED updates = hass.states.async_all(UPDATE_DOMAIN) assert len(updates) == 1 @@ -61,7 +61,7 @@ async def test_update_available( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED update = hass.states.get("update.mock_title_fritz_os") assert update is not None @@ -84,7 +84,7 @@ async def test_no_update_available( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED update = hass.states.get("update.mock_title_fritz_os") assert update is not None @@ -112,7 +112,7 @@ async def test_available_update_can_be_installed( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED update = hass.states.get("update.mock_title_fritz_os") assert update is not None diff --git a/tests/components/generic/test_config_flow.py b/tests/components/generic/test_config_flow.py index f22bb4d93da..841fb710717 100644 --- a/tests/components/generic/test_config_flow.py +++ b/tests/components/generic/test_config_flow.py @@ -27,6 +27,7 @@ from homeassistant.components.stream import ( CONF_USE_WALLCLOCK_AS_TIMESTAMPS, ) from homeassistant.components.stream.worker import StreamWorkerError +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import ( CONF_AUTHENTICATION, CONF_NAME, @@ -804,11 +805,11 @@ async def test_unload_entry(hass: HomeAssistant, fakeimg_png) -> None: await hass.config_entries.async_setup(mock_entry.entry_id) await hass.async_block_till_done() - assert mock_entry.state is config_entries.ConfigEntryState.LOADED + assert mock_entry.state is ConfigEntryState.LOADED await hass.config_entries.async_unload(mock_entry.entry_id) await hass.async_block_till_done() - assert mock_entry.state is config_entries.ConfigEntryState.NOT_LOADED + assert mock_entry.state is ConfigEntryState.NOT_LOADED async def test_reload_on_title_change(hass: HomeAssistant) -> None: @@ -823,7 +824,7 @@ async def test_reload_on_title_change(hass: HomeAssistant) -> None: await hass.config_entries.async_setup(mock_entry.entry_id) await hass.async_block_till_done() - assert mock_entry.state is config_entries.ConfigEntryState.LOADED + assert mock_entry.state is ConfigEntryState.LOADED assert hass.states.get("camera.my_title").attributes["friendly_name"] == "My Title" hass.config_entries.async_update_entry(mock_entry, title="New Title") diff --git a/tests/components/github/common.py b/tests/components/github/common.py index d850ce1bba8..5007496c9fe 100644 --- a/tests/components/github/common.py +++ b/tests/components/github/common.py @@ -4,8 +4,8 @@ from __future__ import annotations import json -from homeassistant import config_entries from homeassistant.components.github.const import CONF_REPOSITORIES, DOMAIN +from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant from tests.common import MockConfigEntry, load_fixture @@ -50,4 +50,4 @@ async def setup_github_integration( await hass.async_block_till_done() assert setup_result - assert mock_config_entry.state == config_entries.ConfigEntryState.LOADED + assert mock_config_entry.state is ConfigEntryState.LOADED diff --git a/tests/components/glances/test_init.py b/tests/components/glances/test_init.py index aa861dc5518..02fa6960c2f 100644 --- a/tests/components/glances/test_init.py +++ b/tests/components/glances/test_init.py @@ -27,7 +27,7 @@ async def test_successful_config_entry(hass: HomeAssistant) -> None: await hass.config_entries.async_setup(entry.entry_id) - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED async def test_entry_deprecated_version( @@ -45,7 +45,7 @@ async def test_entry_deprecated_version( await hass.config_entries.async_setup(entry.entry_id) - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED issue = issue_registry.async_get_issue(DOMAIN, "deprecated_version") assert issue is not None diff --git a/tests/components/goalzero/test_init.py b/tests/components/goalzero/test_init.py index 1390561785e..1d44c7e808e 100644 --- a/tests/components/goalzero/test_init.py +++ b/tests/components/goalzero/test_init.py @@ -25,7 +25,7 @@ async def test_setup_config_and_unload(hass: HomeAssistant) -> None: with patch("homeassistant.components.goalzero.Yeti", return_value=mocked_yeti): await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert entry.data == CONF_DATA @@ -46,7 +46,7 @@ async def test_setup_config_entry_incorrectly_formatted_mac( with patch("homeassistant.components.goalzero.Yeti", return_value=mocked_yeti): await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert entry.data == CONF_DATA @@ -64,7 +64,7 @@ async def test_async_setup_entry_not_ready(hass: HomeAssistant) -> None: side_effect=exceptions.ConnectError, ): await hass.config_entries.async_setup(entry.entry_id) - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY async def test_update_failed( diff --git a/tests/components/google/test_init.py b/tests/components/google/test_init.py index 319f6be5012..2a26776b031 100644 --- a/tests/components/google/test_init.py +++ b/tests/components/google/test_init.py @@ -116,7 +116,7 @@ async def test_unload_entry( assert entry.state is ConfigEntryState.LOADED assert await hass.config_entries.async_unload(entry.entry_id) - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED @pytest.mark.parametrize( @@ -959,4 +959,4 @@ async def test_remove_entry( assert entry.state is ConfigEntryState.LOADED assert await hass.config_entries.async_remove(entry.entry_id) - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED diff --git a/tests/components/google_tasks/test_init.py b/tests/components/google_tasks/test_init.py index 061bf549748..0abfce87133 100644 --- a/tests/components/google_tasks/test_init.py +++ b/tests/components/google_tasks/test_init.py @@ -30,7 +30,7 @@ async def test_setup( await hass.config_entries.async_unload(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED assert not hass.services.async_services().get(DOMAIN) diff --git a/tests/components/hardkernel/test_init.py b/tests/components/hardkernel/test_init.py index 90717054ead..af01006afba 100644 --- a/tests/components/hardkernel/test_init.py +++ b/tests/components/hardkernel/test_init.py @@ -101,4 +101,4 @@ async def test_setup_entry_wait_hassio(hass: HomeAssistant) -> None: await hass.async_block_till_done() assert len(mock_get_os_info.mock_calls) == 1 - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY diff --git a/tests/components/hassio/test_sensor.py b/tests/components/hassio/test_sensor.py index 82ac3eccdf5..55cec90ec58 100644 --- a/tests/components/hassio/test_sensor.py +++ b/tests/components/hassio/test_sensor.py @@ -14,6 +14,7 @@ from homeassistant.components.hassio import ( HassioAPIError, ) from homeassistant.components.hassio.const import REQUEST_REFRESH_DELAY +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import STATE_UNAVAILABLE from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er @@ -317,7 +318,7 @@ async def test_stats_addon_sensor( freezer.tick(config_entries.RELOAD_AFTER_UPDATE_DELAY) async_fire_time_changed(hass) await hass.async_block_till_done(wait_background_tasks=True) - assert config_entry.state is config_entries.ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED # Verify the entity is still enabled assert entity_registry.async_get(entity_id).disabled_by is None diff --git a/tests/components/holiday/test_init.py b/tests/components/holiday/test_init.py index a044e390a68..38eb51fe925 100644 --- a/tests/components/holiday/test_init.py +++ b/tests/components/holiday/test_init.py @@ -20,10 +20,10 @@ async def test_unload_entry(hass: HomeAssistant) -> None: await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert await hass.config_entries.async_unload(entry.entry_id) await hass.async_block_till_done() state: ConfigEntryState = entry.state - assert state == ConfigEntryState.NOT_LOADED + assert state is ConfigEntryState.NOT_LOADED diff --git a/tests/components/homeassistant_green/test_init.py b/tests/components/homeassistant_green/test_init.py index 0efb449137a..44cd6da136a 100644 --- a/tests/components/homeassistant_green/test_init.py +++ b/tests/components/homeassistant_green/test_init.py @@ -105,4 +105,4 @@ async def test_setup_entry_wait_hassio(hass: HomeAssistant) -> None: await hass.async_block_till_done() assert len(mock_get_os_info.mock_calls) == 1 - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY diff --git a/tests/components/homeassistant_sky_connect/test_init.py b/tests/components/homeassistant_sky_connect/test_init.py index a1fa4a5c743..a6dd5100d7e 100644 --- a/tests/components/homeassistant_sky_connect/test_init.py +++ b/tests/components/homeassistant_sky_connect/test_init.py @@ -299,7 +299,7 @@ async def test_setup_entry_wait_usb(hass: HomeAssistant) -> None: return_value=False, ) as mock_is_plugged_in: await hass.config_entries.async_setup(config_entry.entry_id) - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert len(hass.config_entries.async_entries(DOMAIN)) == 1 # USB discovery starts, config entry should be removed hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED) @@ -340,7 +340,7 @@ async def test_setup_entry_addon_info_fails( ): assert not await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY async def test_setup_entry_addon_not_running( @@ -373,5 +373,5 @@ async def test_setup_entry_addon_not_running( ): assert not await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY start_addon.assert_called_once() diff --git a/tests/components/homeassistant_yellow/test_init.py b/tests/components/homeassistant_yellow/test_init.py index e94dbbc1438..0631c2cb983 100644 --- a/tests/components/homeassistant_yellow/test_init.py +++ b/tests/components/homeassistant_yellow/test_init.py @@ -294,7 +294,7 @@ async def test_setup_entry_wait_hassio(hass: HomeAssistant) -> None: await hass.async_block_till_done() assert len(mock_get_os_info.mock_calls) == 1 - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY async def test_setup_entry_addon_info_fails( @@ -325,7 +325,7 @@ async def test_setup_entry_addon_info_fails( assert not await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY async def test_setup_entry_addon_not_running( @@ -355,5 +355,5 @@ async def test_setup_entry_addon_not_running( assert not await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY start_addon.assert_called_once() diff --git a/tests/components/homekit/test_init.py b/tests/components/homekit/test_init.py index e8fb7e1d92e..7e924be1637 100644 --- a/tests/components/homekit/test_init.py +++ b/tests/components/homekit/test_init.py @@ -126,7 +126,7 @@ async def test_bridge_with_triggers( hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED await hass.config_entries.async_unload(entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/homekit_controller/test_device_trigger.py b/tests/components/homekit_controller/test_device_trigger.py index 239d170a84f..b5a9aee72b1 100644 --- a/tests/components/homekit_controller/test_device_trigger.py +++ b/tests/components/homekit_controller/test_device_trigger.py @@ -370,7 +370,7 @@ async def test_handle_events_late_setup( await hass.config_entries.async_unload(helper.config_entry.entry_id) await hass.async_block_till_done() - assert helper.config_entry.state == ConfigEntryState.NOT_LOADED + assert helper.config_entry.state is ConfigEntryState.NOT_LOADED assert await async_setup_component( hass, @@ -424,7 +424,7 @@ async def test_handle_events_late_setup( await hass.config_entries.async_setup(helper.config_entry.entry_id) await hass.async_block_till_done() - assert helper.config_entry.state == ConfigEntryState.LOADED + assert helper.config_entry.state is ConfigEntryState.LOADED # Make sure first automation (only) fires for single press helper.pairing.testing.update_named_service( diff --git a/tests/components/homekit_controller/test_init.py b/tests/components/homekit_controller/test_init.py index ec3e6216288..59fdf555a50 100644 --- a/tests/components/homekit_controller/test_init.py +++ b/tests/components/homekit_controller/test_init.py @@ -155,13 +155,13 @@ async def test_offline_device_raises(hass: HomeAssistant, controller) -> None: ) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY is_connected = True async_fire_time_changed(hass, utcnow() + timedelta(seconds=10)) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert hass.states.get("light.testdevice").state == STATE_OFF @@ -212,13 +212,13 @@ async def test_ble_device_only_checks_is_available( ) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY is_available = True async_fire_time_changed(hass, utcnow() + timedelta(seconds=10)) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert hass.states.get("light.testdevice").state == STATE_OFF is_available = False diff --git a/tests/components/husqvarna_automower/test_init.py b/tests/components/husqvarna_automower/test_init.py index 3c97a3b2668..dbf1d429eee 100644 --- a/tests/components/husqvarna_automower/test_init.py +++ b/tests/components/husqvarna_automower/test_init.py @@ -31,12 +31,12 @@ async def test_load_unload_entry( await setup_integration(hass, mock_config_entry) entry = hass.config_entries.async_entries(DOMAIN)[0] - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED await hass.config_entries.async_remove(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED @pytest.mark.parametrize( @@ -87,7 +87,7 @@ async def test_update_failed( await setup_integration(hass, mock_config_entry) entry = hass.config_entries.async_entries(DOMAIN)[0] - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY async def test_websocket_not_available( @@ -105,13 +105,13 @@ async def test_websocket_not_available( assert "Failed to connect to websocket. Trying to reconnect: Boom" in caplog.text assert mock_automower_client.auth.websocket_connect.call_count == 1 assert mock_automower_client.start_listening.call_count == 1 - assert mock_config_entry.state == ConfigEntryState.LOADED + assert mock_config_entry.state is ConfigEntryState.LOADED freezer.tick(timedelta(seconds=2)) async_fire_time_changed(hass) await hass.async_block_till_done() assert mock_automower_client.auth.websocket_connect.call_count == 2 assert mock_automower_client.start_listening.call_count == 2 - assert mock_config_entry.state == ConfigEntryState.LOADED + assert mock_config_entry.state is ConfigEntryState.LOADED async def test_device_info( diff --git a/tests/components/insteon/test_config_flow.py b/tests/components/insteon/test_config_flow.py index 711290ef3b1..ae21489bd62 100644 --- a/tests/components/insteon/test_config_flow.py +++ b/tests/components/insteon/test_config_flow.py @@ -30,6 +30,7 @@ from homeassistant.components.insteon.const import ( CONF_X10, DOMAIN, ) +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import ( CONF_ADDRESS, CONF_DEVICE, @@ -136,7 +137,7 @@ async def test_fail_on_existing(hass: HomeAssistant) -> None: options={}, ) config_entry.add_to_hass(hass) - assert config_entry.state is config_entries.ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED result = await hass.config_entries.flow.async_init( DOMAIN, diff --git a/tests/components/iotawatt/test_init.py b/tests/components/iotawatt/test_init.py index c185fec0e4d..8b707780eb4 100644 --- a/tests/components/iotawatt/test_init.py +++ b/tests/components/iotawatt/test_init.py @@ -24,7 +24,7 @@ async def test_setup_connection_failed( mock_iotawatt.connect.side_effect = httpx.ConnectError("") assert await async_setup_component(hass, "iotawatt", {}) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY async def test_setup_auth_failed(hass: HomeAssistant, mock_iotawatt, entry) -> None: @@ -32,4 +32,4 @@ async def test_setup_auth_failed(hass: HomeAssistant, mock_iotawatt, entry) -> N mock_iotawatt.connect.return_value = False assert await async_setup_component(hass, "iotawatt", {}) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY diff --git a/tests/components/islamic_prayer_times/test_init.py b/tests/components/islamic_prayer_times/test_init.py index 3c7565a37ef..aa865ee05a4 100644 --- a/tests/components/islamic_prayer_times/test_init.py +++ b/tests/components/islamic_prayer_times/test_init.py @@ -7,10 +7,10 @@ from freezegun import freeze_time from prayer_times_calculator.exceptions import InvalidResponseError import pytest -from homeassistant import config_entries from homeassistant.components import islamic_prayer_times from homeassistant.components.islamic_prayer_times.const import CONF_CALC_METHOD from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, STATE_UNAVAILABLE from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry as er @@ -43,7 +43,7 @@ async def test_successful_config_entry(hass: HomeAssistant) -> None: await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state is config_entries.ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED async def test_setup_failed(hass: HomeAssistant) -> None: @@ -62,7 +62,7 @@ async def test_setup_failed(hass: HomeAssistant) -> None: ): await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state is config_entries.ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY async def test_unload_entry(hass: HomeAssistant) -> None: @@ -81,7 +81,7 @@ async def test_unload_entry(hass: HomeAssistant) -> None: assert await hass.config_entries.async_unload(entry.entry_id) await hass.async_block_till_done() - assert entry.state is config_entries.ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED async def test_options_listener(hass: HomeAssistant) -> None: @@ -122,7 +122,7 @@ async def test_update_failed(hass: HomeAssistant) -> None: await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state is config_entries.ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED with patch( "prayer_times_calculator.PrayerTimesCalculator.fetch_prayer_times" diff --git a/tests/components/kmtronic/test_config_flow.py b/tests/components/kmtronic/test_config_flow.py index 725058c662a..21468584d81 100644 --- a/tests/components/kmtronic/test_config_flow.py +++ b/tests/components/kmtronic/test_config_flow.py @@ -87,7 +87,7 @@ async def test_form_options( await hass.async_block_till_done() - assert config_entry.state == config_entries.ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED async def test_form_invalid_auth(hass: HomeAssistant) -> None: diff --git a/tests/components/knx/test_init.py b/tests/components/knx/test_init.py index 2d2889e7718..a317a6a298c 100644 --- a/tests/components/knx/test_init.py +++ b/tests/components/knx/test_init.py @@ -11,7 +11,6 @@ from xknx.io import ( SecureConfig, ) -from homeassistant import config_entries from homeassistant.components.knx.config_flow import DEFAULT_ROUTING_IA from homeassistant.components.knx.const import ( CONF_KNX_AUTOMATIC, @@ -40,6 +39,7 @@ from homeassistant.components.knx.const import ( DOMAIN as KNX_DOMAIN, KNXConfigEntryData, ) +from homeassistant.config_entries import ConfigEntryState from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.core import HomeAssistant @@ -287,4 +287,4 @@ async def test_async_remove_entry( await hass.async_block_till_done() assert hass.config_entries.async_entries() == [] - assert config_entry.state is config_entries.ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED diff --git a/tests/components/lacrosse_view/test_init.py b/tests/components/lacrosse_view/test_init.py index cf11e787ad8..51fa7e5abf4 100644 --- a/tests/components/lacrosse_view/test_init.py +++ b/tests/components/lacrosse_view/test_init.py @@ -35,11 +35,11 @@ async def test_unload_entry(hass: HomeAssistant) -> None: entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.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 == ConfigEntryState.NOT_LOADED + assert entries[0].state is ConfigEntryState.NOT_LOADED async def test_login_error(hass: HomeAssistant) -> None: @@ -54,7 +54,7 @@ async def test_login_error(hass: HomeAssistant) -> None: entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.SETUP_ERROR + assert entries[0].state is ConfigEntryState.SETUP_ERROR flows = hass.config_entries.flow.async_progress_by_handler(DOMAIN) assert flows assert len(flows) == 1 @@ -76,7 +76,7 @@ async def test_http_error(hass: HomeAssistant) -> None: entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.SETUP_RETRY + assert entries[0].state is ConfigEntryState.SETUP_RETRY async def test_new_token(hass: HomeAssistant, freezer: FrozenDateTimeFactory) -> None: @@ -98,7 +98,7 @@ async def test_new_token(hass: HomeAssistant, freezer: FrozenDateTimeFactory) -> entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.LOADED + assert entries[0].state is ConfigEntryState.LOADED with ( patch("lacrosse_view.LaCrosse.login", return_value=True) as login, @@ -135,7 +135,7 @@ async def test_failed_token( entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.LOADED + assert entries[0].state is ConfigEntryState.LOADED with patch("lacrosse_view.LaCrosse.login", side_effect=LoginError("Test")): freezer.tick(timedelta(hours=1)) @@ -145,7 +145,7 @@ async def test_failed_token( entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.LOADED + assert entries[0].state is ConfigEntryState.LOADED flows = hass.config_entries.flow.async_progress_by_handler(DOMAIN) assert flows diff --git a/tests/components/lacrosse_view/test_sensor.py b/tests/components/lacrosse_view/test_sensor.py index b9140e6173f..11faaf8877e 100644 --- a/tests/components/lacrosse_view/test_sensor.py +++ b/tests/components/lacrosse_view/test_sensor.py @@ -43,7 +43,7 @@ async def test_entities_added(hass: HomeAssistant) -> None: entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.LOADED + assert entries[0].state is ConfigEntryState.LOADED assert hass.states.get("sensor.test_temperature") @@ -67,7 +67,7 @@ async def test_sensor_permission( entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.SETUP_ERROR + assert entries[0].state is ConfigEntryState.SETUP_ERROR assert not hass.states.get("sensor.test_temperature") assert "This account does not have permission to read Test" in caplog.text @@ -92,7 +92,7 @@ async def test_field_not_supported( entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.LOADED + assert entries[0].state is ConfigEntryState.LOADED assert hass.states.get("sensor.test_some_unsupported_field") is None assert "Unsupported sensor field" in caplog.text @@ -128,7 +128,7 @@ async def test_field_types( entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.LOADED + assert entries[0].state is ConfigEntryState.LOADED assert hass.states.get(f"sensor.test_{entity_id}").state == expected @@ -151,7 +151,7 @@ async def test_no_field(hass: HomeAssistant, caplog: pytest.LogCaptureFixture) - entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.LOADED + assert entries[0].state is ConfigEntryState.LOADED assert hass.states.get("sensor.test_temperature").state == "unavailable" @@ -174,5 +174,5 @@ async def test_field_data_missing(hass: HomeAssistant) -> None: entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.LOADED + assert entries[0].state is ConfigEntryState.LOADED assert hass.states.get("sensor.test_temperature").state == "unknown" diff --git a/tests/components/lamarzocco/test_config_flow.py b/tests/components/lamarzocco/test_config_flow.py index 8539f14ce7f..14f794000d8 100644 --- a/tests/components/lamarzocco/test_config_flow.py +++ b/tests/components/lamarzocco/test_config_flow.py @@ -10,7 +10,7 @@ from homeassistant.components.lamarzocco.const import ( CONF_USE_BLUETOOTH, DOMAIN, ) -from homeassistant.config_entries import SOURCE_REAUTH +from homeassistant.config_entries import SOURCE_REAUTH, ConfigEntryState from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_PASSWORD from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResult, FlowResultType @@ -346,7 +346,7 @@ async def test_options_flow( ) -> None: """Test options flow.""" await async_init_integration(hass, mock_config_entry) - assert mock_config_entry.state is config_entries.ConfigEntryState.LOADED + assert mock_config_entry.state is ConfigEntryState.LOADED result = await hass.config_entries.options.async_init(mock_config_entry.entry_id) diff --git a/tests/components/laundrify/test_init.py b/tests/components/laundrify/test_init.py index 84965af6768..e3ec54a3225 100644 --- a/tests/components/laundrify/test_init.py +++ b/tests/components/laundrify/test_init.py @@ -20,7 +20,7 @@ async def test_setup_entry_api_unauthorized( await hass.async_block_till_done() assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert config_entry.state == ConfigEntryState.SETUP_ERROR + assert config_entry.state is ConfigEntryState.SETUP_ERROR assert not hass.data.get(DOMAIN) @@ -35,7 +35,7 @@ async def test_setup_entry_api_cannot_connect( await hass.async_block_till_done() assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY assert not hass.data.get(DOMAIN) @@ -46,7 +46,7 @@ async def test_setup_entry_successful(hass: HomeAssistant) -> None: await hass.async_block_till_done() assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED async def test_setup_entry_unload(hass: HomeAssistant) -> None: @@ -56,4 +56,4 @@ async def test_setup_entry_unload(hass: HomeAssistant) -> None: await hass.config_entries.async_unload(config_entry.entry_id) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED diff --git a/tests/components/lawn_mower/test_init.py b/tests/components/lawn_mower/test_init.py index 1cf6c7f4b24..87115cb1900 100644 --- a/tests/components/lawn_mower/test_init.py +++ b/tests/components/lawn_mower/test_init.py @@ -114,13 +114,13 @@ async def test_lawn_mower_setup(hass: HomeAssistant) -> None: assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert hass.states.get(entity1.entity_id) assert await hass.config_entries.async_unload(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED entity_state = hass.states.get(entity1.entity_id) assert entity_state diff --git a/tests/components/lcn/test_init.py b/tests/components/lcn/test_init.py index 292ebc045b2..670735439ce 100644 --- a/tests/components/lcn/test_init.py +++ b/tests/components/lcn/test_init.py @@ -20,12 +20,12 @@ from .conftest import MockPchkConnectionManager, setup_component async def test_async_setup_entry(hass: HomeAssistant, entry, lcn_connection) -> None: """Test a successful setup entry and unload of entry.""" assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert entry.state == ConfigEntryState.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 == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED assert not hass.data.get(DOMAIN) @@ -36,7 +36,7 @@ async def test_async_setup_multiple_entries(hass: HomeAssistant, entry, entry2) config_entry.add_to_hass(hass) await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED assert len(hass.config_entries.async_entries(DOMAIN)) == 2 @@ -44,7 +44,7 @@ async def test_async_setup_multiple_entries(hass: HomeAssistant, entry, entry2) assert await hass.config_entries.async_unload(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED assert not hass.data.get(DOMAIN) @@ -96,7 +96,7 @@ async def test_async_setup_entry_raises_authentication_error( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.SETUP_ERROR + assert entry.state is ConfigEntryState.SETUP_ERROR async def test_async_setup_entry_raises_license_error( @@ -110,7 +110,7 @@ async def test_async_setup_entry_raises_license_error( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.SETUP_ERROR + assert entry.state is ConfigEntryState.SETUP_ERROR async def test_async_setup_entry_raises_timeout_error( @@ -122,7 +122,7 @@ async def test_async_setup_entry_raises_timeout_error( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.SETUP_ERROR + assert entry.state is ConfigEntryState.SETUP_ERROR async def test_async_setup_from_configuration_yaml(hass: HomeAssistant) -> None: diff --git a/tests/components/lidarr/test_init.py b/tests/components/lidarr/test_init.py index 48c5e3ff9a6..f10dc117b9c 100644 --- a/tests/components/lidarr/test_init.py +++ b/tests/components/lidarr/test_init.py @@ -14,7 +14,7 @@ async def test_setup( """Test setup.""" await setup_integration() entry = hass.config_entries.async_entries(DOMAIN)[0] - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert await hass.config_entries.async_unload(entry.entry_id) await hass.async_block_till_done() @@ -30,7 +30,7 @@ async def test_async_setup_entry_not_ready( await setup_integration() entry = hass.config_entries.async_entries(DOMAIN)[0] assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY assert not hass.data.get(DOMAIN) @@ -41,7 +41,7 @@ async def test_async_setup_entry_auth_failed( await setup_integration() entry = hass.config_entries.async_entries(DOMAIN)[0] assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert entry.state == ConfigEntryState.SETUP_ERROR + assert entry.state is ConfigEntryState.SETUP_ERROR assert not hass.data.get(DOMAIN) diff --git a/tests/components/lifx/test_init.py b/tests/components/lifx/test_init.py index 3d0d127bf5c..42ece68a2c5 100644 --- a/tests/components/lifx/test_init.py +++ b/tests/components/lifx/test_init.py @@ -87,10 +87,10 @@ async def test_config_entry_reload(hass: HomeAssistant) -> None: with _patch_discovery(), _patch_config_flow_try_connect(), _patch_device(): await async_setup_component(hass, lifx.DOMAIN, {lifx.DOMAIN: {}}) await hass.async_block_till_done() - assert already_migrated_config_entry.state == ConfigEntryState.LOADED + assert already_migrated_config_entry.state is ConfigEntryState.LOADED await hass.config_entries.async_unload(already_migrated_config_entry.entry_id) await hass.async_block_till_done() - assert already_migrated_config_entry.state == ConfigEntryState.NOT_LOADED + assert already_migrated_config_entry.state is ConfigEntryState.NOT_LOADED async def test_config_entry_retry(hass: HomeAssistant) -> None: @@ -106,7 +106,7 @@ async def test_config_entry_retry(hass: HomeAssistant) -> None: ): await async_setup_component(hass, lifx.DOMAIN, {lifx.DOMAIN: {}}) await hass.async_block_till_done() - assert already_migrated_config_entry.state == ConfigEntryState.SETUP_RETRY + assert already_migrated_config_entry.state is ConfigEntryState.SETUP_RETRY async def test_get_version_fails(hass: HomeAssistant) -> None: @@ -123,7 +123,7 @@ async def test_get_version_fails(hass: HomeAssistant) -> None: with _patch_discovery(device=bulb), _patch_device(device=bulb): await async_setup_component(hass, lifx.DOMAIN, {lifx.DOMAIN: {}}) await hass.async_block_till_done() - assert already_migrated_config_entry.state == ConfigEntryState.SETUP_RETRY + assert already_migrated_config_entry.state is ConfigEntryState.SETUP_RETRY async def test_dns_error_at_startup(hass: HomeAssistant) -> None: @@ -158,7 +158,7 @@ async def test_dns_error_at_startup(hass: HomeAssistant) -> None: ): await async_setup_component(hass, lifx.DOMAIN, {lifx.DOMAIN: {}}) await hass.async_block_till_done() - assert already_migrated_config_entry.state == ConfigEntryState.SETUP_RETRY + assert already_migrated_config_entry.state is ConfigEntryState.SETUP_RETRY async def test_config_entry_wrong_serial( @@ -173,7 +173,7 @@ async def test_config_entry_wrong_serial( with _patch_discovery(), _patch_config_flow_try_connect(), _patch_device(): await async_setup_component(hass, lifx.DOMAIN, {lifx.DOMAIN: {}}) await hass.async_block_till_done() - assert already_migrated_config_entry.state == ConfigEntryState.SETUP_RETRY + assert already_migrated_config_entry.state is ConfigEntryState.SETUP_RETRY assert ( "Unexpected device found at 127.0.0.1; expected aa:bb:cc:dd:ee:c0, found aa:bb:cc:dd:ee:cc" diff --git a/tests/components/linear_garage_door/test_coordinator.py b/tests/components/linear_garage_door/test_coordinator.py index 1e46d294f3f..be38b316c56 100644 --- a/tests/components/linear_garage_door/test_coordinator.py +++ b/tests/components/linear_garage_door/test_coordinator.py @@ -38,7 +38,7 @@ async def test_invalid_password( entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.SETUP_ERROR + assert entries[0].state is ConfigEntryState.SETUP_ERROR flows = hass.config_entries.flow.async_progress_by_handler(DOMAIN) assert flows assert len(flows) == 1 @@ -70,4 +70,4 @@ async def test_invalid_login( entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.SETUP_RETRY + assert entries[0].state is ConfigEntryState.SETUP_RETRY diff --git a/tests/components/linear_garage_door/test_cover.py b/tests/components/linear_garage_door/test_cover.py index e692d1867dc..9db7b80fd0e 100644 --- a/tests/components/linear_garage_door/test_cover.py +++ b/tests/components/linear_garage_door/test_cover.py @@ -32,7 +32,7 @@ async def test_data(hass: HomeAssistant) -> None: entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.LOADED + assert entries[0].state is ConfigEntryState.LOADED assert hass.states.get("cover.test_garage_1").state == STATE_OPEN assert hass.states.get("cover.test_garage_2").state == STATE_CLOSED assert hass.states.get("cover.test_garage_3").state == STATE_OPENING diff --git a/tests/components/linear_garage_door/test_init.py b/tests/components/linear_garage_door/test_init.py index 32ebda7e125..63975c8bd3f 100644 --- a/tests/components/linear_garage_door/test_init.py +++ b/tests/components/linear_garage_door/test_init.py @@ -53,7 +53,7 @@ async def test_unload_entry(hass: HomeAssistant) -> None: entries = hass.config_entries.async_entries(DOMAIN) assert entries assert len(entries) == 1 - assert entries[0].state == ConfigEntryState.LOADED + assert entries[0].state is ConfigEntryState.LOADED with patch( "homeassistant.components.linear_garage_door.coordinator.Linear.close", @@ -61,4 +61,4 @@ async def test_unload_entry(hass: HomeAssistant) -> None: ): await hass.config_entries.async_unload(entries[0].entry_id) await hass.async_block_till_done() - assert entries[0].state == ConfigEntryState.NOT_LOADED + assert entries[0].state is ConfigEntryState.NOT_LOADED diff --git a/tests/components/local_calendar/test_init.py b/tests/components/local_calendar/test_init.py index 8e79cccea36..8bb7a26d794 100644 --- a/tests/components/local_calendar/test_init.py +++ b/tests/components/local_calendar/test_init.py @@ -17,7 +17,7 @@ async def test_load_unload( ) -> None: """Test loading and unloading a config entry.""" - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED state = hass.states.get(TEST_ENTITY) assert state @@ -26,7 +26,7 @@ async def test_load_unload( await hass.config_entries.async_unload(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED state = hass.states.get(TEST_ENTITY) assert state assert state.state == "unavailable" @@ -54,7 +54,7 @@ async def test_load_failure( ) -> None: """Test failures loading the store.""" - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY state = hass.states.get(TEST_ENTITY) assert not state diff --git a/tests/components/local_ip/test_init.py b/tests/components/local_ip/test_init.py index 54126b21243..cc4f4dd4968 100644 --- a/tests/components/local_ip/test_init.py +++ b/tests/components/local_ip/test_init.py @@ -2,9 +2,9 @@ from __future__ import annotations -from homeassistant import config_entries from homeassistant.components.local_ip import DOMAIN from homeassistant.components.network import MDNS_TARGET_IP, async_get_source_ip +from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant from tests.common import MockConfigEntry @@ -17,7 +17,7 @@ async def test_basic_setup(hass: HomeAssistant, mock_get_source_ip) -> None: await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == config_entries.ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED local_ip = await async_get_source_ip(hass, target_ip=MDNS_TARGET_IP) state = hass.states.get(f"sensor.{DOMAIN}") @@ -26,4 +26,4 @@ async def test_basic_setup(hass: HomeAssistant, mock_get_source_ip) -> None: assert await hass.config_entries.async_unload(entry.entry_id) await hass.async_block_till_done() - assert entry.state is config_entries.ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED diff --git a/tests/components/local_todo/test_init.py b/tests/components/local_todo/test_init.py index 98da2ef3c12..c27c65c5706 100644 --- a/tests/components/local_todo/test_init.py +++ b/tests/components/local_todo/test_init.py @@ -17,7 +17,7 @@ async def test_load_unload( ) -> None: """Test loading and unloading a config entry.""" - assert config_entry.state == ConfigEntryState.LOADED + assert config_entry.state is ConfigEntryState.LOADED state = hass.states.get(TEST_ENTITY) assert state @@ -26,7 +26,7 @@ async def test_load_unload( await hass.config_entries.async_unload(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.NOT_LOADED + assert config_entry.state is ConfigEntryState.NOT_LOADED state = hass.states.get(TEST_ENTITY) assert state assert state.state == "unavailable" @@ -54,7 +54,7 @@ async def test_load_failure( ) -> None: """Test failures loading the todo store.""" - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY state = hass.states.get(TEST_ENTITY) assert not state diff --git a/tests/components/lyric/test_config_flow.py b/tests/components/lyric/test_config_flow.py index d53b0d57613..73b3aae2d3d 100644 --- a/tests/components/lyric/test_config_flow.py +++ b/tests/components/lyric/test_config_flow.py @@ -11,6 +11,7 @@ from homeassistant.components.application_credentials import ( async_import_client_credential, ) from homeassistant.components.lyric.const import DOMAIN, OAUTH2_AUTHORIZE, OAUTH2_TOKEN +from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType from homeassistant.helpers import config_entry_oauth2_flow @@ -105,7 +106,7 @@ async def test_full_flow( assert DOMAIN in hass.config.components entry = hass.config_entries.async_entries(DOMAIN)[0] - assert entry.state is config_entries.ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(mock_setup.mock_calls) == 1 diff --git a/tests/components/matter/test_init.py b/tests/components/matter/test_init.py index 327e73dd4de..4472e712b20 100644 --- a/tests/components/matter/test_init.py +++ b/tests/components/matter/test_init.py @@ -68,7 +68,7 @@ async def test_entry_setup_unload( await hass.async_block_till_done() assert matter_client.connect.call_count == 1 - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED entity_state = hass.states.get("light.mock_onoff_light") assert entity_state assert entity_state.state != STATE_UNAVAILABLE @@ -76,7 +76,7 @@ async def test_entry_setup_unload( await hass.config_entries.async_unload(entry.entry_id) assert matter_client.disconnect.call_count == 1 - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED entity_state = hass.states.get("light.mock_onoff_light") assert entity_state assert entity_state.state == STATE_UNAVAILABLE @@ -210,12 +210,12 @@ async def test_listen_failure_config_entry_loaded( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED listen_block.set() await hass.async_block_till_done() - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY assert matter_client.disconnect.call_count == 1 diff --git a/tests/components/mikrotik/test_init.py b/tests/components/mikrotik/test_init.py index 96ec0f5771e..cc6a737e75a 100644 --- a/tests/components/mikrotik/test_init.py +++ b/tests/components/mikrotik/test_init.py @@ -34,7 +34,7 @@ async def test_successful_config_entry(hass: HomeAssistant) -> None: entry.add_to_hass(hass) await hass.config_entries.async_setup(entry.entry_id) - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED async def test_hub_connection_error(hass: HomeAssistant, mock_api: MagicMock) -> None: @@ -49,7 +49,7 @@ async def test_hub_connection_error(hass: HomeAssistant, mock_api: MagicMock) -> await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY async def test_hub_authentication_error( @@ -66,7 +66,7 @@ async def test_hub_authentication_error( await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.SETUP_ERROR + assert entry.state is ConfigEntryState.SETUP_ERROR async def test_unload_entry(hass: HomeAssistant) -> None: @@ -83,5 +83,5 @@ async def test_unload_entry(hass: HomeAssistant) -> None: assert await hass.config_entries.async_unload(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED assert entry.entry_id not in hass.data[DOMAIN] diff --git a/tests/components/minecraft_server/test_init.py b/tests/components/minecraft_server/test_init.py index 9c02fb56d91..8ac2e7ca04d 100644 --- a/tests/components/minecraft_server/test_init.py +++ b/tests/components/minecraft_server/test_init.py @@ -134,12 +134,12 @@ async def test_setup_and_unload_entry( ): assert await hass.config_entries.async_setup(java_mock_config_entry.entry_id) await hass.async_block_till_done() - assert java_mock_config_entry.state == ConfigEntryState.LOADED + assert java_mock_config_entry.state is ConfigEntryState.LOADED assert await hass.config_entries.async_unload(java_mock_config_entry.entry_id) await hass.async_block_till_done() assert not hass.data.get(DOMAIN) - assert java_mock_config_entry.state == ConfigEntryState.NOT_LOADED + assert java_mock_config_entry.state is ConfigEntryState.NOT_LOADED async def test_setup_entry_lookup_failure( @@ -157,7 +157,7 @@ async def test_setup_entry_lookup_failure( ) await hass.async_block_till_done() - assert java_mock_config_entry.state == ConfigEntryState.SETUP_RETRY + assert java_mock_config_entry.state is ConfigEntryState.SETUP_RETRY async def test_setup_entry_init_failure( @@ -175,7 +175,7 @@ async def test_setup_entry_init_failure( ) await hass.async_block_till_done() - assert java_mock_config_entry.state == ConfigEntryState.SETUP_RETRY + assert java_mock_config_entry.state is ConfigEntryState.SETUP_RETRY async def test_setup_entry_not_ready( @@ -199,7 +199,7 @@ async def test_setup_entry_not_ready( ) await hass.async_block_till_done() - assert java_mock_config_entry.state == ConfigEntryState.SETUP_RETRY + assert java_mock_config_entry.state is ConfigEntryState.SETUP_RETRY async def test_entry_migration( @@ -246,7 +246,7 @@ async def test_entry_migration( CONF_ADDRESS: TEST_ADDRESS, } assert migrated_config_entry.version == 3 - assert migrated_config_entry.state == ConfigEntryState.LOADED + assert migrated_config_entry.state is ConfigEntryState.LOADED # Test migrated device entry. device_entry = device_registry.async_get(device_entry_id) @@ -305,7 +305,7 @@ async def test_entry_migration_host_only( CONF_ADDRESS: TEST_HOST, } assert v1_mock_config_entry.version == 3 - assert v1_mock_config_entry.state == ConfigEntryState.LOADED + assert v1_mock_config_entry.state is ConfigEntryState.LOADED async def test_entry_migration_v3_failure( @@ -335,4 +335,4 @@ async def test_entry_migration_v3_failure( # Test config entry. assert v1_mock_config_entry.version == 2 - assert v1_mock_config_entry.state == ConfigEntryState.MIGRATION_ERROR + assert v1_mock_config_entry.state is ConfigEntryState.MIGRATION_ERROR diff --git a/tests/components/modem_callerid/test_init.py b/tests/components/modem_callerid/test_init.py index ccf97f60e10..e12850f763d 100644 --- a/tests/components/modem_callerid/test_init.py +++ b/tests/components/modem_callerid/test_init.py @@ -30,7 +30,7 @@ async def test_setup_entry(hass: HomeAssistant) -> None: patch("phone_modem.PhoneModem._modem_sm"), ): await hass.config_entries.async_setup(entry.entry_id) - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED async def test_async_setup_entry_not_ready(hass: HomeAssistant) -> None: @@ -45,7 +45,7 @@ async def test_async_setup_entry_not_ready(hass: HomeAssistant) -> None: modemmock.side_effect = exceptions.SerialError await hass.config_entries.async_setup(entry.entry_id) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert entry.state == ConfigEntryState.SETUP_RETRY + assert entry.state is ConfigEntryState.SETUP_RETRY assert not hass.data.get(DOMAIN) diff --git a/tests/components/mqtt/test_util.py b/tests/components/mqtt/test_util.py index b07dfc1f642..c485e8a9c27 100644 --- a/tests/components/mqtt/test_util.py +++ b/tests/components/mqtt/test_util.py @@ -162,7 +162,7 @@ async def test_waiting_for_client_not_loaded( for _ in range(4): hass.async_create_task(_async_just_in_time_subscribe()) - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED assert await hass.config_entries.async_setup(entry.entry_id) assert len(unsubs) == 4 for unsub in unsubs: @@ -182,7 +182,7 @@ async def test_waiting_for_client_loaded( unsub = await mqtt.async_subscribe(hass, "test_topic", lambda msg: None) entry = hass.config_entries.async_entries(mqtt.DATA_MQTT)[0] - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED await _async_just_in_time_subscribe() @@ -209,13 +209,13 @@ async def test_waiting_for_client_entry_fails( assert not await mqtt.async_wait_for_mqtt_client(hass) hass.async_create_task(_async_just_in_time_subscribe()) - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED with patch( "homeassistant.components.mqtt.async_setup_entry", side_effect=Exception, ): await hass.config_entries.async_setup(entry.entry_id) - assert entry.state == ConfigEntryState.SETUP_ERROR + assert entry.state is ConfigEntryState.SETUP_ERROR async def test_waiting_for_client_setup_fails( @@ -237,12 +237,12 @@ async def test_waiting_for_client_setup_fails( assert not await mqtt.async_wait_for_mqtt_client(hass) hass.async_create_task(_async_just_in_time_subscribe()) - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED # Simulate MQTT setup fails before the client would become available mqtt_client_mock.connect.side_effect = Exception assert not await hass.config_entries.async_setup(entry.entry_id) - assert entry.state == ConfigEntryState.SETUP_ERROR + assert entry.state is ConfigEntryState.SETUP_ERROR @patch("homeassistant.components.mqtt.util.AVAILABILITY_TIMEOUT", 0.01) @@ -260,7 +260,7 @@ async def test_waiting_for_client_timeout( ) entry.add_to_hass(hass) - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED # returns False after timeout assert not await mqtt.async_wait_for_mqtt_client(hass) @@ -284,7 +284,7 @@ async def test_waiting_for_client_with_disabled_entry( entry.entry_id, ConfigEntryDisabler.USER ) - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED # returns False because entry is disabled assert not await mqtt.async_wait_for_mqtt_client(hass) diff --git a/tests/components/mystrom/test_init.py b/tests/components/mystrom/test_init.py index 0304a0eb270..f22665efb6b 100644 --- a/tests/components/mystrom/test_init.py +++ b/tests/components/mystrom/test_init.py @@ -113,7 +113,7 @@ async def test_init_of_unknown_bulb( await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_ERROR + assert config_entry.state is ConfigEntryState.SETUP_ERROR async def test_init_of_unknown_device( @@ -127,7 +127,7 @@ async def test_init_of_unknown_device( await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_ERROR + assert config_entry.state is ConfigEntryState.SETUP_ERROR async def test_init_cannot_connect_because_of_device_info( @@ -145,7 +145,7 @@ async def test_init_cannot_connect_because_of_device_info( await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY async def test_init_cannot_connect_because_of_get_state( @@ -168,4 +168,4 @@ async def test_init_cannot_connect_because_of_get_state( await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - assert config_entry.state == ConfigEntryState.SETUP_RETRY + assert config_entry.state is ConfigEntryState.SETUP_RETRY diff --git a/tests/components/myuplink/test_init.py b/tests/components/myuplink/test_init.py index 328dc55d4ad..421eb9b59c2 100644 --- a/tests/components/myuplink/test_init.py +++ b/tests/components/myuplink/test_init.py @@ -26,12 +26,12 @@ async def test_load_unload_entry( await setup_integration(hass, mock_config_entry) entry = hass.config_entries.async_entries(DOMAIN)[0] - assert entry.state == ConfigEntryState.LOADED + assert entry.state is ConfigEntryState.LOADED await hass.config_entries.async_remove(entry.entry_id) await hass.async_block_till_done() - assert entry.state == ConfigEntryState.NOT_LOADED + assert entry.state is ConfigEntryState.NOT_LOADED @pytest.mark.parametrize(