From 935b913bc7802e091f9b10e82545b66b56045d9e Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Wed, 1 Jan 2025 22:49:58 -0800 Subject: [PATCH] Fix test_proactive_adaptation_with_separate_commands (#1158) --- tests/test_switch.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_switch.py b/tests/test_switch.py index afc720e5..34554872 100644 --- a/tests/test_switch.py +++ b/tests/test_switch.py @@ -1602,7 +1602,6 @@ async def test_proactive_adaptation(hass): assert state.attributes[ATTR_COLOR_TEMP_KELVIN] == 3448 -# TODO: Breaks since 2024.5.0! async def test_proactive_adaptation_with_separate_commands(hass): """Validate that a split proactive adaptation yields one additional service call.""" switch, _ = await setup_lights_and_switch( @@ -1623,11 +1622,16 @@ async def test_proactive_adaptation_with_separate_commands(hass): }, ) - event_context_ids = await _turn_on_and_track_event_contexts( + events = await _turn_on_and_track_event_contexts( hass, "test_context", ENTITY_LIGHT_3, + return_full_events=True, ) + # Wait for all adaptation tasks to complete + await asyncio.gather(*switch.manager.adaptation_tasks) + await hass.async_block_till_done() + event_context_ids = [event.context.id for event in events] # Expect two service calls assert len(event_context_ids) == 2, event_context_ids