Skip to content

Commit

Permalink
fix update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darkxst committed Oct 3, 2024
1 parent 25f4f52 commit ac6ee34
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/components/smlight/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
3 changes: 3 additions & 0 deletions tests/components/smlight/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ac6ee34

Please sign in to comment.