mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Use real devices in light device action tests (#102722)
This commit is contained in:
parent
69ce85d5af
commit
02a83740cc
@ -467,12 +467,21 @@ async def test_get_action_capabilities_features_legacy(
|
|||||||
|
|
||||||
async def test_action(
|
async def test_action(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
calls,
|
calls,
|
||||||
enable_custom_integrations: None,
|
enable_custom_integrations: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for turn_on and turn_off actions."""
|
"""Test for turn_on and turn_off 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(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
@ -483,7 +492,7 @@ async def test_action(
|
|||||||
"trigger": {"platform": "event", "event_type": "test_off"},
|
"trigger": {"platform": "event", "event_type": "test_off"},
|
||||||
"action": {
|
"action": {
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "turn_off",
|
"type": "turn_off",
|
||||||
},
|
},
|
||||||
@ -492,7 +501,7 @@ async def test_action(
|
|||||||
"trigger": {"platform": "event", "event_type": "test_on"},
|
"trigger": {"platform": "event", "event_type": "test_on"},
|
||||||
"action": {
|
"action": {
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "turn_on",
|
"type": "turn_on",
|
||||||
},
|
},
|
||||||
@ -501,7 +510,7 @@ async def test_action(
|
|||||||
"trigger": {"platform": "event", "event_type": "test_toggle"},
|
"trigger": {"platform": "event", "event_type": "test_toggle"},
|
||||||
"action": {
|
"action": {
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "toggle",
|
"type": "toggle",
|
||||||
},
|
},
|
||||||
@ -510,7 +519,7 @@ async def test_action(
|
|||||||
"trigger": {"platform": "event", "event_type": "test_flash_short"},
|
"trigger": {"platform": "event", "event_type": "test_flash_short"},
|
||||||
"action": {
|
"action": {
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "flash",
|
"type": "flash",
|
||||||
},
|
},
|
||||||
@ -519,7 +528,7 @@ async def test_action(
|
|||||||
"trigger": {"platform": "event", "event_type": "test_flash_long"},
|
"trigger": {"platform": "event", "event_type": "test_flash_long"},
|
||||||
"action": {
|
"action": {
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "flash",
|
"type": "flash",
|
||||||
"flash": "long",
|
"flash": "long",
|
||||||
@ -532,7 +541,7 @@ async def test_action(
|
|||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "brightness_increase",
|
"type": "brightness_increase",
|
||||||
},
|
},
|
||||||
@ -544,7 +553,7 @@ async def test_action(
|
|||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "brightness_decrease",
|
"type": "brightness_decrease",
|
||||||
},
|
},
|
||||||
@ -553,7 +562,7 @@ async def test_action(
|
|||||||
"trigger": {"platform": "event", "event_type": "test_brightness"},
|
"trigger": {"platform": "event", "event_type": "test_brightness"},
|
||||||
"action": {
|
"action": {
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "turn_on",
|
"type": "turn_on",
|
||||||
"brightness_pct": 75,
|
"brightness_pct": 75,
|
||||||
@ -623,12 +632,21 @@ async def test_action(
|
|||||||
|
|
||||||
async def test_action_legacy(
|
async def test_action_legacy(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
calls,
|
calls,
|
||||||
enable_custom_integrations: None,
|
enable_custom_integrations: None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for turn_on and turn_off actions."""
|
"""Test for turn_on and turn_off 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(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
@ -639,7 +657,7 @@ async def test_action_legacy(
|
|||||||
"trigger": {"platform": "event", "event_type": "test_off"},
|
"trigger": {"platform": "event", "event_type": "test_off"},
|
||||||
"action": {
|
"action": {
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.entity_id,
|
"entity_id": entry.entity_id,
|
||||||
"type": "turn_off",
|
"type": "turn_off",
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user