feat: add location and branch topology with scoped navigation
This commit is contained in:
1 parent
4a8da8ad0c
commit
bffc4d0acc
30 files changed
+3172
-2491
No files matched your search
@@ -19,6 +19,54 @@ from custom_components.nextfloor.schema import (
|
||||
ROOM = {"id": "r1", "name": "Bad", "area_id": None, "points": [[0, 0], [2, 0], [2, 2]], "floor_material": "tiles"}
|
||||
|
||||
|
||||
def test_topology_and_per_location_outdoor_membership_survive_validation() -> None:
|
||||
from custom_components.nextfloor.schema import BUILDING_SCHEMA, empty_building
|
||||
|
||||
topology = {
|
||||
"locations": [{"id": "urbach", "name": "Urbach"}, {"id": "ulm", "name": "Ulm"}],
|
||||
"branches": [{"id": "hq", "name": "Zentrale", "location_id": "urbach"}],
|
||||
"buildings": [{"id": "ras19", "name": "RAS19", "branch_id": "hq"}],
|
||||
}
|
||||
floor = {
|
||||
"id": "eg",
|
||||
"name": "EG",
|
||||
"elevation": 0,
|
||||
"height": 2.5,
|
||||
"cut_height": 1.15,
|
||||
"rooms": [ROOM],
|
||||
"openings": [],
|
||||
"placements": [],
|
||||
"furniture": [],
|
||||
"background": None,
|
||||
"outdoor": [],
|
||||
"building_id": "ras19",
|
||||
"outdoor_location_id": None,
|
||||
}
|
||||
outdoor = {
|
||||
**floor,
|
||||
"id": "garden",
|
||||
"name": "Außen",
|
||||
"building_id": None,
|
||||
"outdoor_location_id": "urbach",
|
||||
"rooms": [],
|
||||
}
|
||||
b = {**empty_building(), "topology": topology, "floors": [floor, outdoor]}
|
||||
result = BUILDING_SCHEMA(b)
|
||||
assert result["topology"] == topology
|
||||
assert result["floors"][0]["building_id"] == "ras19"
|
||||
assert result["floors"][1]["outdoor_location_id"] == "urbach"
|
||||
assert "topology" not in BUILDING_SCHEMA(empty_building())
|
||||
for bad in (
|
||||
{**b, "topology": {**topology, "branches": [{"id": "hq", "name": "Zentrale", "location_id": 12}]}},
|
||||
{**b, "topology": {**topology, "buildings": [{"id": "ras19", "name": "RAS19", "branch_id": "invalid/id"}]}},
|
||||
{**b, "floors": [{**floor, "building_id": 123}]},
|
||||
{**b, "floors": [{**outdoor, "outdoor_location_id": 123}]},
|
||||
{**b, "floors": [floor] * 129},
|
||||
):
|
||||
with pytest.raises(vol.Invalid):
|
||||
BUILDING_SCHEMA(bad)
|
||||
|
||||
|
||||
def test_charging_station_links_formats_and_clearing_survive_validation() -> None:
|
||||
charging = {
|
||||
"soc": "cover.1",
|
||||
|
||||
Reference in new issue
Block a user