Use real devices in fan device action tests (#102720)

This commit is contained in:
Erik Montnemery 2023-10-24 23:40:24 +02:00 committed by GitHub
parent 21d0fa640f
commit 530611c44e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,9 +103,21 @@ async def test_get_actions_hidden_auxiliary(
assert actions == unordered(expected_actions) assert actions == unordered(expected_actions)
async def test_action(hass: HomeAssistant, entity_registry: er.EntityRegistry) -> None: async def test_action(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
) -> 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,
@ -119,7 +131,7 @@ async def test_action(hass: HomeAssistant, entity_registry: er.EntityRegistry) -
}, },
"action": { "action": {
"domain": DOMAIN, "domain": DOMAIN,
"device_id": "abcdefgh", "device_id": device_entry.id,
"entity_id": entry.id, "entity_id": entry.id,
"type": "turn_off", "type": "turn_off",
}, },
@ -131,7 +143,7 @@ async def test_action(hass: HomeAssistant, entity_registry: er.EntityRegistry) -
}, },
"action": { "action": {
"domain": DOMAIN, "domain": DOMAIN,
"device_id": "abcdefgh", "device_id": device_entry.id,
"entity_id": entry.id, "entity_id": entry.id,
"type": "turn_on", "type": "turn_on",
}, },
@ -143,7 +155,7 @@ async def test_action(hass: HomeAssistant, entity_registry: er.EntityRegistry) -
}, },
"action": { "action": {
"domain": DOMAIN, "domain": DOMAIN,
"device_id": "abcdefgh", "device_id": device_entry.id,
"entity_id": entry.id, "entity_id": entry.id,
"type": "toggle", "type": "toggle",
}, },
@ -176,10 +188,20 @@ async def test_action(hass: HomeAssistant, entity_registry: er.EntityRegistry) -
async def test_action_legacy( async def test_action_legacy(
hass: HomeAssistant, entity_registry: er.EntityRegistry hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
) -> 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,
@ -193,7 +215,7 @@ async def test_action_legacy(
}, },
"action": { "action": {
"domain": DOMAIN, "domain": DOMAIN,
"device_id": "abcdefgh", "device_id": device_entry.id,
"entity_id": entry.entity_id, "entity_id": entry.entity_id,
"type": "turn_off", "type": "turn_off",
}, },