From 40b98b70b0d4aab36140d37deb170fbcd78cb6df Mon Sep 17 00:00:00 2001 From: Shay Levy Date: Thu, 13 Jun 2024 22:36:03 +0300 Subject: [PATCH] Wait for background tasks in Shelly tests (#119636) --- tests/components/shelly/test_config_flow.py | 2 +- tests/components/shelly/test_coordinator.py | 2 +- tests/components/shelly/test_init.py | 6 +++--- tests/components/shelly/test_number.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/components/shelly/test_config_flow.py b/tests/components/shelly/test_config_flow.py index f6467215faa..a26c6eac405 100644 --- a/tests/components/shelly/test_config_flow.py +++ b/tests/components/shelly/test_config_flow.py @@ -1125,7 +1125,7 @@ async def test_zeroconf_sleeping_device_not_triggers_refresh( await hass.async_block_till_done() mock_rpc_device.mock_online() - await hass.async_block_till_done() + await hass.async_block_till_done(wait_background_tasks=True) assert "online, resuming setup" in caplog.text assert len(mock_rpc_device.initialize.mock_calls) == 1 diff --git a/tests/components/shelly/test_coordinator.py b/tests/components/shelly/test_coordinator.py index 895d18cd7e1..1e0af115c9e 100644 --- a/tests/components/shelly/test_coordinator.py +++ b/tests/components/shelly/test_coordinator.py @@ -352,7 +352,7 @@ async def test_block_button_click_event( # Make device online mock_block_device.mock_online() - await hass.async_block_till_done() + await hass.async_block_till_done(wait_background_tasks=True) device = dr.async_entries_for_config_entry(device_registry, entry.entry_id)[0] diff --git a/tests/components/shelly/test_init.py b/tests/components/shelly/test_init.py index 05d306c76ff..998d56fc6cc 100644 --- a/tests/components/shelly/test_init.py +++ b/tests/components/shelly/test_init.py @@ -263,7 +263,7 @@ async def test_sleeping_block_device_online( assert "will resume when device is online" in caplog.text mock_block_device.mock_online() - await hass.async_block_till_done() + await hass.async_block_till_done(wait_background_tasks=True) assert "online, resuming setup" in caplog.text assert entry.data["sleep_period"] == device_sleep @@ -284,7 +284,7 @@ async def test_sleeping_rpc_device_online( assert "will resume when device is online" in caplog.text mock_rpc_device.mock_online() - await hass.async_block_till_done() + await hass.async_block_till_done(wait_background_tasks=True) assert "online, resuming setup" in caplog.text assert entry.data["sleep_period"] == device_sleep @@ -302,7 +302,7 @@ async def test_sleeping_rpc_device_online_new_firmware( mutate_rpc_device_status(monkeypatch, mock_rpc_device, "sys", "wakeup_period", 1500) mock_rpc_device.mock_online() - await hass.async_block_till_done() + await hass.async_block_till_done(wait_background_tasks=True) assert "online, resuming setup" in caplog.text assert entry.data["sleep_period"] == 1500 diff --git a/tests/components/shelly/test_number.py b/tests/components/shelly/test_number.py index 3f0f3ae8686..ff453b3251c 100644 --- a/tests/components/shelly/test_number.py +++ b/tests/components/shelly/test_number.py @@ -188,7 +188,7 @@ async def test_block_set_value_connection_error( # Make device online mock_block_device.mock_online() - await hass.async_block_till_done() + await hass.async_block_till_done(wait_background_tasks=True) with pytest.raises(HomeAssistantError): await hass.services.async_call(