Skip to content

Commit

Permalink
fix for odler versions
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Apr 6, 2024
1 parent 96bbbe0 commit b127ed9
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions tests/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
STATE_OFF,
STATE_ON,
)
from homeassistant.const import __version__ as ha_version
from homeassistant.core import Context, Event, HomeAssistant, State
from homeassistant.helpers import area_registry as ar
from homeassistant.helpers import entity_registry
Expand Down Expand Up @@ -1340,17 +1341,20 @@ def mock_area_registry(
"""Mock the Area Registry."""
registry = ar.AreaRegistry(hass)
registry._area_data = {}
area_in_floor = ar.AreaEntry(
id="test-area",
name="Test area",
aliases={},
normalized_name="test-area",
floor_id="test-floor",
icon=None,
picture=None,
)
area_kwargs = {
"name": "Test Area",
"normalized_name": "test-area",
"aliases": {},
"id": "test-area",
"picture": None,
}
year, month = (int(x) for x in ha_version.split(".")[:2])
if year >= 2024 and month >= 3:
area_kwargs["icon"] = None
area_kwargs["floor_id"] = "test-floor"
area = ar.AreaEntry(**area_kwargs)
registry.areas = ar.AreaRegistryItems()
registry.areas[area_in_floor.id] = area_in_floor
registry.areas[area.id] = area
hass.data[ar.DATA_REGISTRY] = registry
return registry

Expand Down

0 comments on commit b127ed9

Please sign in to comment.