mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add typing to tests with single hass argument (2) (#87675)
* Add typing to tests with single hass argument (2) * a few more
This commit is contained in:
@@ -3,7 +3,7 @@ from datetime import datetime, timedelta
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.core import CoreState, State
|
||||
from homeassistant.core import CoreState, HomeAssistant, State
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.restore_state import (
|
||||
@@ -18,7 +18,7 @@ from homeassistant.util import dt as dt_util
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
|
||||
async def test_caching_data(hass):
|
||||
async def test_caching_data(hass: HomeAssistant) -> None:
|
||||
"""Test that we cache data."""
|
||||
now = dt_util.utcnow()
|
||||
stored_states = [
|
||||
@@ -52,7 +52,7 @@ async def test_caching_data(hass):
|
||||
assert mock_write_data.called
|
||||
|
||||
|
||||
async def test_periodic_write(hass):
|
||||
async def test_periodic_write(hass: HomeAssistant) -> None:
|
||||
"""Test that we write periodiclly but not after stop."""
|
||||
data = await RestoreStateData.async_get_instance(hass)
|
||||
await hass.async_block_till_done()
|
||||
@@ -98,7 +98,7 @@ async def test_periodic_write(hass):
|
||||
assert not mock_write_data.called
|
||||
|
||||
|
||||
async def test_save_persistent_states(hass):
|
||||
async def test_save_persistent_states(hass: HomeAssistant) -> None:
|
||||
"""Test that we cancel the currently running job, save the data, and verify the perdiodic job continues."""
|
||||
data = await RestoreStateData.async_get_instance(hass)
|
||||
await hass.async_block_till_done()
|
||||
@@ -154,7 +154,7 @@ async def test_save_persistent_states(hass):
|
||||
assert mock_write_data.called
|
||||
|
||||
|
||||
async def test_hass_starting(hass):
|
||||
async def test_hass_starting(hass: HomeAssistant) -> None:
|
||||
"""Test that we cache data."""
|
||||
hass.state = CoreState.starting
|
||||
|
||||
@@ -203,7 +203,7 @@ async def test_hass_starting(hass):
|
||||
assert mock_write_data.called
|
||||
|
||||
|
||||
async def test_dump_data(hass):
|
||||
async def test_dump_data(hass: HomeAssistant) -> None:
|
||||
"""Test that we cache data."""
|
||||
states = [
|
||||
State("input_boolean.b0", "on"),
|
||||
@@ -278,7 +278,7 @@ async def test_dump_data(hass):
|
||||
assert written_states[1]["state"]["state"] == "off"
|
||||
|
||||
|
||||
async def test_dump_error(hass):
|
||||
async def test_dump_error(hass: HomeAssistant) -> None:
|
||||
"""Test that we cache data."""
|
||||
states = [
|
||||
State("input_boolean.b0", "on"),
|
||||
@@ -307,7 +307,7 @@ async def test_dump_error(hass):
|
||||
assert mock_write_data.called
|
||||
|
||||
|
||||
async def test_load_error(hass):
|
||||
async def test_load_error(hass: HomeAssistant) -> None:
|
||||
"""Test that we cache data."""
|
||||
entity = RestoreEntity()
|
||||
entity.hass = hass
|
||||
@@ -322,7 +322,7 @@ async def test_load_error(hass):
|
||||
assert state is None
|
||||
|
||||
|
||||
async def test_state_saved_on_remove(hass):
|
||||
async def test_state_saved_on_remove(hass: HomeAssistant) -> None:
|
||||
"""Test that we save entity state on removal."""
|
||||
entity = RestoreEntity()
|
||||
entity.hass = hass
|
||||
|
||||
Reference in New Issue
Block a user