Use real devices in cover device action tests (#102719)
This commit is contained in:
parent
8da421c442
commit
21d0fa640f
1 changed files with 48 additions and 12 deletions
|
@ -351,11 +351,20 @@ async def test_get_action_capabilities_set_tilt_pos(
|
|||
|
||||
async def test_action(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
enable_custom_integrations: None,
|
||||
) -> None:
|
||||
"""Test for cover actions."""
|
||||
entry = entity_registry.async_get_or_create(DOMAIN, "test", "5678")
|
||||
config_entry = MockConfigEntry(domain="test", data={})
|
||||
config_entry.add_to_hass(hass)
|
||||
device_entry = device_registry.async_get_or_create(
|
||||
config_entry_id=config_entry.entry_id,
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||
)
|
||||
entry = entity_registry.async_get_or_create(
|
||||
DOMAIN, "test", "5678", device_id=device_entry.id
|
||||
)
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -366,7 +375,7 @@ async def test_action(
|
|||
"trigger": {"platform": "event", "event_type": "test_event_open"},
|
||||
"action": {
|
||||
"domain": DOMAIN,
|
||||
"device_id": "abcdefgh",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "open",
|
||||
},
|
||||
|
@ -375,7 +384,7 @@ async def test_action(
|
|||
"trigger": {"platform": "event", "event_type": "test_event_close"},
|
||||
"action": {
|
||||
"domain": DOMAIN,
|
||||
"device_id": "abcdefgh",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "close",
|
||||
},
|
||||
|
@ -384,7 +393,7 @@ async def test_action(
|
|||
"trigger": {"platform": "event", "event_type": "test_event_stop"},
|
||||
"action": {
|
||||
"domain": DOMAIN,
|
||||
"device_id": "abcdefgh",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "stop",
|
||||
},
|
||||
|
@ -429,11 +438,20 @@ async def test_action(
|
|||
|
||||
async def test_action_legacy(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
enable_custom_integrations: None,
|
||||
) -> None:
|
||||
"""Test for cover actions."""
|
||||
entry = entity_registry.async_get_or_create(DOMAIN, "test", "5678")
|
||||
config_entry = MockConfigEntry(domain="test", data={})
|
||||
config_entry.add_to_hass(hass)
|
||||
device_entry = device_registry.async_get_or_create(
|
||||
config_entry_id=config_entry.entry_id,
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||
)
|
||||
entry = entity_registry.async_get_or_create(
|
||||
DOMAIN, "test", "5678", device_id=device_entry.id
|
||||
)
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -444,7 +462,7 @@ async def test_action_legacy(
|
|||
"trigger": {"platform": "event", "event_type": "test_event_open"},
|
||||
"action": {
|
||||
"domain": DOMAIN,
|
||||
"device_id": "abcdefgh",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "open",
|
||||
},
|
||||
|
@ -467,11 +485,20 @@ async def test_action_legacy(
|
|||
|
||||
async def test_action_tilt(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
enable_custom_integrations: None,
|
||||
) -> None:
|
||||
"""Test for cover tilt actions."""
|
||||
entry = entity_registry.async_get_or_create(DOMAIN, "test", "5678")
|
||||
config_entry = MockConfigEntry(domain="test", data={})
|
||||
config_entry.add_to_hass(hass)
|
||||
device_entry = device_registry.async_get_or_create(
|
||||
config_entry_id=config_entry.entry_id,
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||
)
|
||||
entry = entity_registry.async_get_or_create(
|
||||
DOMAIN, "test", "5678", device_id=device_entry.id
|
||||
)
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -482,7 +509,7 @@ async def test_action_tilt(
|
|||
"trigger": {"platform": "event", "event_type": "test_event_open"},
|
||||
"action": {
|
||||
"domain": DOMAIN,
|
||||
"device_id": "abcdefgh",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "open_tilt",
|
||||
},
|
||||
|
@ -491,7 +518,7 @@ async def test_action_tilt(
|
|||
"trigger": {"platform": "event", "event_type": "test_event_close"},
|
||||
"action": {
|
||||
"domain": DOMAIN,
|
||||
"device_id": "abcdefgh",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "close_tilt",
|
||||
},
|
||||
|
@ -529,11 +556,20 @@ async def test_action_tilt(
|
|||
|
||||
async def test_action_set_position(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
enable_custom_integrations: None,
|
||||
) -> None:
|
||||
"""Test for cover set position actions."""
|
||||
entry = entity_registry.async_get_or_create(DOMAIN, "test", "5678")
|
||||
config_entry = MockConfigEntry(domain="test", data={})
|
||||
config_entry.add_to_hass(hass)
|
||||
device_entry = device_registry.async_get_or_create(
|
||||
config_entry_id=config_entry.entry_id,
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
|
||||
)
|
||||
entry = entity_registry.async_get_or_create(
|
||||
DOMAIN, "test", "5678", device_id=device_entry.id
|
||||
)
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -547,7 +583,7 @@ async def test_action_set_position(
|
|||
},
|
||||
"action": {
|
||||
"domain": DOMAIN,
|
||||
"device_id": "abcdefgh",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "set_position",
|
||||
"position": 25,
|
||||
|
@ -560,7 +596,7 @@ async def test_action_set_position(
|
|||
},
|
||||
"action": {
|
||||
"domain": DOMAIN,
|
||||
"device_id": "abcdefgh",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "set_tilt_position",
|
||||
"position": 75,
|
||||
|
|
Loading…
Add table
Reference in a new issue