@@ -172,6 +172,39 @@ async def test_create_area(
172172 }
173173 assert len (area_registry .areas ) == 2
174174
175+ # Create area with invalid aliases
176+ await client .send_json_auto_id (
177+ {
178+ "aliases" : [" alias_1 " , "" , " " ],
179+ "floor_id" : "first_floor" ,
180+ "icon" : "mdi:garage" ,
181+ "labels" : ["label_1" , "label_2" ],
182+ "name" : "mock 3" ,
183+ "picture" : "/image/example.png" ,
184+ "temperature_entity_id" : "sensor.mock_temperature" ,
185+ "humidity_entity_id" : "sensor.mock_humidity" ,
186+ "type" : "config/area_registry/create" ,
187+ }
188+ )
189+
190+ msg = await client .receive_json ()
191+
192+ assert msg ["success" ]
193+ assert msg ["result" ] == {
194+ "aliases" : unordered (["alias_1" ]),
195+ "area_id" : ANY ,
196+ "floor_id" : "first_floor" ,
197+ "icon" : "mdi:garage" ,
198+ "labels" : unordered (["label_1" , "label_2" ]),
199+ "name" : "mock 3" ,
200+ "picture" : "/image/example.png" ,
201+ "created_at" : utcnow ().timestamp (),
202+ "modified_at" : utcnow ().timestamp (),
203+ "temperature_entity_id" : "sensor.mock_temperature" ,
204+ "humidity_entity_id" : "sensor.mock_humidity" ,
205+ }
206+ assert len (area_registry .areas ) == 3
207+
175208
176209async def test_create_area_with_name_already_in_use (
177210 client : MockHAClientWebSocket , area_registry : ar .AreaRegistry
@@ -304,6 +337,40 @@ async def test_update_area(
304337 }
305338 assert len (area_registry .areas ) == 1
306339
340+ modified_at = datetime .fromisoformat ("2024-07-16T13:55:00.900075+00:00" )
341+ freezer .move_to (modified_at )
342+
343+ await client .send_json_auto_id (
344+ {
345+ "type" : "config/area_registry/update" ,
346+ "aliases" : ["alias_1" , "" , " " , " alias_2 " ],
347+ "area_id" : area .id ,
348+ "floor_id" : None ,
349+ "humidity_entity_id" : None ,
350+ "icon" : None ,
351+ "labels" : [],
352+ "picture" : None ,
353+ "temperature_entity_id" : None ,
354+ }
355+ )
356+
357+ msg = await client .receive_json ()
358+
359+ assert msg ["result" ] == {
360+ "aliases" : unordered (["alias_1" , "alias_2" ]),
361+ "area_id" : area .id ,
362+ "floor_id" : None ,
363+ "icon" : None ,
364+ "labels" : [],
365+ "name" : "mock 2" ,
366+ "picture" : None ,
367+ "temperature_entity_id" : None ,
368+ "humidity_entity_id" : None ,
369+ "created_at" : created_at .timestamp (),
370+ "modified_at" : modified_at .timestamp (),
371+ }
372+ assert len (area_registry .areas ) == 1
373+
307374
308375async def test_update_area_with_same_name (
309376 client : MockHAClientWebSocket , area_registry : ar .AreaRegistry
0 commit comments