Use freezegun in shelly tests (#99042)
This commit is contained in:
parent
452caee41a
commit
b0952bc54a
5 changed files with 80 additions and 83 deletions
|
@ -2,6 +2,7 @@
|
|||
from unittest.mock import AsyncMock
|
||||
|
||||
from aioshelly.exceptions import DeviceConnectionError, InvalidAuthError, RpcCallError
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.shelly.const import DOMAIN
|
||||
|
@ -37,7 +38,7 @@ from tests.common import mock_restore_cache
|
|||
|
||||
|
||||
async def test_block_update(
|
||||
hass: HomeAssistant, mock_block_device, monkeypatch
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, mock_block_device, monkeypatch
|
||||
) -> None:
|
||||
"""Test block device update entity."""
|
||||
entity_registry = async_get(hass)
|
||||
|
@ -75,7 +76,7 @@ async def test_block_update(
|
|||
assert state.attributes[ATTR_IN_PROGRESS] is True
|
||||
|
||||
monkeypatch.setitem(mock_block_device.status["update"], "old_version", "2")
|
||||
await mock_rest_update(hass)
|
||||
await mock_rest_update(hass, freezer)
|
||||
|
||||
state = hass.states.get("update.test_name_firmware_update")
|
||||
assert state.state == STATE_OFF
|
||||
|
@ -85,7 +86,7 @@ async def test_block_update(
|
|||
|
||||
|
||||
async def test_block_beta_update(
|
||||
hass: HomeAssistant, mock_block_device, monkeypatch
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, mock_block_device, monkeypatch
|
||||
) -> None:
|
||||
"""Test block device beta update entity."""
|
||||
entity_registry = async_get(hass)
|
||||
|
@ -108,7 +109,7 @@ async def test_block_beta_update(
|
|||
assert state.attributes[ATTR_IN_PROGRESS] is False
|
||||
|
||||
monkeypatch.setitem(mock_block_device.status["update"], "beta_version", "2b")
|
||||
await mock_rest_update(hass)
|
||||
await mock_rest_update(hass, freezer)
|
||||
|
||||
state = hass.states.get("update.test_name_beta_firmware_update")
|
||||
assert state.state == STATE_ON
|
||||
|
@ -131,7 +132,7 @@ async def test_block_beta_update(
|
|||
assert state.attributes[ATTR_IN_PROGRESS] is True
|
||||
|
||||
monkeypatch.setitem(mock_block_device.status["update"], "old_version", "2b")
|
||||
await mock_rest_update(hass)
|
||||
await mock_rest_update(hass, freezer)
|
||||
|
||||
state = hass.states.get("update.test_name_beta_firmware_update")
|
||||
assert state.state == STATE_OFF
|
||||
|
@ -389,7 +390,7 @@ async def test_rpc_restored_sleeping_update_no_last_state(
|
|||
|
||||
|
||||
async def test_rpc_beta_update(
|
||||
hass: HomeAssistant, mock_rpc_device, monkeypatch
|
||||
hass: HomeAssistant, freezer: FrozenDateTimeFactory, mock_rpc_device, monkeypatch
|
||||
) -> None:
|
||||
"""Test RPC device beta update entity."""
|
||||
entity_registry = async_get(hass)
|
||||
|
@ -425,7 +426,7 @@ async def test_rpc_beta_update(
|
|||
"beta": {"version": "2b"},
|
||||
},
|
||||
)
|
||||
await mock_rest_update(hass)
|
||||
await mock_rest_update(hass, freezer)
|
||||
|
||||
state = hass.states.get("update.test_name_beta_firmware_update")
|
||||
assert state.state == STATE_ON
|
||||
|
@ -448,7 +449,7 @@ async def test_rpc_beta_update(
|
|||
assert state.attributes[ATTR_IN_PROGRESS] is True
|
||||
|
||||
monkeypatch.setitem(mock_rpc_device.shelly, "ver", "2b")
|
||||
await mock_rest_update(hass)
|
||||
await mock_rest_update(hass, freezer)
|
||||
|
||||
state = hass.states.get("update.test_name_beta_firmware_update")
|
||||
assert state.state == STATE_OFF
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue