From ac6ee34bf24f6f22ba810d45db96a1627b27fa33 Mon Sep 17 00:00:00 2001 From: Tim Lunn Date: Thu, 3 Oct 2024 12:40:05 +0000 Subject: [PATCH] fix update tests --- tests/components/smlight/conftest.py | 10 ++++++++++ tests/components/smlight/test_update.py | 3 +++ 2 files changed, 13 insertions(+) diff --git a/tests/components/smlight/conftest.py b/tests/components/smlight/conftest.py index 665a55ba880a7..6ec63901b77d3 100644 --- a/tests/components/smlight/conftest.py +++ b/tests/components/smlight/conftest.py @@ -71,6 +71,16 @@ def mock_setup_entry() -> Generator[AsyncMock]: yield mock_setup_entry +@pytest.fixture +def mock_update_sleep() -> Generator[AsyncMock]: + """Fixture to mock asyncio.sleep.""" + with patch( + "homeassistant.components.smlight.update.asyncio.sleep", + return_value=AsyncMock(), + ) as mock_sleep: + yield mock_sleep + + @pytest.fixture def mock_smlight_client(request: pytest.FixtureRequest) -> Generator[MagicMock]: """Mock the SMLIGHT API client.""" diff --git a/tests/components/smlight/test_update.py b/tests/components/smlight/test_update.py index 7bff12bb027a8..74dabd5a38d4c 100644 --- a/tests/components/smlight/test_update.py +++ b/tests/components/smlight/test_update.py @@ -87,6 +87,7 @@ async def test_update_setup( await hass.config_entries.async_unload(entry.entry_id) +@pytest.mark.usefixtures("mock_update_sleep") async def test_update_firmware( hass: HomeAssistant, freezer: FrozenDateTimeFactory, @@ -134,6 +135,7 @@ async def test_update_firmware( assert state.attributes[ATTR_LATEST_VERSION] == "v2.5.2" +@pytest.mark.usefixtures("mock_update_sleep") async def test_update_legacy_firmware_v2( hass: HomeAssistant, freezer: FrozenDateTimeFactory, @@ -213,6 +215,7 @@ async def _call_event_function(event: MessageEvent): assert state.attributes[ATTR_IN_PROGRESS] is False +@pytest.mark.usefixtures("mock_update_sleep") async def test_update_release_notes( hass: HomeAssistant, freezer: FrozenDateTimeFactory,