mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Improve type hints in registry helper tests (#119302)
This commit is contained in:
@@ -8,14 +8,6 @@ import pytest
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import area_registry as ar, floor_registry as fr
|
||||
from homeassistant.helpers.floor_registry import (
|
||||
EVENT_FLOOR_REGISTRY_UPDATED,
|
||||
STORAGE_KEY,
|
||||
STORAGE_VERSION_MAJOR,
|
||||
FloorRegistry,
|
||||
async_get,
|
||||
async_load,
|
||||
)
|
||||
|
||||
from tests.common import async_capture_events, flush_store
|
||||
|
||||
@@ -30,7 +22,7 @@ async def test_create_floor(
|
||||
hass: HomeAssistant, floor_registry: fr.FloorRegistry
|
||||
) -> None:
|
||||
"""Make sure that we can create floors."""
|
||||
update_events = async_capture_events(hass, EVENT_FLOOR_REGISTRY_UPDATED)
|
||||
update_events = async_capture_events(hass, fr.EVENT_FLOOR_REGISTRY_UPDATED)
|
||||
floor = floor_registry.async_create(
|
||||
name="First floor",
|
||||
icon="mdi:home-floor-1",
|
||||
@@ -59,7 +51,7 @@ async def test_create_floor_with_name_already_in_use(
|
||||
hass: HomeAssistant, floor_registry: fr.FloorRegistry
|
||||
) -> None:
|
||||
"""Make sure that we can't create a floor with a name already in use."""
|
||||
update_events = async_capture_events(hass, EVENT_FLOOR_REGISTRY_UPDATED)
|
||||
update_events = async_capture_events(hass, fr.EVENT_FLOOR_REGISTRY_UPDATED)
|
||||
floor_registry.async_create("First floor")
|
||||
|
||||
with pytest.raises(
|
||||
@@ -75,7 +67,7 @@ async def test_create_floor_with_name_already_in_use(
|
||||
|
||||
|
||||
async def test_create_floor_with_id_already_in_use(
|
||||
hass: HomeAssistant, floor_registry: fr.FloorRegistry
|
||||
floor_registry: fr.FloorRegistry,
|
||||
) -> None:
|
||||
"""Make sure that we can't create an floor with an id already in use."""
|
||||
floor = floor_registry.async_create("First")
|
||||
@@ -92,7 +84,7 @@ async def test_delete_floor(
|
||||
hass: HomeAssistant, floor_registry: fr.FloorRegistry
|
||||
) -> None:
|
||||
"""Make sure that we can delete a floor."""
|
||||
update_events = async_capture_events(hass, EVENT_FLOOR_REGISTRY_UPDATED)
|
||||
update_events = async_capture_events(hass, fr.EVENT_FLOOR_REGISTRY_UPDATED)
|
||||
floor = floor_registry.async_create("First floor")
|
||||
assert len(floor_registry.floors) == 1
|
||||
|
||||
@@ -127,7 +119,7 @@ async def test_update_floor(
|
||||
hass: HomeAssistant, floor_registry: fr.FloorRegistry
|
||||
) -> None:
|
||||
"""Make sure that we can update floors."""
|
||||
update_events = async_capture_events(hass, EVENT_FLOOR_REGISTRY_UPDATED)
|
||||
update_events = async_capture_events(hass, fr.EVENT_FLOOR_REGISTRY_UPDATED)
|
||||
floor = floor_registry.async_create("First floor")
|
||||
|
||||
assert len(floor_registry.floors) == 1
|
||||
@@ -171,7 +163,7 @@ async def test_update_floor_with_same_data(
|
||||
hass: HomeAssistant, floor_registry: fr.FloorRegistry
|
||||
) -> None:
|
||||
"""Make sure that we can reapply the same data to a floor and it won't update."""
|
||||
update_events = async_capture_events(hass, EVENT_FLOOR_REGISTRY_UPDATED)
|
||||
update_events = async_capture_events(hass, fr.EVENT_FLOOR_REGISTRY_UPDATED)
|
||||
floor = floor_registry.async_create(
|
||||
"First floor",
|
||||
icon="mdi:home-floor-1",
|
||||
@@ -262,7 +254,7 @@ async def test_load_floors(
|
||||
|
||||
assert len(floor_registry.floors) == 2
|
||||
|
||||
registry2 = FloorRegistry(hass)
|
||||
registry2 = fr.FloorRegistry(hass)
|
||||
await flush_store(floor_registry._store)
|
||||
await registry2.async_load()
|
||||
|
||||
@@ -288,11 +280,11 @@ async def test_load_floors(
|
||||
|
||||
@pytest.mark.parametrize("load_registries", [False])
|
||||
async def test_loading_floors_from_storage(
|
||||
hass: HomeAssistant, hass_storage: Any
|
||||
hass: HomeAssistant, hass_storage: dict[str, Any]
|
||||
) -> None:
|
||||
"""Test loading stored floors on start."""
|
||||
hass_storage[STORAGE_KEY] = {
|
||||
"version": STORAGE_VERSION_MAJOR,
|
||||
hass_storage[fr.STORAGE_KEY] = {
|
||||
"version": fr.STORAGE_VERSION_MAJOR,
|
||||
"data": {
|
||||
"floors": [
|
||||
{
|
||||
@@ -306,8 +298,8 @@ async def test_loading_floors_from_storage(
|
||||
},
|
||||
}
|
||||
|
||||
await async_load(hass)
|
||||
registry = async_get(hass)
|
||||
await fr.async_load(hass)
|
||||
registry = fr.async_get(hass)
|
||||
|
||||
assert len(registry.floors) == 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user