mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Use real devices in cover device condition tests (#102706)
This commit is contained in:
parent
bead989e7f
commit
14485af22d
@ -355,10 +355,21 @@ async def test_get_condition_capabilities_set_tilt_pos(
|
||||
|
||||
|
||||
async def test_if_state(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, calls
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
calls,
|
||||
) -> None:
|
||||
"""Test for turn_on and turn_off conditions."""
|
||||
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
|
||||
)
|
||||
|
||||
hass.states.async_set(entry.entity_id, STATE_OPEN)
|
||||
|
||||
@ -373,7 +384,7 @@ async def test_if_state(
|
||||
{
|
||||
"condition": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "is_open",
|
||||
}
|
||||
@ -395,7 +406,7 @@ async def test_if_state(
|
||||
{
|
||||
"condition": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "is_closed",
|
||||
}
|
||||
@ -417,7 +428,7 @@ async def test_if_state(
|
||||
{
|
||||
"condition": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "is_opening",
|
||||
}
|
||||
@ -439,7 +450,7 @@ async def test_if_state(
|
||||
{
|
||||
"condition": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "is_closing",
|
||||
}
|
||||
@ -487,10 +498,21 @@ async def test_if_state(
|
||||
|
||||
|
||||
async def test_if_state_legacy(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, calls
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
calls,
|
||||
) -> None:
|
||||
"""Test for turn_on and turn_off conditions."""
|
||||
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
|
||||
)
|
||||
|
||||
hass.states.async_set(entry.entity_id, STATE_OPEN)
|
||||
|
||||
@ -505,7 +527,7 @@ async def test_if_state_legacy(
|
||||
{
|
||||
"condition": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.entity_id,
|
||||
"type": "is_open",
|
||||
}
|
||||
@ -533,6 +555,7 @@ async def test_if_state_legacy(
|
||||
|
||||
async def test_if_position(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
calls,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
@ -545,7 +568,14 @@ async def test_if_position(
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
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(ent.entity_id)
|
||||
entity_registry.async_update_entity(entry.entity_id, device_id=device_entry.id)
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
@ -559,7 +589,7 @@ async def test_if_position(
|
||||
"conditions": {
|
||||
"condition": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "is_position",
|
||||
"above": 45,
|
||||
@ -593,7 +623,7 @@ async def test_if_position(
|
||||
{
|
||||
"condition": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "is_position",
|
||||
"below": 90,
|
||||
@ -616,7 +646,7 @@ async def test_if_position(
|
||||
{
|
||||
"condition": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "is_position",
|
||||
"above": 45,
|
||||
@ -686,6 +716,7 @@ async def test_if_position(
|
||||
|
||||
async def test_if_tilt_position(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
calls,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
@ -698,7 +729,14 @@ async def test_if_tilt_position(
|
||||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
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(ent.entity_id)
|
||||
entity_registry.async_update_entity(entry.entity_id, device_id=device_entry.id)
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
@ -712,7 +750,7 @@ async def test_if_tilt_position(
|
||||
"conditions": {
|
||||
"condition": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "is_tilt_position",
|
||||
"above": 45,
|
||||
@ -746,7 +784,7 @@ async def test_if_tilt_position(
|
||||
{
|
||||
"condition": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "is_tilt_position",
|
||||
"below": 90,
|
||||
@ -769,7 +807,7 @@ async def test_if_tilt_position(
|
||||
{
|
||||
"condition": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "is_tilt_position",
|
||||
"above": 45,
|
||||
|
Loading…
x
Reference in New Issue
Block a user