Skip to content

Commit

Permalink
Use is in ConfigEntryState enum comparison in tests (N-Z) (home-assis…
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Apr 5, 2024
1 parent f2c091f commit 9204ccf
Show file tree
Hide file tree
Showing 107 changed files with 332 additions and 321 deletions.
3 changes: 2 additions & 1 deletion tests/components/neato/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
async_import_client_credential,
)
from homeassistant.components.neato.const import NEATO_DOMAIN
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
Expand Down Expand Up @@ -158,6 +159,6 @@ async def test_reauth(

assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "reauth_successful"
assert new_entry.state == config_entries.ConfigEntryState.LOADED
assert new_entry.state is ConfigEntryState.LOADED
assert len(hass.config_entries.async_entries(NEATO_DOMAIN)) == 1
assert len(mock_setup.mock_calls) == 1
2 changes: 1 addition & 1 deletion tests/components/nest/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ async def test_unload_entry(hass: HomeAssistant, setup_platform) -> None:
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


async def test_remove_entry(
Expand Down
6 changes: 3 additions & 3 deletions tests/components/nest/test_media_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ async def test_integration_unloaded(hass: HomeAssistant, auth, setup_platform) -
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

# No devices returned
browse = await async_browse_media(hass, f"{URI_SCHEME}{DOMAIN}")
Expand Down Expand Up @@ -1166,10 +1166,10 @@ async def test_media_store_persistence(
await hass.async_block_till_done()

# Unload the integration.
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

# Now rebuild the entire integration and verify that all persisted storage
# can be re-loaded from disk.
Expand Down
5 changes: 3 additions & 2 deletions tests/components/netatmo/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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
Expand Down Expand Up @@ -275,7 +276,7 @@ async def test_reauth(

new_entry = hass.config_entries.async_entries(DOMAIN)[0]

assert new_entry.state == config_entries.ConfigEntryState.LOADED
assert new_entry.state is ConfigEntryState.LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert len(mock_setup.mock_calls) == 1

Expand Down Expand Up @@ -322,6 +323,6 @@ async def test_reauth(

assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "reauth_successful"
assert new_entry2.state == config_entries.ConfigEntryState.LOADED
assert new_entry2.state is ConfigEntryState.LOADED
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert len(mock_setup.mock_calls) == 1
8 changes: 4 additions & 4 deletions tests/components/netatmo/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import pytest
from syrupy import SnapshotAssertion

from homeassistant import config_entries
from homeassistant.components import cloud
from homeassistant.components.netatmo import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_WEBHOOK_ID, Platform
from homeassistant.core import CoreState, HomeAssistant
import homeassistant.helpers.device_registry as dr
Expand Down Expand Up @@ -82,7 +82,7 @@ async def test_setup_component(
mock_impl.assert_called_once()
mock_webhook.assert_called_once()

assert config_entry.state is config_entries.ConfigEntryState.LOADED
assert config_entry.state is ConfigEntryState.LOADED
assert hass.config_entries.async_entries(DOMAIN)
assert len(hass.states.async_all()) > 0

Expand Down Expand Up @@ -425,7 +425,7 @@ async def test_setup_component_invalid_token_scope(hass: HomeAssistant) -> None:
mock_impl.assert_called_once()
mock_webhook.assert_not_called()

assert config_entry.state is config_entries.ConfigEntryState.SETUP_ERROR
assert config_entry.state is ConfigEntryState.SETUP_ERROR
assert hass.config_entries.async_entries(DOMAIN)

notifications = async_get_persistent_notifications(hass)
Expand Down Expand Up @@ -479,7 +479,7 @@ async def fake_ensure_valid_token(*args, **kwargs):
mock_impl.assert_called_once()
mock_webhook.assert_not_called()

assert config_entry.state is config_entries.ConfigEntryState.SETUP_ERROR
assert config_entry.state is ConfigEntryState.SETUP_ERROR
assert hass.config_entries.async_entries(DOMAIN)
notifications = async_get_persistent_notifications(hass)
assert len(notifications) > 0
Expand Down
4 changes: 2 additions & 2 deletions tests/components/netgear_lte/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
async def test_setup_unload(hass: HomeAssistant, setup_integration: None) -> None:
"""Test setup and unload."""
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

Expand All @@ -29,7 +29,7 @@ async def test_async_setup_entry_not_ready(
"""Test that it throws ConfigEntryNotReady when exception occurs during setup."""
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


async def test_device(
Expand Down
2 changes: 1 addition & 1 deletion tests/components/nexia/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
async def test_setup_retry_client_os_error(hass: HomeAssistant) -> None:
"""Verify we retry setup on aiohttp.ClientOSError."""
config_entry = await async_init_integration(hass, exception=aiohttp.ClientOSError)
assert config_entry.state == ConfigEntryState.SETUP_RETRY
assert config_entry.state is ConfigEntryState.SETUP_RETRY


async def remove_device(ws_client, device_id, config_entry_id):
Expand Down
2 changes: 1 addition & 1 deletion tests/components/nibe_heatpump/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def async_add_entry(hass: HomeAssistant, data: dict[str, Any]) -> MockConf
entry.add_to_hass(hass)
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
return entry


Expand Down
6 changes: 3 additions & 3 deletions tests/components/nina/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def test_sensors(hass: HomeAssistant) -> None:
await hass.config_entries.async_setup(conf_entry.entry_id)
await hass.async_block_till_done()

assert conf_entry.state == ConfigEntryState.LOADED
assert conf_entry.state is ConfigEntryState.LOADED

state_w1 = hass.states.get("binary_sensor.warning_aach_stadt_1")
entry_w1 = entity_registry.async_get("binary_sensor.warning_aach_stadt_1")
Expand Down Expand Up @@ -181,7 +181,7 @@ async def test_sensors_without_corona_filter(hass: HomeAssistant) -> None:
await hass.config_entries.async_setup(conf_entry.entry_id)
await hass.async_block_till_done()

assert conf_entry.state == ConfigEntryState.LOADED
assert conf_entry.state is ConfigEntryState.LOADED

state_w1 = hass.states.get("binary_sensor.warning_aach_stadt_1")
entry_w1 = entity_registry.async_get("binary_sensor.warning_aach_stadt_1")
Expand Down Expand Up @@ -309,7 +309,7 @@ async def test_sensors_with_area_filter(hass: HomeAssistant) -> None:
await hass.config_entries.async_setup(conf_entry.entry_id)
await hass.async_block_till_done()

assert conf_entry.state == ConfigEntryState.LOADED
assert conf_entry.state is ConfigEntryState.LOADED

state_w1 = hass.states.get("binary_sensor.warning_aach_stadt_1")
entry_w1 = entity_registry.async_get("binary_sensor.warning_aach_stadt_1")
Expand Down
4 changes: 2 additions & 2 deletions tests/components/nina/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def test_config_entry_not_ready(hass: HomeAssistant) -> None:
"""Test the configuration entry."""
entry: MockConfigEntry = await init_integration(hass)

assert entry.state == ConfigEntryState.LOADED
assert entry.state is ConfigEntryState.LOADED


async def test_sensors_connection_error(hass: HomeAssistant) -> None:
Expand All @@ -82,4 +82,4 @@ async def test_sensors_connection_error(hass: HomeAssistant) -> None:
await hass.config_entries.async_setup(conf_entry.entry_id)
await hass.async_block_till_done()

assert conf_entry.state == ConfigEntryState.SETUP_RETRY
assert conf_entry.state is ConfigEntryState.SETUP_RETRY
2 changes: 1 addition & 1 deletion tests/components/octoprint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ async def init_integration(
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
4 changes: 2 additions & 2 deletions tests/components/oncue/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def test_binary_sensors(hass: HomeAssistant) -> None:
with _patch_login_and_data():
await async_setup_component(hass, oncue.DOMAIN, {oncue.DOMAIN: {}})
await hass.async_block_till_done()
assert config_entry.state == ConfigEntryState.LOADED
assert config_entry.state is ConfigEntryState.LOADED

assert len(hass.states.async_all("binary_sensor")) == 1
assert (
Expand All @@ -47,7 +47,7 @@ async def test_binary_sensors_not_unavailable(hass: HomeAssistant) -> None:
with _patch_login_and_data_unavailable():
await async_setup_component(hass, oncue.DOMAIN, {oncue.DOMAIN: {}})
await hass.async_block_till_done()
assert config_entry.state == ConfigEntryState.LOADED
assert config_entry.state is ConfigEntryState.LOADED

assert len(hass.states.async_all("binary_sensor")) == 1
assert (
Expand Down
8 changes: 4 additions & 4 deletions tests/components/oncue/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ async def test_config_entry_reload(hass: HomeAssistant) -> None:
with _patch_login_and_data():
await async_setup_component(hass, oncue.DOMAIN, {oncue.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_login_error(hass: HomeAssistant) -> None:
Expand All @@ -49,7 +49,7 @@ async def test_config_entry_login_error(hass: HomeAssistant) -> None:
):
await async_setup_component(hass, oncue.DOMAIN, {oncue.DOMAIN: {}})
await hass.async_block_till_done()
assert config_entry.state == ConfigEntryState.SETUP_ERROR
assert config_entry.state is ConfigEntryState.SETUP_ERROR


async def test_config_entry_retry_later(hass: HomeAssistant) -> None:
Expand All @@ -66,4 +66,4 @@ async def test_config_entry_retry_later(hass: HomeAssistant) -> None:
):
await async_setup_component(hass, oncue.DOMAIN, {oncue.DOMAIN: {}})
await hass.async_block_till_done()
assert config_entry.state == ConfigEntryState.SETUP_RETRY
assert config_entry.state is ConfigEntryState.SETUP_RETRY
4 changes: 2 additions & 2 deletions tests/components/oncue/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def test_sensors(hass: HomeAssistant, patcher, connections) -> None:
with patcher():
await async_setup_component(hass, oncue.DOMAIN, {oncue.DOMAIN: {}})
await hass.async_block_till_done()
assert config_entry.state == ConfigEntryState.LOADED
assert config_entry.state is ConfigEntryState.LOADED

entity_registry = er.async_get(hass)
ent = entity_registry.async_get("sensor.my_generator_latest_firmware")
Expand Down Expand Up @@ -167,7 +167,7 @@ async def test_sensors_unavailable(hass: HomeAssistant, patcher, connections) ->
with patcher():
await async_setup_component(hass, oncue.DOMAIN, {oncue.DOMAIN: {}})
await hass.async_block_till_done()
assert config_entry.state == ConfigEntryState.LOADED
assert config_entry.state is ConfigEntryState.LOADED

assert len(hass.states.async_all("sensor")) == 25
assert (
Expand Down
10 changes: 5 additions & 5 deletions tests/components/openweathermap/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ async def test_form(hass: HomeAssistant) -> None:

conf_entries = hass.config_entries.async_entries(DOMAIN)
entry = conf_entries[0]
assert entry.state == ConfigEntryState.LOADED
assert entry.state is ConfigEntryState.LOADED

await hass.config_entries.async_unload(conf_entries[0].entry_id)
await hass.async_block_till_done()
assert entry.state == ConfigEntryState.NOT_LOADED
assert entry.state is ConfigEntryState.NOT_LOADED

assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == CONFIG[CONF_NAME]
Expand All @@ -88,7 +88,7 @@ async def test_form_options(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

result = await hass.config_entries.options.async_init(config_entry.entry_id)

Expand All @@ -107,7 +107,7 @@ async def test_form_options(hass: HomeAssistant) -> None:

await hass.async_block_till_done()

assert config_entry.state == ConfigEntryState.LOADED
assert config_entry.state is ConfigEntryState.LOADED

result = await hass.config_entries.options.async_init(config_entry.entry_id)

Expand All @@ -126,7 +126,7 @@ async def test_form_options(hass: HomeAssistant) -> None:

await hass.async_block_till_done()

assert config_entry.state == ConfigEntryState.LOADED
assert config_entry.state is ConfigEntryState.LOADED


async def test_form_invalid_api_key(hass: HomeAssistant) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/components/ourgroceries/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ async def test_load_unload(
entries = hass.config_entries.async_entries(DOMAIN)
assert len(entries) == 1

assert ourgroceries_config_entry.state == ConfigEntryState.LOADED
assert ourgroceries_config_entry.state is ConfigEntryState.LOADED

assert await hass.config_entries.async_unload(ourgroceries_config_entry.entry_id)
assert ourgroceries_config_entry.state == ConfigEntryState.NOT_LOADED
assert ourgroceries_config_entry.state is ConfigEntryState.NOT_LOADED


@pytest.fixture
Expand Down
Loading

0 comments on commit 9204ccf

Please sign in to comment.