1414from homeassistant .core import HomeAssistant
1515from homeassistant .helpers import entity_registry as er
1616
17- from .common import ENTITY_INFO , mock_api_device , setup_platform
17+ from .common import mock_api_device , setup_platform
1818
1919
2020async def test_cover_entity (
@@ -25,26 +25,54 @@ async def test_cover_entity(
2525) -> None :
2626 """Tests cover entity."""
2727
28- device_name = "Cover Controller"
29- entity_key = "cover.cover_controller_test_entity_name"
28+ blind_device_name = "Blind Controller"
29+ blind_entity_key = "cover.blind_controller_test_entity_name"
30+ blind_entity_id = "test-entity-id-blind"
31+ door_device_name = "Cover Controller"
32+ door_entity_key = "cover.cover_controller_test_entity_name"
33+ door_entity_id = "test-entity-id-door"
3034 entity_type = Platform .COVER
3135
32- mock_api .doors = [mock_api_device (device_name = device_name , entity_type = entity_type )]
36+ mock_api .blinds = [
37+ mock_api_device (
38+ device_name = blind_device_name ,
39+ entity_type = entity_type ,
40+ entity_id = blind_entity_id ,
41+ )
42+ ]
43+ mock_api .doors = [
44+ mock_api_device (
45+ device_name = door_device_name ,
46+ entity_type = entity_type ,
47+ entity_id = door_entity_id ,
48+ )
49+ ]
3350
3451 await setup_platform (hass , entity_type )
3552
36- entity = entity_registry .entities [entity_key ]
37- assert entity .unique_id == ENTITY_INFO [ "id" ]
53+ blind_entity = entity_registry .entities [blind_entity_key ]
54+ assert blind_entity .unique_id == blind_entity_id
3855
3956 assert (
40- entity .supported_features
57+ blind_entity .supported_features
4158 == CoverEntityFeature .OPEN
4259 | CoverEntityFeature .CLOSE
4360 | CoverEntityFeature .STOP
4461 | CoverEntityFeature .SET_POSITION
4562 )
4663
47- state = hass .states .get (entity_key )
64+ door_entity = entity_registry .entities [door_entity_key ]
65+ assert door_entity .unique_id == door_entity_id
66+
67+ assert (
68+ door_entity .supported_features
69+ == CoverEntityFeature .OPEN
70+ | CoverEntityFeature .CLOSE
71+ | CoverEntityFeature .STOP
72+ | CoverEntityFeature .SET_POSITION
73+ )
74+
75+ state = hass .states .get (door_entity_key )
4876 assert state == snapshot
4977
5078 services = hass .services .async_services ()
@@ -53,7 +81,7 @@ async def test_cover_entity(
5381 await hass .services .async_call (
5482 entity_type ,
5583 SERVICE_CLOSE_COVER ,
56- {"entity_id" : entity_key },
84+ {"entity_id" : door_entity_key },
5785 blocking = True ,
5886 )
5987 assert mock_api .doors [0 ].close_door .called
@@ -62,7 +90,7 @@ async def test_cover_entity(
6290 await hass .services .async_call (
6391 entity_type ,
6492 SERVICE_OPEN_COVER ,
65- {"entity_id" : entity_key },
93+ {"entity_id" : door_entity_key },
6694 blocking = True ,
6795 )
6896 assert mock_api .doors [0 ].open_door .called
@@ -71,7 +99,7 @@ async def test_cover_entity(
7199 await hass .services .async_call (
72100 entity_type ,
73101 SERVICE_SET_COVER_POSITION ,
74- {"entity_id" : entity_key , "position" : 50 },
102+ {"entity_id" : door_entity_key , "position" : 50 },
75103 blocking = True ,
76104 )
77105 assert mock_api .doors [0 ].open_to_percentage .called
0 commit comments