mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Use real devices in select device action tests (#102726)
This commit is contained in:
parent
e708faa4d6
commit
69ce85d5af
@ -116,10 +116,21 @@ async def test_get_actions_hidden_auxiliary(
|
|||||||
|
|
||||||
@pytest.mark.parametrize("action_type", ("select_first", "select_last"))
|
@pytest.mark.parametrize("action_type", ("select_first", "select_last"))
|
||||||
async def test_action_select_first_last(
|
async def test_action_select_first_last(
|
||||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, action_type: str
|
hass: HomeAssistant,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
action_type: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for select_first and select_last actions."""
|
"""Test for select_first and select_last 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,
|
||||||
@ -133,7 +144,7 @@ async def test_action_select_first_last(
|
|||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "abcdefgh",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": action_type,
|
"type": action_type,
|
||||||
},
|
},
|
||||||
@ -154,10 +165,21 @@ async def test_action_select_first_last(
|
|||||||
|
|
||||||
@pytest.mark.parametrize("action_type", ("select_first", "select_last"))
|
@pytest.mark.parametrize("action_type", ("select_first", "select_last"))
|
||||||
async def test_action_select_first_last_legacy(
|
async def test_action_select_first_last_legacy(
|
||||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, action_type: str
|
hass: HomeAssistant,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
action_type: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for select_first and select_last actions."""
|
"""Test for select_first and select_last 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,
|
||||||
@ -171,7 +193,7 @@ async def test_action_select_first_last_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": action_type,
|
"type": action_type,
|
||||||
},
|
},
|
||||||
@ -191,10 +213,20 @@ async def test_action_select_first_last_legacy(
|
|||||||
|
|
||||||
|
|
||||||
async def test_action_select_option(
|
async def test_action_select_option(
|
||||||
hass: HomeAssistant, entity_registry: er.EntityRegistry
|
hass: HomeAssistant,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for select_option action."""
|
"""Test for select_option action."""
|
||||||
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,
|
||||||
@ -208,7 +240,7 @@ async def test_action_select_option(
|
|||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "abcdefgh",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "select_option",
|
"type": "select_option",
|
||||||
"option": "option1",
|
"option": "option1",
|
||||||
@ -230,10 +262,21 @@ async def test_action_select_option(
|
|||||||
|
|
||||||
@pytest.mark.parametrize("action_type", ["select_next", "select_previous"])
|
@pytest.mark.parametrize("action_type", ["select_next", "select_previous"])
|
||||||
async def test_action_select_next_previous(
|
async def test_action_select_next_previous(
|
||||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, action_type: str
|
hass: HomeAssistant,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
action_type: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for select_next and select_previous actions."""
|
"""Test for select_next and select_previous 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,
|
||||||
@ -247,7 +290,7 @@ async def test_action_select_next_previous(
|
|||||||
},
|
},
|
||||||
"action": {
|
"action": {
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "abcdefgh",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": action_type,
|
"type": action_type,
|
||||||
"cycle": False,
|
"cycle": False,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user