Use is instead of == on check against enum value at Home Connect (#144083)

* Use `is` instead of `==` on check against enum value at Home Connect

* Revert HTTP status checks
This commit is contained in:
J. Diego Rodríguez Royo 2025-05-02 10:08:46 +02:00 committed by GitHub
parent fca62f1ae8
commit 3af0d6e484
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 94 additions and 94 deletions

View File

@ -79,7 +79,7 @@ class HomeConnectTimeEntity(HomeConnectEntity, TimeEntity):
async def async_added_to_hass(self) -> None: async def async_added_to_hass(self) -> None:
"""Call when entity is added to hass.""" """Call when entity is added to hass."""
await super().async_added_to_hass() await super().async_added_to_hass()
if self.bsh_key == SettingKey.BSH_COMMON_ALARM_CLOCK: if self.bsh_key is SettingKey.BSH_COMMON_ALARM_CLOCK:
automations = automations_with_entity(self.hass, self.entity_id) automations = automations_with_entity(self.hass, self.entity_id)
scripts = scripts_with_entity(self.hass, self.entity_id) scripts = scripts_with_entity(self.hass, self.entity_id)
items = automations + scripts items = automations + scripts
@ -123,7 +123,7 @@ class HomeConnectTimeEntity(HomeConnectEntity, TimeEntity):
async def async_will_remove_from_hass(self) -> None: async def async_will_remove_from_hass(self) -> None:
"""Call when entity will be removed from hass.""" """Call when entity will be removed from hass."""
if self.bsh_key == SettingKey.BSH_COMMON_ALARM_CLOCK: if self.bsh_key is SettingKey.BSH_COMMON_ALARM_CLOCK:
async_delete_issue( async_delete_issue(
self.hass, self.hass,
DOMAIN, DOMAIN,

View File

@ -52,7 +52,7 @@ async def test_paired_depaired_devices_flow(
) -> None: ) -> None:
"""Test that removed devices are correctly removed from and added to hass on API events.""" """Test that removed devices are correctly removed from and added to hass on API events."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)}) device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)})
assert device assert device
@ -128,7 +128,7 @@ async def test_connected_devices(
client.get_status = AsyncMock(side_effect=get_status_side_effect) client.get_status = AsyncMock(side_effect=get_status_side_effect)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
client.get_status = get_status_original_mock client.get_status = get_status_original_mock
device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)}) device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)})
@ -178,7 +178,7 @@ async def test_binary_sensors_entity_availability(
"binary_sensor.washer_remote_control", "binary_sensor.washer_remote_control",
] ]
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
for entity_id in entity_ids: for entity_id in entity_ids:
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
@ -277,7 +277,7 @@ async def test_binary_sensors_functionality(
) -> None: ) -> None:
"""Tests for Home Connect Fridge appliance door states.""" """Tests for Home Connect Fridge appliance door states."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
await client.add_events( await client.add_events(
[ [
EventMessage( EventMessage(
@ -313,7 +313,7 @@ async def test_connected_sensor_functionality(
"""Test if the connected binary sensor reports the right values.""" """Test if the connected binary sensor reports the right values."""
entity_id = "binary_sensor.washer_connectivity" entity_id = "binary_sensor.washer_connectivity"
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert hass.states.is_state(entity_id, STATE_ON) assert hass.states.is_state(entity_id, STATE_ON)

View File

@ -44,7 +44,7 @@ async def test_paired_depaired_devices_flow(
) -> None: ) -> None:
"""Test that removed devices are correctly removed from and added to hass on API events.""" """Test that removed devices are correctly removed from and added to hass on API events."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)}) device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)})
assert device assert device
@ -131,7 +131,7 @@ async def test_connected_devices(
) )
client.get_all_programs = AsyncMock(side_effect=get_all_programs_side_effect) client.get_all_programs = AsyncMock(side_effect=get_all_programs_side_effect)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
client.get_available_commands = get_available_commands_original_mock client.get_available_commands = get_available_commands_original_mock
client.get_all_programs = get_all_programs_mock client.get_all_programs = get_all_programs_mock
@ -182,7 +182,7 @@ async def test_button_entity_availability(
"button.washer_stop_program", "button.washer_stop_program",
] ]
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
for entity_id in entity_ids: for entity_id in entity_ids:
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
@ -244,7 +244,7 @@ async def test_button_functionality(
) -> None: ) -> None:
"""Test if button entities availability are based on the appliance connection state.""" """Test if button entities availability are based on the appliance connection state."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
entity = hass.states.get(entity_id) entity = hass.states.get(entity_id)
assert entity assert entity
@ -279,7 +279,7 @@ async def test_command_button_exception(
) )
) )
assert await integration_setup(client_with_exception) assert await integration_setup(client_with_exception)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
entity = hass.states.get(entity_id) entity = hass.states.get(entity_id)
assert entity assert entity
@ -304,7 +304,7 @@ async def test_stop_program_button_exception(
entity_id = "button.washer_stop_program" entity_id = "button.washer_stop_program"
assert await integration_setup(client_with_exception) assert await integration_setup(client_with_exception)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
entity = hass.states.get(entity_id) entity = hass.states.get(entity_id)
assert entity assert entity

View File

@ -189,7 +189,7 @@ async def test_reauth_flow(
assert entry.state is ConfigEntryState.LOADED assert entry.state is ConfigEntryState.LOADED
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful" assert result["reason"] == "reauth_successful"
@ -239,5 +239,5 @@ async def test_reauth_flow_with_different_account(
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == FlowResultType.ABORT assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "wrong_account" assert result["reason"] == "wrong_account"

View File

@ -99,7 +99,7 @@ async def test_coordinator_failure_refresh_and_stream(
entity_id_2 = "binary_sensor.washer_remote_start" entity_id_2 = "binary_sensor.washer_remote_start"
await async_setup_component(hass, HA_DOMAIN, {}) await async_setup_component(hass, HA_DOMAIN, {})
await integration_setup(client) await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
state = hass.states.get(entity_id_1) state = hass.states.get(entity_id_1)
assert state assert state
assert state.state != STATE_UNAVAILABLE assert state.state != STATE_UNAVAILABLE
@ -219,7 +219,7 @@ async def test_coordinator_not_fetching_on_disconnected_appliance(
appliance.connected = False appliance.connected = False
await integration_setup(client) await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
for method in INITIAL_FETCH_CLIENT_METHODS: for method in INITIAL_FETCH_CLIENT_METHODS:
assert getattr(client, method).call_count == 0 assert getattr(client, method).call_count == 0
@ -242,7 +242,7 @@ async def test_coordinator_update_failing(
setattr(client, mock_method, AsyncMock(side_effect=HomeConnectError())) setattr(client, mock_method, AsyncMock(side_effect=HomeConnectError()))
await integration_setup(client) await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
getattr(client, mock_method).assert_called() getattr(client, mock_method).assert_called()
@ -285,7 +285,7 @@ async def test_event_listener(
) -> None: ) -> None:
"""Test that the event listener works.""" """Test that the event listener works."""
await integration_setup(client) await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
@ -351,7 +351,7 @@ async def tests_receive_setting_and_status_for_first_time_at_events(
client.get_status = AsyncMock(return_value=ArrayOfStatus([])) client.get_status = AsyncMock(return_value=ArrayOfStatus([]))
await integration_setup(client) await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
await client.add_events( await client.add_events(
[ [
@ -391,7 +391,7 @@ async def tests_receive_setting_and_status_for_first_time_at_events(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(config_entry._background_tasks) == 1 assert len(config_entry._background_tasks) == 1
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
async def test_event_listener_error( async def test_event_listener_error(
@ -467,7 +467,7 @@ async def test_event_listener_resilience(
await integration_setup(client) await integration_setup(client)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert len(config_entry._background_tasks) == 1 assert len(config_entry._background_tasks) == 1
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
@ -527,7 +527,7 @@ async def test_devices_updated_on_refresh(
await async_setup_component(hass, HA_DOMAIN, {}) await async_setup_component(hass, HA_DOMAIN, {})
await integration_setup(client) await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
for appliance in appliances[:2]: for appliance in appliances[:2]:
assert device_registry.async_get_device({(DOMAIN, appliance.ha_id)}) assert device_registry.async_get_device({(DOMAIN, appliance.ha_id)})
@ -559,7 +559,7 @@ async def test_paired_disconnected_devices_not_fetching(
"""Test that Home Connect API is not fetched after pairing a disconnected device.""" """Test that Home Connect API is not fetched after pairing a disconnected device."""
client.get_home_appliances = AsyncMock(return_value=ArrayOfHomeAppliances([])) client.get_home_appliances = AsyncMock(return_value=ArrayOfHomeAppliances([]))
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
appliance.connected = False appliance.connected = False
await client.add_events( await client.add_events(
@ -595,7 +595,7 @@ async def test_coordinator_disabling_updates_for_appliance(
issue_id = f"home_connect_too_many_connected_paired_events_{appliance_ha_id}" issue_id = f"home_connect_too_many_connected_paired_events_{appliance_ha_id}"
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert hass.states.is_state("switch.dishwasher_power", STATE_ON) assert hass.states.is_state("switch.dishwasher_power", STATE_ON)
@ -685,7 +685,7 @@ async def test_coordinator_disabling_updates_for_appliance_is_gone_after_entry_r
issue_id = f"home_connect_too_many_connected_paired_events_{appliance_ha_id}" issue_id = f"home_connect_too_many_connected_paired_events_{appliance_ha_id}"
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert hass.states.is_state("switch.dishwasher_power", STATE_ON) assert hass.states.is_state("switch.dishwasher_power", STATE_ON)
@ -710,7 +710,7 @@ async def test_coordinator_disabling_updates_for_appliance_is_gone_after_entry_r
assert not issue_registry.async_get_issue(DOMAIN, issue_id) assert not issue_registry.async_get_issue(DOMAIN, issue_id)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
get_settings_original_side_effect = client.get_settings.side_effect get_settings_original_side_effect = client.get_settings.side_effect

View File

@ -26,7 +26,7 @@ async def test_async_get_config_entry_diagnostics(
) -> None: ) -> None:
"""Test config entry diagnostics.""" """Test config entry diagnostics."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert await async_get_config_entry_diagnostics(hass, config_entry) == snapshot assert await async_get_config_entry_diagnostics(hass, config_entry) == snapshot
@ -41,7 +41,7 @@ async def test_async_get_device_diagnostics(
) -> None: ) -> None:
"""Test device config entry diagnostics.""" """Test device config entry diagnostics."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device = device_registry.async_get_or_create( device = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,

View File

@ -158,7 +158,7 @@ async def test_program_options_retrieval(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
for entity_id, (state, _) in zip( for entity_id, (state, _) in zip(
option_entity_id.values(), options_state_stage_1, strict=True option_entity_id.values(), options_state_stage_1, strict=True
@ -276,7 +276,7 @@ async def test_no_options_retrieval_on_unknown_program(
client.get_all_programs = AsyncMock(side_effect=get_all_programs_with_options_mock) client.get_all_programs = AsyncMock(side_effect=get_all_programs_with_options_mock)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert client.get_available_program.call_count == 0 assert client.get_available_program.call_count == 0
@ -356,7 +356,7 @@ async def test_program_options_retrieval_after_appliance_connection(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert not hass.states.get(option_entity_id) assert not hass.states.get(option_entity_id)
@ -467,7 +467,7 @@ async def test_option_entity_functionality_exception(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert hass.states.get(entity_id) assert hass.states.get(entity_id)

View File

@ -47,12 +47,12 @@ async def test_entry_setup(
) -> None: ) -> None:
"""Test setup and unload.""" """Test setup and unload."""
assert await integration_setup(client) assert await integration_setup(client)
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 await hass.config_entries.async_unload(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ConfigEntryState.NOT_LOADED assert config_entry.state is ConfigEntryState.NOT_LOADED
@pytest.mark.parametrize("token_expiration_time", [12345]) @pytest.mark.parametrize("token_expiration_time", [12345])
@ -85,7 +85,7 @@ async def test_token_refresh_success(
client._auth = auth client._auth = auth
return client return client
assert config_entry.state == ConfigEntryState.NOT_LOADED assert config_entry.state is ConfigEntryState.NOT_LOADED
with ( with (
patch("homeassistant.components.home_connect.PLATFORMS", platforms), patch("homeassistant.components.home_connect.PLATFORMS", platforms),
patch("homeassistant.components.home_connect.HomeConnectClient") as client_mock, patch("homeassistant.components.home_connect.HomeConnectClient") as client_mock,
@ -93,7 +93,7 @@ async def test_token_refresh_success(
client_mock.side_effect = MagicMock(side_effect=init_side_effect) client_mock.side_effect = MagicMock(side_effect=init_side_effect)
assert await hass.config_entries.async_setup(config_entry.entry_id) assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
# Verify token request # Verify token request
assert aioclient_mock.call_count == 1 assert aioclient_mock.call_count == 1
@ -154,7 +154,7 @@ async def test_token_refresh_error(
**aioclient_mock_args, **aioclient_mock_args,
) )
assert config_entry.state == ConfigEntryState.NOT_LOADED assert config_entry.state is ConfigEntryState.NOT_LOADED
with patch( with patch(
"homeassistant.components.home_connect.HomeConnectClient", return_value=client "homeassistant.components.home_connect.HomeConnectClient", return_value=client
): ):
@ -216,12 +216,12 @@ async def test_client_rate_limit_error(
mock.side_effect = side_effect mock.side_effect = side_effect
setattr(client, raising_exception_method, mock) setattr(client, raising_exception_method, mock)
assert config_entry.state == ConfigEntryState.NOT_LOADED assert config_entry.state is ConfigEntryState.NOT_LOADED
with patch( with patch(
"homeassistant.components.home_connect.coordinator.asyncio_sleep", "homeassistant.components.home_connect.coordinator.asyncio_sleep",
) as asyncio_sleep_mock: ) as asyncio_sleep_mock:
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert mock.call_count >= 2 assert mock.call_count >= 2
asyncio_sleep_mock.assert_called_once_with(retry_after) asyncio_sleep_mock.assert_called_once_with(retry_after)
@ -238,7 +238,7 @@ async def test_required_program_or_at_least_an_option(
"Test that the set_program_and_options does raise an exception if no program nor options are set." "Test that the set_program_and_options does raise an exception if no program nor options are set."
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,

View File

@ -65,7 +65,7 @@ async def test_paired_depaired_devices_flow(
) -> None: ) -> None:
"""Test that removed devices are correctly removed from and added to hass on API events.""" """Test that removed devices are correctly removed from and added to hass on API events."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)}) device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)})
assert device assert device
@ -141,7 +141,7 @@ async def test_connected_devices(
client.get_settings = AsyncMock(side_effect=get_settings_side_effect) client.get_settings = AsyncMock(side_effect=get_settings_side_effect)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
client.get_settings = get_settings_original_mock client.get_settings = get_settings_original_mock
device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)}) device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)})
@ -185,7 +185,7 @@ async def test_light_availability(
"light.hood_functional_light", "light.hood_functional_light",
] ]
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
for entity_id in entity_ids: for entity_id in entity_ids:
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
@ -351,7 +351,7 @@ async def test_light_functionality(
) -> None: ) -> None:
"""Test light functionality.""" """Test light functionality."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
service_data = exprected_attributes.copy() service_data = exprected_attributes.copy()
service_data[ATTR_ENTITY_ID] = entity_id service_data[ATTR_ENTITY_ID] = entity_id
@ -402,7 +402,7 @@ async def test_light_color_different_than_custom(
) -> None: ) -> None:
"""Test that light color attributes are not set if color is different than custom.""" """Test that light color attributes are not set if color is different than custom."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
await hass.services.async_call( await hass.services.async_call(
LIGHT_DOMAIN, LIGHT_DOMAIN,
SERVICE_TURN_ON, SERVICE_TURN_ON,
@ -582,7 +582,7 @@ async def test_light_exception_handling(
exception() if exception else None for exception in attr_side_effect exception() if exception else None for exception in attr_side_effect
] ]
assert await integration_setup(client_with_exception) assert await integration_setup(client_with_exception)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
# Assert that an exception is called. # Assert that an exception is called.
with pytest.raises(HomeConnectError): with pytest.raises(HomeConnectError):

View File

@ -81,7 +81,7 @@ async def test_paired_depaired_devices_flow(
) )
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)}) device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)})
assert device assert device
@ -159,7 +159,7 @@ async def test_connected_devices(
client.get_settings = AsyncMock(side_effect=get_settings_side_effect) client.get_settings = AsyncMock(side_effect=get_settings_side_effect)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
client.get_settings = get_settings_original_mock client.get_settings = get_settings_original_mock
device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)}) device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)})
@ -208,7 +208,7 @@ async def test_number_entity_availability(
# so we rise an error to easily test the availability # so we rise an error to easily test the availability
client.get_setting = AsyncMock(side_effect=HomeConnectError()) client.get_setting = AsyncMock(side_effect=HomeConnectError())
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
for entity_id in entity_ids: for entity_id in entity_ids:
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
@ -594,7 +594,7 @@ async def test_options_functionality(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
entity_state = hass.states.get(entity_id) entity_state = hass.states.get(entity_id)
assert entity_state assert entity_state
assert entity_state.attributes["unit_of_measurement"] == unit assert entity_state.attributes["unit_of_measurement"] == unit

View File

@ -85,7 +85,7 @@ async def test_paired_depaired_devices_flow(
) )
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)}) device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)})
assert device assert device
@ -174,7 +174,7 @@ async def test_connected_devices(
client.get_settings = AsyncMock(side_effect=get_settings_side_effect) client.get_settings = AsyncMock(side_effect=get_settings_side_effect)
client.get_all_programs = AsyncMock(side_effect=get_all_programs_side_effect) client.get_all_programs = AsyncMock(side_effect=get_all_programs_side_effect)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
client.get_settings = get_settings_original_mock client.get_settings = get_settings_original_mock
client.get_all_programs = get_all_programs_mock client.get_all_programs = get_all_programs_mock
@ -219,7 +219,7 @@ async def test_select_entity_availability(
"select.washer_active_program", "select.washer_active_program",
] ]
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
for entity_id in entity_ids: for entity_id in entity_ids:
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
@ -489,7 +489,7 @@ async def test_programs_updated_on_connect(
client.get_all_programs = AsyncMock(side_effect=get_all_programs_side_effect) client.get_all_programs = AsyncMock(side_effect=get_all_programs_side_effect)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
client.get_all_programs = get_all_programs_mock client.get_all_programs = get_all_programs_mock
state = hass.states.get("select.washer_active_program") state = hass.states.get("select.washer_active_program")
@ -941,7 +941,7 @@ async def test_options_functionality(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
entity_state = hass.states.get(entity_id) entity_state = hass.states.get(entity_id)
assert entity_state assert entity_state
assert set(entity_state.attributes[ATTR_OPTIONS]) == expected_options assert set(entity_state.attributes[ATTR_OPTIONS]) == expected_options

View File

@ -101,7 +101,7 @@ async def test_paired_depaired_devices_flow(
) -> None: ) -> None:
"""Test that removed devices are correctly removed from and added to hass on API events.""" """Test that removed devices are correctly removed from and added to hass on API events."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)}) device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)})
assert device assert device
@ -200,7 +200,7 @@ async def test_connected_devices(
client.get_status = AsyncMock(side_effect=get_status_side_effect) client.get_status = AsyncMock(side_effect=get_status_side_effect)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
client.get_status = get_status_original_mock client.get_status = get_status_original_mock
device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)}) device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)})
@ -245,7 +245,7 @@ async def test_sensor_entity_availability(
"sensor.dishwasher_salt_nearly_empty", "sensor.dishwasher_salt_nearly_empty",
] ]
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
await client.add_events( await client.add_events(
[ [
@ -367,7 +367,7 @@ async def test_program_sensors(
time_to_freeze = "2021-01-09 12:00:00+00:00" time_to_freeze = "2021-01-09 12:00:00+00:00"
freezer.move_to(time_to_freeze) freezer.move_to(time_to_freeze)
assert config_entry.state == ConfigEntryState.NOT_LOADED assert config_entry.state is ConfigEntryState.NOT_LOADED
client.get_status.return_value.status.extend( client.get_status.return_value.status.extend(
Status( Status(
key=StatusKey(event_key.value), key=StatusKey(event_key.value),
@ -377,7 +377,7 @@ async def test_program_sensors(
for event_key, value in EVENT_PROG_DELAYED_START[EventType.STATUS].items() for event_key, value in EVENT_PROG_DELAYED_START[EventType.STATUS].items()
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
await client.add_events( await client.add_events(
[ [
@ -450,7 +450,7 @@ async def test_program_sensor_edge_case(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert hass.states.is_state(entity_id, initial_state) assert hass.states.is_state(entity_id, initial_state)
@ -512,7 +512,7 @@ async def test_remaining_prog_time_edge_cases(
freezer.move_to(time_to_freeze) freezer.move_to(time_to_freeze)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
for ( for (
event, event,
@ -587,7 +587,7 @@ async def test_sensors_states(
) -> None: ) -> None:
"""Tests for appliance sensors.""" """Tests for appliance sensors."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
for value, expected_state in value_expected_state: for value, expected_state in value_expected_state:
await client.add_events( await client.add_events(
@ -648,7 +648,7 @@ async def test_event_sensors_states(
"""Tests for appliance event sensors.""" """Tests for appliance event sensors."""
caplog.set_level(logging.ERROR) caplog.set_level(logging.ERROR)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert not hass.states.get(entity_id) assert not hass.states.get(entity_id)
@ -757,7 +757,7 @@ async def test_sensor_unit_fetching(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
entity_state = hass.states.get(entity_id) entity_state = hass.states.get(entity_id)
assert entity_state assert entity_state
@ -812,7 +812,7 @@ async def test_sensor_unit_fetching_error(
client.get_status_value = AsyncMock(side_effect=HomeConnectError()) client.get_status_value = AsyncMock(side_effect=HomeConnectError())
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert hass.states.get(entity_id) assert hass.states.get(entity_id)
@ -875,7 +875,7 @@ async def test_sensor_unit_fetching_after_rate_limit_error(
assert await integration_setup(client) assert await integration_setup(client)
async_fire_time_changed(hass) async_fire_time_changed(hass)
await hass.async_block_till_done() await hass.async_block_till_done()
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert client.get_status_value.call_count == 2 assert client.get_status_value.call_count == 2

View File

@ -186,7 +186,7 @@ async def test_key_value_services(
) -> None: ) -> None:
"""Create and test services.""" """Create and test services."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
@ -236,7 +236,7 @@ async def test_programs_and_options_actions_deprecation(
) -> None: ) -> None:
"""Test deprecated service keys.""" """Test deprecated service keys."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
@ -304,7 +304,7 @@ async def test_set_program_and_options(
) -> None: ) -> None:
"""Test recognized options.""" """Test recognized options."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
@ -345,7 +345,7 @@ async def test_set_program_and_options_exceptions(
) -> None: ) -> None:
"""Test recognized options.""" """Test recognized options."""
assert await integration_setup(client_with_exception) assert await integration_setup(client_with_exception)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
@ -373,7 +373,7 @@ async def test_services_exception_device_id(
) -> None: ) -> None:
"""Raise a HomeAssistantError when there is an API error.""" """Raise a HomeAssistantError when there is an API error."""
assert await integration_setup(client_with_exception) assert await integration_setup(client_with_exception)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,
@ -395,7 +395,7 @@ async def test_services_appliance_not_found(
) -> None: ) -> None:
"""Raise a ServiceValidationError when device id does not match.""" """Raise a ServiceValidationError when device id does not match."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
service_call = SERVICE_KV_CALL_PARAMS[0] service_call = SERVICE_KV_CALL_PARAMS[0]
@ -443,7 +443,7 @@ async def test_services_exception(
) -> None: ) -> None:
"""Raise a ValueError when device id does not match.""" """Raise a ValueError when device id does not match."""
assert await integration_setup(client_with_exception) assert await integration_setup(client_with_exception)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device_entry = device_registry.async_get_or_create( device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id, config_entry_id=config_entry.entry_id,

View File

@ -92,7 +92,7 @@ async def test_paired_depaired_devices_flow(
) )
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)}) device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)})
assert device assert device
@ -181,7 +181,7 @@ async def test_connected_devices(
client.get_settings = AsyncMock(side_effect=get_settings_side_effect) client.get_settings = AsyncMock(side_effect=get_settings_side_effect)
client.get_all_programs = AsyncMock(side_effect=get_all_programs_side_effect) client.get_all_programs = AsyncMock(side_effect=get_all_programs_side_effect)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
client.get_settings = get_settings_original_mock client.get_settings = get_settings_original_mock
client.get_all_programs = get_all_programs_mock client.get_all_programs = get_all_programs_mock
@ -229,7 +229,7 @@ async def test_switch_entity_availability(
"switch.dishwasher_program_eco50", "switch.dishwasher_program_eco50",
] ]
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
for entity_id in entity_ids: for entity_id in entity_ids:
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
@ -311,7 +311,7 @@ async def test_switch_functionality(
"""Test switch functionality.""" """Test switch functionality."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
await hass.services.async_call(SWITCH_DOMAIN, service, {ATTR_ENTITY_ID: entity_id}) await hass.services.async_call(SWITCH_DOMAIN, service, {ATTR_ENTITY_ID: entity_id})
await hass.async_block_till_done() await hass.async_block_till_done()
@ -377,7 +377,7 @@ async def test_program_switch_functionality(
client.stop_program = AsyncMock(side_effect=mock_stop_program) client.stop_program = AsyncMock(side_effect=mock_stop_program)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert hass.states.is_state(entity_id, initial_state) assert hass.states.is_state(entity_id, initial_state)
await hass.services.async_call( await hass.services.async_call(
@ -484,7 +484,7 @@ async def test_switch_exception_handling(
) )
assert await integration_setup(client_with_exception) assert await integration_setup(client_with_exception)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
# Assert that an exception is called. # Assert that an exception is called.
with pytest.raises(HomeConnectError): with pytest.raises(HomeConnectError):
@ -527,7 +527,7 @@ async def test_ent_desc_switch_functionality(
"""Test switch functionality - entity description setup.""" """Test switch functionality - entity description setup."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
await hass.services.async_call(SWITCH_DOMAIN, service, {ATTR_ENTITY_ID: entity_id}) await hass.services.async_call(SWITCH_DOMAIN, service, {ATTR_ENTITY_ID: entity_id})
await hass.async_block_till_done() await hass.async_block_till_done()
@ -583,7 +583,7 @@ async def test_ent_desc_switch_exception_handling(
] ]
) )
assert await integration_setup(client_with_exception) assert await integration_setup(client_with_exception)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
# Assert that an exception is called. # Assert that an exception is called.
with pytest.raises(HomeConnectError): with pytest.raises(HomeConnectError):
@ -668,7 +668,7 @@ async def test_power_switch(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
await hass.services.async_call(SWITCH_DOMAIN, service, {ATTR_ENTITY_ID: entity_id}) await hass.services.async_call(SWITCH_DOMAIN, service, {ATTR_ENTITY_ID: entity_id})
await hass.async_block_till_done() await hass.async_block_till_done()
@ -707,7 +707,7 @@ async def test_power_switch_fetch_off_state_from_current_value(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert hass.states.is_state("switch.dishwasher_power", STATE_OFF) assert hass.states.is_state("switch.dishwasher_power", STATE_OFF)
@ -772,7 +772,7 @@ async def test_power_switch_service_validation_errors(
client.get_setting = AsyncMock(return_value=setting) client.get_setting = AsyncMock(return_value=setting)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
with pytest.raises(HomeAssistantError, match=exception_match): with pytest.raises(HomeAssistantError, match=exception_match):
await hass.services.async_call( await hass.services.async_call(
@ -832,7 +832,7 @@ async def test_create_program_switch_deprecation_issue(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
await hass.services.async_call( await hass.services.async_call(
SWITCH_DOMAIN, SWITCH_DOMAIN,
@ -912,7 +912,7 @@ async def test_program_switch_deprecation_issue_fix(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
await hass.services.async_call( await hass.services.async_call(
SWITCH_DOMAIN, SWITCH_DOMAIN,
@ -1006,7 +1006,7 @@ async def test_options_functionality(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
assert hass.states.get(entity_id) assert hass.states.get(entity_id)
await hass.services.async_call( await hass.services.async_call(

View File

@ -58,7 +58,7 @@ async def test_paired_depaired_devices_flow(
) -> None: ) -> None:
"""Test that removed devices are correctly removed from and added to hass on API events.""" """Test that removed devices are correctly removed from and added to hass on API events."""
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)}) device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)})
assert device assert device
@ -135,7 +135,7 @@ async def test_connected_devices(
client.get_settings = AsyncMock(side_effect=get_settings_side_effect) client.get_settings = AsyncMock(side_effect=get_settings_side_effect)
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
client.get_settings = get_settings_original_mock client.get_settings = get_settings_original_mock
device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)}) device = device_registry.async_get_device(identifiers={(DOMAIN, appliance.ha_id)})
@ -180,7 +180,7 @@ async def test_time_entity_availability(
"time.oven_alarm_clock", "time.oven_alarm_clock",
] ]
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
for entity_id in entity_ids: for entity_id in entity_ids:
state = hass.states.get(entity_id) state = hass.states.get(entity_id)
@ -363,7 +363,7 @@ async def test_create_alarm_clock_deprecation_issue(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
await hass.services.async_call( await hass.services.async_call(
TIME_DOMAIN, TIME_DOMAIN,
@ -442,7 +442,7 @@ async def test_alarm_clock_deprecation_issue_fix(
) )
assert await integration_setup(client) assert await integration_setup(client)
assert config_entry.state == ConfigEntryState.LOADED assert config_entry.state is ConfigEntryState.LOADED
await hass.services.async_call( await hass.services.async_call(
TIME_DOMAIN, TIME_DOMAIN,