Skip to content

Commit

Permalink
Fix snooz tests (#127468)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Oct 5, 2024
1 parent 00df42b commit c104e66
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions tests/components/snooz/test_fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from datetime import timedelta
from unittest.mock import Mock
from unittest.mock import Mock, patch

from pysnooz.api import SnoozDeviceState, UnknownSnoozState
from pysnooz.commands import SnoozCommandResult, SnoozCommandResultStatus
Expand Down Expand Up @@ -32,6 +32,8 @@

from . import SnoozFixture, create_mock_snooz, create_mock_snooz_config_entry

from tests.components.bluetooth import generate_ble_device


async def test_turn_on(hass: HomeAssistant, snooz_fan_entity_id: str) -> None:
"""Test turning on the device."""
Expand Down Expand Up @@ -200,7 +202,14 @@ async def test_restore_state(
assert state.state == STATE_UNAVAILABLE

# reload entry
await create_mock_snooz_config_entry(hass, device)
with (
patch("homeassistant.components.snooz.SnoozDevice", return_value=device),
patch(
"homeassistant.components.snooz.async_ble_device_from_address",
return_value=generate_ble_device(device.address, device.name),
),
):
await hass.config_entries.async_setup(entry.entry_id)

# should match last known state
state = hass.states.get(entity_id)
Expand All @@ -225,7 +234,14 @@ async def test_restore_unknown_state(
assert state.state == STATE_UNAVAILABLE

# reload entry
await create_mock_snooz_config_entry(hass, device)
with (
patch("homeassistant.components.snooz.SnoozDevice", return_value=device),
patch(
"homeassistant.components.snooz.async_ble_device_from_address",
return_value=generate_ble_device(device.address, device.name),
),
):
await hass.config_entries.async_setup(entry.entry_id)

# should match last known state
state = hass.states.get(entity_id)
Expand Down

0 comments on commit c104e66

Please sign in to comment.