From 7bd126dc8ea0bba4fa77a50128017aae1b246b3e Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Fri, 15 Aug 2025 13:04:12 +0200 Subject: [PATCH] Assert the MQTT config entry is reloaded on subentry creation and mutation (#150636) --- tests/components/mqtt/test_config_flow.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/components/mqtt/test_config_flow.py b/tests/components/mqtt/test_config_flow.py index ff1f954bace..3b4f090aef3 100644 --- a/tests/components/mqtt/test_config_flow.py +++ b/tests/components/mqtt/test_config_flow.py @@ -3367,6 +3367,7 @@ async def test_migrate_of_incompatible_config_entry( async def test_subentry_configflow( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, + mock_reload_after_entry_update: MagicMock, config_subentries_data: dict[str, Any], mock_device_user_input: dict[str, Any], mock_entity_user_input: dict[str, Any], @@ -3501,6 +3502,10 @@ async def test_subentry_configflow( assert subentry_device_data[option] == value await hass.async_block_till_done() + await hass.async_block_till_done(wait_background_tasks=True) + + # Assert the entry is reloaded to set up the entity + assert len(mock_reload_after_entry_update.mock_calls) == 1 @pytest.mark.parametrize( @@ -3641,6 +3646,7 @@ async def test_subentry_reconfigure_remove_entity( async def test_subentry_reconfigure_edit_entity_multi_entitites( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator, + mock_reload_after_entry_update: MagicMock, device_registry: dr.DeviceRegistry, entity_registry: er.EntityRegistry, user_input_mqtt: dict[str, Any], @@ -3758,6 +3764,10 @@ async def test_subentry_reconfigure_edit_entity_multi_entitites( for key, value in user_input_mqtt.items(): assert new_components[object_list[1]][key] == value + # Assert the entry is reloaded to set up the entity + await hass.async_block_till_done(wait_background_tasks=True) + assert len(mock_reload_after_entry_update.mock_calls) == 1 + @pytest.mark.parametrize( (