|
|
@ -642,11 +642,11 @@ async def test_extract_entity_ids(hass: HomeAssistant) -> None:
|
|
|
|
order=None,
|
|
|
|
order=None,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall("light", "turn_on", {ATTR_ENTITY_ID: "light.Bowl"})
|
|
|
|
call = ServiceCall(hass, "light", "turn_on", {ATTR_ENTITY_ID: "light.Bowl"})
|
|
|
|
|
|
|
|
|
|
|
|
assert {"light.bowl"} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
assert {"light.bowl"} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall("light", "turn_on", {ATTR_ENTITY_ID: "group.test"})
|
|
|
|
call = ServiceCall(hass, "light", "turn_on", {ATTR_ENTITY_ID: "group.test"})
|
|
|
|
|
|
|
|
|
|
|
|
assert {"light.ceiling", "light.kitchen"} == await service.async_extract_entity_ids(
|
|
|
|
assert {"light.ceiling", "light.kitchen"} == await service.async_extract_entity_ids(
|
|
|
|
hass, call
|
|
|
|
hass, call
|
|
|
@ -659,7 +659,7 @@ async def test_extract_entity_ids(hass: HomeAssistant) -> None:
|
|
|
|
assert (
|
|
|
|
assert (
|
|
|
|
await service.async_extract_entity_ids(
|
|
|
|
await service.async_extract_entity_ids(
|
|
|
|
hass,
|
|
|
|
hass,
|
|
|
|
ServiceCall("light", "turn_on", {ATTR_ENTITY_ID: ENTITY_MATCH_NONE}),
|
|
|
|
ServiceCall(hass, "light", "turn_on", {ATTR_ENTITY_ID: ENTITY_MATCH_NONE}),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
== set()
|
|
|
|
== set()
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -669,20 +669,22 @@ async def test_extract_entity_ids_from_area(
|
|
|
|
hass: HomeAssistant, floor_area_mock
|
|
|
|
hass: HomeAssistant, floor_area_mock
|
|
|
|
) -> None:
|
|
|
|
) -> None:
|
|
|
|
"""Test extract_entity_ids method with areas."""
|
|
|
|
"""Test extract_entity_ids method with areas."""
|
|
|
|
call = ServiceCall("light", "turn_on", {"area_id": "own-area"})
|
|
|
|
call = ServiceCall(hass, "light", "turn_on", {"area_id": "own-area"})
|
|
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
assert {
|
|
|
|
"light.in_own_area",
|
|
|
|
"light.in_own_area",
|
|
|
|
} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall("light", "turn_on", {"area_id": "test-area"})
|
|
|
|
call = ServiceCall(hass, "light", "turn_on", {"area_id": "test-area"})
|
|
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
assert {
|
|
|
|
"light.in_area",
|
|
|
|
"light.in_area",
|
|
|
|
"light.assigned_to_area",
|
|
|
|
"light.assigned_to_area",
|
|
|
|
} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall("light", "turn_on", {"area_id": ["test-area", "diff-area"]})
|
|
|
|
call = ServiceCall(
|
|
|
|
|
|
|
|
hass, "light", "turn_on", {"area_id": ["test-area", "diff-area"]}
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
assert {
|
|
|
|
"light.in_area",
|
|
|
|
"light.in_area",
|
|
|
@ -692,7 +694,7 @@ async def test_extract_entity_ids_from_area(
|
|
|
|
|
|
|
|
|
|
|
|
assert (
|
|
|
|
assert (
|
|
|
|
await service.async_extract_entity_ids(
|
|
|
|
await service.async_extract_entity_ids(
|
|
|
|
hass, ServiceCall("light", "turn_on", {"area_id": ENTITY_MATCH_NONE})
|
|
|
|
hass, ServiceCall(hass, "light", "turn_on", {"area_id": ENTITY_MATCH_NONE})
|
|
|
|
)
|
|
|
|
)
|
|
|
|
== set()
|
|
|
|
== set()
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -703,13 +705,13 @@ async def test_extract_entity_ids_from_devices(
|
|
|
|
) -> None:
|
|
|
|
) -> None:
|
|
|
|
"""Test extract_entity_ids method with devices."""
|
|
|
|
"""Test extract_entity_ids method with devices."""
|
|
|
|
assert await service.async_extract_entity_ids(
|
|
|
|
assert await service.async_extract_entity_ids(
|
|
|
|
hass, ServiceCall("light", "turn_on", {"device_id": "device-no-area-id"})
|
|
|
|
hass, ServiceCall(hass, "light", "turn_on", {"device_id": "device-no-area-id"})
|
|
|
|
) == {
|
|
|
|
) == {
|
|
|
|
"light.no_area",
|
|
|
|
"light.no_area",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
assert await service.async_extract_entity_ids(
|
|
|
|
assert await service.async_extract_entity_ids(
|
|
|
|
hass, ServiceCall("light", "turn_on", {"device_id": "device-area-a-id"})
|
|
|
|
hass, ServiceCall(hass, "light", "turn_on", {"device_id": "device-area-a-id"})
|
|
|
|
) == {
|
|
|
|
) == {
|
|
|
|
"light.in_area_a",
|
|
|
|
"light.in_area_a",
|
|
|
|
"light.in_area_b",
|
|
|
|
"light.in_area_b",
|
|
|
@ -717,7 +719,8 @@ async def test_extract_entity_ids_from_devices(
|
|
|
|
|
|
|
|
|
|
|
|
assert (
|
|
|
|
assert (
|
|
|
|
await service.async_extract_entity_ids(
|
|
|
|
await service.async_extract_entity_ids(
|
|
|
|
hass, ServiceCall("light", "turn_on", {"device_id": "non-existing-id"})
|
|
|
|
hass,
|
|
|
|
|
|
|
|
ServiceCall(hass, "light", "turn_on", {"device_id": "non-existing-id"}),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
== set()
|
|
|
|
== set()
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -726,14 +729,16 @@ async def test_extract_entity_ids_from_devices(
|
|
|
|
@pytest.mark.usefixtures("floor_area_mock")
|
|
|
|
@pytest.mark.usefixtures("floor_area_mock")
|
|
|
|
async def test_extract_entity_ids_from_floor(hass: HomeAssistant) -> None:
|
|
|
|
async def test_extract_entity_ids_from_floor(hass: HomeAssistant) -> None:
|
|
|
|
"""Test extract_entity_ids method with floors."""
|
|
|
|
"""Test extract_entity_ids method with floors."""
|
|
|
|
call = ServiceCall("light", "turn_on", {"floor_id": "test-floor"})
|
|
|
|
call = ServiceCall(hass, "light", "turn_on", {"floor_id": "test-floor"})
|
|
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
assert {
|
|
|
|
"light.in_area",
|
|
|
|
"light.in_area",
|
|
|
|
"light.assigned_to_area",
|
|
|
|
"light.assigned_to_area",
|
|
|
|
} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall("light", "turn_on", {"floor_id": ["test-floor", "floor-a"]})
|
|
|
|
call = ServiceCall(
|
|
|
|
|
|
|
|
hass, "light", "turn_on", {"floor_id": ["test-floor", "floor-a"]}
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
assert {
|
|
|
|
"light.in_area",
|
|
|
|
"light.in_area",
|
|
|
@ -743,7 +748,7 @@ async def test_extract_entity_ids_from_floor(hass: HomeAssistant) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
assert (
|
|
|
|
assert (
|
|
|
|
await service.async_extract_entity_ids(
|
|
|
|
await service.async_extract_entity_ids(
|
|
|
|
hass, ServiceCall("light", "turn_on", {"floor_id": ENTITY_MATCH_NONE})
|
|
|
|
hass, ServiceCall(hass, "light", "turn_on", {"floor_id": ENTITY_MATCH_NONE})
|
|
|
|
)
|
|
|
|
)
|
|
|
|
== set()
|
|
|
|
== set()
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -752,13 +757,13 @@ async def test_extract_entity_ids_from_floor(hass: HomeAssistant) -> None:
|
|
|
|
@pytest.mark.usefixtures("label_mock")
|
|
|
|
@pytest.mark.usefixtures("label_mock")
|
|
|
|
async def test_extract_entity_ids_from_labels(hass: HomeAssistant) -> None:
|
|
|
|
async def test_extract_entity_ids_from_labels(hass: HomeAssistant) -> None:
|
|
|
|
"""Test extract_entity_ids method with labels."""
|
|
|
|
"""Test extract_entity_ids method with labels."""
|
|
|
|
call = ServiceCall("light", "turn_on", {"label_id": "my-label"})
|
|
|
|
call = ServiceCall(hass, "light", "turn_on", {"label_id": "my-label"})
|
|
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
assert {
|
|
|
|
"light.with_my_label",
|
|
|
|
"light.with_my_label",
|
|
|
|
} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall("light", "turn_on", {"label_id": "label1"})
|
|
|
|
call = ServiceCall(hass, "light", "turn_on", {"label_id": "label1"})
|
|
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
assert {
|
|
|
|
"light.with_label1_from_device",
|
|
|
|
"light.with_label1_from_device",
|
|
|
@ -767,14 +772,14 @@ async def test_extract_entity_ids_from_labels(hass: HomeAssistant) -> None:
|
|
|
|
"light.with_label1_and_label2_from_device",
|
|
|
|
"light.with_label1_and_label2_from_device",
|
|
|
|
} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall("light", "turn_on", {"label_id": ["label2"]})
|
|
|
|
call = ServiceCall(hass, "light", "turn_on", {"label_id": ["label2"]})
|
|
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
assert {
|
|
|
|
"light.with_labels_from_device",
|
|
|
|
"light.with_labels_from_device",
|
|
|
|
"light.with_label1_and_label2_from_device",
|
|
|
|
"light.with_label1_and_label2_from_device",
|
|
|
|
} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
} == await service.async_extract_entity_ids(hass, call)
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall("light", "turn_on", {"label_id": ["label_area"]})
|
|
|
|
call = ServiceCall(hass, "light", "turn_on", {"label_id": ["label_area"]})
|
|
|
|
|
|
|
|
|
|
|
|
assert {
|
|
|
|
assert {
|
|
|
|
"light.with_labels_from_device",
|
|
|
|
"light.with_labels_from_device",
|
|
|
@ -782,7 +787,7 @@ async def test_extract_entity_ids_from_labels(hass: HomeAssistant) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
assert (
|
|
|
|
assert (
|
|
|
|
await service.async_extract_entity_ids(
|
|
|
|
await service.async_extract_entity_ids(
|
|
|
|
hass, ServiceCall("light", "turn_on", {"label_id": ENTITY_MATCH_NONE})
|
|
|
|
hass, ServiceCall(hass, "light", "turn_on", {"label_id": ENTITY_MATCH_NONE})
|
|
|
|
)
|
|
|
|
)
|
|
|
|
== set()
|
|
|
|
== set()
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -1281,7 +1286,7 @@ async def test_call_with_required_features(hass: HomeAssistant, mock_entities) -
|
|
|
|
hass,
|
|
|
|
hass,
|
|
|
|
mock_entities,
|
|
|
|
mock_entities,
|
|
|
|
HassJob(test_service_mock),
|
|
|
|
HassJob(test_service_mock),
|
|
|
|
ServiceCall("test_domain", "test_service", {"entity_id": "all"}),
|
|
|
|
ServiceCall(hass, "test_domain", "test_service", {"entity_id": "all"}),
|
|
|
|
required_features=[SUPPORT_A],
|
|
|
|
required_features=[SUPPORT_A],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -1305,7 +1310,7 @@ async def test_call_with_required_features(hass: HomeAssistant, mock_entities) -
|
|
|
|
mock_entities,
|
|
|
|
mock_entities,
|
|
|
|
HassJob(test_service_mock),
|
|
|
|
HassJob(test_service_mock),
|
|
|
|
ServiceCall(
|
|
|
|
ServiceCall(
|
|
|
|
"test_domain", "test_service", {"entity_id": "light.living_room"}
|
|
|
|
hass, "test_domain", "test_service", {"entity_id": "light.living_room"}
|
|
|
|
),
|
|
|
|
),
|
|
|
|
required_features=[SUPPORT_A],
|
|
|
|
required_features=[SUPPORT_A],
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -1321,7 +1326,7 @@ async def test_call_with_both_required_features(
|
|
|
|
hass,
|
|
|
|
hass,
|
|
|
|
mock_entities,
|
|
|
|
mock_entities,
|
|
|
|
HassJob(test_service_mock),
|
|
|
|
HassJob(test_service_mock),
|
|
|
|
ServiceCall("test_domain", "test_service", {"entity_id": "all"}),
|
|
|
|
ServiceCall(hass, "test_domain", "test_service", {"entity_id": "all"}),
|
|
|
|
required_features=[SUPPORT_A | SUPPORT_B],
|
|
|
|
required_features=[SUPPORT_A | SUPPORT_B],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -1340,7 +1345,7 @@ async def test_call_with_one_of_required_features(
|
|
|
|
hass,
|
|
|
|
hass,
|
|
|
|
mock_entities,
|
|
|
|
mock_entities,
|
|
|
|
HassJob(test_service_mock),
|
|
|
|
HassJob(test_service_mock),
|
|
|
|
ServiceCall("test_domain", "test_service", {"entity_id": "all"}),
|
|
|
|
ServiceCall(hass, "test_domain", "test_service", {"entity_id": "all"}),
|
|
|
|
required_features=[SUPPORT_A, SUPPORT_C],
|
|
|
|
required_features=[SUPPORT_A, SUPPORT_C],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -1361,7 +1366,9 @@ async def test_call_with_sync_func(hass: HomeAssistant, mock_entities) -> None:
|
|
|
|
hass,
|
|
|
|
hass,
|
|
|
|
mock_entities,
|
|
|
|
mock_entities,
|
|
|
|
HassJob(test_service_mock),
|
|
|
|
HassJob(test_service_mock),
|
|
|
|
ServiceCall("test_domain", "test_service", {"entity_id": "light.kitchen"}),
|
|
|
|
ServiceCall(
|
|
|
|
|
|
|
|
hass, "test_domain", "test_service", {"entity_id": "light.kitchen"}
|
|
|
|
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
assert test_service_mock.call_count == 1
|
|
|
|
assert test_service_mock.call_count == 1
|
|
|
|
|
|
|
|
|
|
|
@ -1374,6 +1381,7 @@ async def test_call_with_sync_attr(hass: HomeAssistant, mock_entities) -> None:
|
|
|
|
mock_entities,
|
|
|
|
mock_entities,
|
|
|
|
"sync_method",
|
|
|
|
"sync_method",
|
|
|
|
ServiceCall(
|
|
|
|
ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"test_domain",
|
|
|
|
"test_domain",
|
|
|
|
"test_service",
|
|
|
|
"test_service",
|
|
|
|
{"entity_id": "light.kitchen", "area_id": "abcd"},
|
|
|
|
{"entity_id": "light.kitchen", "area_id": "abcd"},
|
|
|
@ -1392,6 +1400,7 @@ async def test_call_context_user_not_exist(hass: HomeAssistant) -> None:
|
|
|
|
{},
|
|
|
|
{},
|
|
|
|
Mock(),
|
|
|
|
Mock(),
|
|
|
|
ServiceCall(
|
|
|
|
ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"test_domain",
|
|
|
|
"test_domain",
|
|
|
|
"test_service",
|
|
|
|
"test_service",
|
|
|
|
context=Context(user_id="non-existing"),
|
|
|
|
context=Context(user_id="non-existing"),
|
|
|
@ -1419,6 +1428,7 @@ async def test_call_context_target_all(
|
|
|
|
mock_entities,
|
|
|
|
mock_entities,
|
|
|
|
Mock(),
|
|
|
|
Mock(),
|
|
|
|
ServiceCall(
|
|
|
|
ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"test_domain",
|
|
|
|
"test_domain",
|
|
|
|
"test_service",
|
|
|
|
"test_service",
|
|
|
|
data={"entity_id": ENTITY_MATCH_ALL},
|
|
|
|
data={"entity_id": ENTITY_MATCH_ALL},
|
|
|
@ -1447,6 +1457,7 @@ async def test_call_context_target_specific(
|
|
|
|
mock_entities,
|
|
|
|
mock_entities,
|
|
|
|
Mock(),
|
|
|
|
Mock(),
|
|
|
|
ServiceCall(
|
|
|
|
ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"test_domain",
|
|
|
|
"test_domain",
|
|
|
|
"test_service",
|
|
|
|
"test_service",
|
|
|
|
{"entity_id": "light.kitchen"},
|
|
|
|
{"entity_id": "light.kitchen"},
|
|
|
@ -1474,6 +1485,7 @@ async def test_call_context_target_specific_no_auth(
|
|
|
|
mock_entities,
|
|
|
|
mock_entities,
|
|
|
|
Mock(),
|
|
|
|
Mock(),
|
|
|
|
ServiceCall(
|
|
|
|
ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"test_domain",
|
|
|
|
"test_domain",
|
|
|
|
"test_service",
|
|
|
|
"test_service",
|
|
|
|
{"entity_id": "light.kitchen"},
|
|
|
|
{"entity_id": "light.kitchen"},
|
|
|
@ -1494,7 +1506,7 @@ async def test_call_no_context_target_all(
|
|
|
|
mock_entities,
|
|
|
|
mock_entities,
|
|
|
|
Mock(),
|
|
|
|
Mock(),
|
|
|
|
ServiceCall(
|
|
|
|
ServiceCall(
|
|
|
|
"test_domain", "test_service", data={"entity_id": ENTITY_MATCH_ALL}
|
|
|
|
hass, "test_domain", "test_service", data={"entity_id": ENTITY_MATCH_ALL}
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -1513,6 +1525,7 @@ async def test_call_no_context_target_specific(
|
|
|
|
mock_entities,
|
|
|
|
mock_entities,
|
|
|
|
Mock(),
|
|
|
|
Mock(),
|
|
|
|
ServiceCall(
|
|
|
|
ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"test_domain",
|
|
|
|
"test_domain",
|
|
|
|
"test_service",
|
|
|
|
"test_service",
|
|
|
|
{"entity_id": ["light.kitchen", "light.non-existing"]},
|
|
|
|
{"entity_id": ["light.kitchen", "light.non-existing"]},
|
|
|
@ -1534,7 +1547,7 @@ async def test_call_with_match_all(
|
|
|
|
hass,
|
|
|
|
hass,
|
|
|
|
mock_entities,
|
|
|
|
mock_entities,
|
|
|
|
Mock(),
|
|
|
|
Mock(),
|
|
|
|
ServiceCall("test_domain", "test_service", {"entity_id": "all"}),
|
|
|
|
ServiceCall(hass, "test_domain", "test_service", {"entity_id": "all"}),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert len(mock_handle_entity_call.mock_calls) == 4
|
|
|
|
assert len(mock_handle_entity_call.mock_calls) == 4
|
|
|
@ -1551,7 +1564,7 @@ async def test_call_with_omit_entity_id(
|
|
|
|
hass,
|
|
|
|
hass,
|
|
|
|
mock_entities,
|
|
|
|
mock_entities,
|
|
|
|
Mock(),
|
|
|
|
Mock(),
|
|
|
|
ServiceCall("test_domain", "test_service"),
|
|
|
|
ServiceCall(hass, "test_domain", "test_service"),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
assert len(mock_handle_entity_call.mock_calls) == 0
|
|
|
|
assert len(mock_handle_entity_call.mock_calls) == 0
|
|
|
@ -1797,7 +1810,7 @@ async def test_extract_from_service_available_device(hass: HomeAssistant) -> Non
|
|
|
|
MockEntity(name="test_4", entity_id="test_domain.test_4", available=False),
|
|
|
|
MockEntity(name="test_4", entity_id="test_domain.test_4", available=False),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
call_1 = ServiceCall("test", "service", data={"entity_id": ENTITY_MATCH_ALL})
|
|
|
|
call_1 = ServiceCall(hass, "test", "service", data={"entity_id": ENTITY_MATCH_ALL})
|
|
|
|
|
|
|
|
|
|
|
|
assert [
|
|
|
|
assert [
|
|
|
|
ent.entity_id
|
|
|
|
ent.entity_id
|
|
|
@ -1805,6 +1818,7 @@ async def test_extract_from_service_available_device(hass: HomeAssistant) -> Non
|
|
|
|
] == ["test_domain.test_1", "test_domain.test_3"]
|
|
|
|
] == ["test_domain.test_1", "test_domain.test_3"]
|
|
|
|
|
|
|
|
|
|
|
|
call_2 = ServiceCall(
|
|
|
|
call_2 = ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"test",
|
|
|
|
"test",
|
|
|
|
"service",
|
|
|
|
"service",
|
|
|
|
data={"entity_id": ["test_domain.test_3", "test_domain.test_4"]},
|
|
|
|
data={"entity_id": ["test_domain.test_3", "test_domain.test_4"]},
|
|
|
@ -1820,6 +1834,7 @@ async def test_extract_from_service_available_device(hass: HomeAssistant) -> Non
|
|
|
|
hass,
|
|
|
|
hass,
|
|
|
|
entities,
|
|
|
|
entities,
|
|
|
|
ServiceCall(
|
|
|
|
ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"test",
|
|
|
|
"test",
|
|
|
|
"service",
|
|
|
|
"service",
|
|
|
|
data={"entity_id": ENTITY_MATCH_NONE},
|
|
|
|
data={"entity_id": ENTITY_MATCH_NONE},
|
|
|
@ -1835,7 +1850,7 @@ async def test_extract_from_service_empty_if_no_entity_id(hass: HomeAssistant) -
|
|
|
|
MockEntity(name="test_1", entity_id="test_domain.test_1"),
|
|
|
|
MockEntity(name="test_1", entity_id="test_domain.test_1"),
|
|
|
|
MockEntity(name="test_2", entity_id="test_domain.test_2"),
|
|
|
|
MockEntity(name="test_2", entity_id="test_domain.test_2"),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
call = ServiceCall("test", "service")
|
|
|
|
call = ServiceCall(hass, "test", "service")
|
|
|
|
|
|
|
|
|
|
|
|
assert [
|
|
|
|
assert [
|
|
|
|
ent.entity_id
|
|
|
|
ent.entity_id
|
|
|
@ -1853,6 +1868,7 @@ async def test_extract_from_service_filter_out_non_existing_entities(
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall(
|
|
|
|
call = ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"test",
|
|
|
|
"test",
|
|
|
|
"service",
|
|
|
|
"service",
|
|
|
|
{"entity_id": ["test_domain.test_2", "test_domain.non_exist"]},
|
|
|
|
{"entity_id": ["test_domain.test_2", "test_domain.non_exist"]},
|
|
|
@ -1874,12 +1890,14 @@ async def test_extract_from_service_area_id(
|
|
|
|
MockEntity(name="diff_area", entity_id="light.diff_area"),
|
|
|
|
MockEntity(name="diff_area", entity_id="light.diff_area"),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall("light", "turn_on", {"area_id": "test-area"})
|
|
|
|
call = ServiceCall(hass, "light", "turn_on", {"area_id": "test-area"})
|
|
|
|
extracted = await service.async_extract_entities(hass, entities, call)
|
|
|
|
extracted = await service.async_extract_entities(hass, entities, call)
|
|
|
|
assert len(extracted) == 1
|
|
|
|
assert len(extracted) == 1
|
|
|
|
assert extracted[0].entity_id == "light.in_area"
|
|
|
|
assert extracted[0].entity_id == "light.in_area"
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall("light", "turn_on", {"area_id": ["test-area", "diff-area"]})
|
|
|
|
call = ServiceCall(
|
|
|
|
|
|
|
|
hass, "light", "turn_on", {"area_id": ["test-area", "diff-area"]}
|
|
|
|
|
|
|
|
)
|
|
|
|
extracted = await service.async_extract_entities(hass, entities, call)
|
|
|
|
extracted = await service.async_extract_entities(hass, entities, call)
|
|
|
|
assert len(extracted) == 2
|
|
|
|
assert len(extracted) == 2
|
|
|
|
assert sorted(ent.entity_id for ent in extracted) == [
|
|
|
|
assert sorted(ent.entity_id for ent in extracted) == [
|
|
|
@ -1888,6 +1906,7 @@ async def test_extract_from_service_area_id(
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall(
|
|
|
|
call = ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"light",
|
|
|
|
"light",
|
|
|
|
"turn_on",
|
|
|
|
"turn_on",
|
|
|
|
{"area_id": ["test-area", "diff-area"], "device_id": "device-no-area-id"},
|
|
|
|
{"area_id": ["test-area", "diff-area"], "device_id": "device-no-area-id"},
|
|
|
@ -1912,17 +1931,17 @@ async def test_extract_from_service_label_id(hass: HomeAssistant) -> None:
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall("light", "turn_on", {"label_id": "label_area"})
|
|
|
|
call = ServiceCall(hass, "light", "turn_on", {"label_id": "label_area"})
|
|
|
|
extracted = await service.async_extract_entities(hass, entities, call)
|
|
|
|
extracted = await service.async_extract_entities(hass, entities, call)
|
|
|
|
assert len(extracted) == 1
|
|
|
|
assert len(extracted) == 1
|
|
|
|
assert extracted[0].entity_id == "light.with_labels_from_device"
|
|
|
|
assert extracted[0].entity_id == "light.with_labels_from_device"
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall("light", "turn_on", {"label_id": "my-label"})
|
|
|
|
call = ServiceCall(hass, "light", "turn_on", {"label_id": "my-label"})
|
|
|
|
extracted = await service.async_extract_entities(hass, entities, call)
|
|
|
|
extracted = await service.async_extract_entities(hass, entities, call)
|
|
|
|
assert len(extracted) == 1
|
|
|
|
assert len(extracted) == 1
|
|
|
|
assert extracted[0].entity_id == "light.with_my_label"
|
|
|
|
assert extracted[0].entity_id == "light.with_my_label"
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall("light", "turn_on", {"label_id": ["my-label", "label1"]})
|
|
|
|
call = ServiceCall(hass, "light", "turn_on", {"label_id": ["my-label", "label1"]})
|
|
|
|
extracted = await service.async_extract_entities(hass, entities, call)
|
|
|
|
extracted = await service.async_extract_entities(hass, entities, call)
|
|
|
|
assert len(extracted) == 2
|
|
|
|
assert len(extracted) == 2
|
|
|
|
assert sorted(ent.entity_id for ent in extracted) == [
|
|
|
|
assert sorted(ent.entity_id for ent in extracted) == [
|
|
|
@ -1931,6 +1950,7 @@ async def test_extract_from_service_label_id(hass: HomeAssistant) -> None:
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall(
|
|
|
|
call = ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"light",
|
|
|
|
"light",
|
|
|
|
"turn_on",
|
|
|
|
"turn_on",
|
|
|
|
{"label_id": ["my-label", "label1"], "device_id": "device-no-labels"},
|
|
|
|
{"label_id": ["my-label", "label1"], "device_id": "device-no-labels"},
|
|
|
@ -1949,6 +1969,7 @@ async def test_entity_service_call_warn_referenced(
|
|
|
|
) -> None:
|
|
|
|
) -> None:
|
|
|
|
"""Test we only warn for referenced entities in entity_service_call."""
|
|
|
|
"""Test we only warn for referenced entities in entity_service_call."""
|
|
|
|
call = ServiceCall(
|
|
|
|
call = ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"light",
|
|
|
|
"light",
|
|
|
|
"turn_on",
|
|
|
|
"turn_on",
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1972,6 +1993,7 @@ async def test_async_extract_entities_warn_referenced(
|
|
|
|
) -> None:
|
|
|
|
) -> None:
|
|
|
|
"""Test we only warn for referenced entities in async_extract_entities."""
|
|
|
|
"""Test we only warn for referenced entities in async_extract_entities."""
|
|
|
|
call = ServiceCall(
|
|
|
|
call = ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"light",
|
|
|
|
"light",
|
|
|
|
"turn_on",
|
|
|
|
"turn_on",
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1997,6 +2019,7 @@ async def test_async_extract_config_entry_ids(hass: HomeAssistant) -> None:
|
|
|
|
device_no_entities = dr.DeviceEntry(id="device-no-entities", config_entries={"abc"})
|
|
|
|
device_no_entities = dr.DeviceEntry(id="device-no-entities", config_entries={"abc"})
|
|
|
|
|
|
|
|
|
|
|
|
call = ServiceCall(
|
|
|
|
call = ServiceCall(
|
|
|
|
|
|
|
|
hass,
|
|
|
|
"homeassistant",
|
|
|
|
"homeassistant",
|
|
|
|
"reload_config_entry",
|
|
|
|
"reload_config_entry",
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -2042,17 +2065,33 @@ async def test_reload_service_helper(hass: HomeAssistant) -> None:
|
|
|
|
reloader = service.ReloadServiceHelper(reload_service_handler, reload_targets)
|
|
|
|
reloader = service.ReloadServiceHelper(reload_service_handler, reload_targets)
|
|
|
|
tasks = [
|
|
|
|
tasks = [
|
|
|
|
# This reload task will start executing first, (target1)
|
|
|
|
# This reload task will start executing first, (target1)
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target1"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target1"})
|
|
|
|
|
|
|
|
),
|
|
|
|
# These reload tasks will be deduplicated to (target2, target3, target4, target1)
|
|
|
|
# These reload tasks will be deduplicated to (target2, target3, target4, target1)
|
|
|
|
# while the first task is reloaded, note that target1 can't be deduplicated
|
|
|
|
# while the first task is reloaded, note that target1 can't be deduplicated
|
|
|
|
# because it's already being reloaded.
|
|
|
|
# because it's already being reloaded.
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target2"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target3"})),
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target2"})
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target4"})),
|
|
|
|
),
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target1"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target2"})),
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target3"})
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target3"})),
|
|
|
|
),
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target4"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target4"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target1"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target2"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target3"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target4"})
|
|
|
|
|
|
|
|
),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
await asyncio.gather(*tasks)
|
|
|
|
await asyncio.gather(*tasks)
|
|
|
|
assert reloaded == unordered(
|
|
|
|
assert reloaded == unordered(
|
|
|
@ -2063,13 +2102,21 @@ async def test_reload_service_helper(hass: HomeAssistant) -> None:
|
|
|
|
reloaded.clear()
|
|
|
|
reloaded.clear()
|
|
|
|
tasks = [
|
|
|
|
tasks = [
|
|
|
|
# This reload task will start executing first, (target1)
|
|
|
|
# This reload task will start executing first, (target1)
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target1"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target1"})
|
|
|
|
|
|
|
|
),
|
|
|
|
# These reload tasks will be deduplicated to (target2, target3, target4, all)
|
|
|
|
# These reload tasks will be deduplicated to (target2, target3, target4, all)
|
|
|
|
# while the first task is reloaded.
|
|
|
|
# while the first task is reloaded.
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target2"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target3"})),
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target2"})
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target4"})),
|
|
|
|
),
|
|
|
|
reloader.execute_service(ServiceCall("test", "test")),
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target3"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target4"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(ServiceCall(hass, "test", "test")),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
await asyncio.gather(*tasks)
|
|
|
|
await asyncio.gather(*tasks)
|
|
|
|
assert reloaded == unordered(["target1", "target2", "target3", "target4", "all"])
|
|
|
|
assert reloaded == unordered(["target1", "target2", "target3", "target4", "all"])
|
|
|
@ -2078,13 +2125,21 @@ async def test_reload_service_helper(hass: HomeAssistant) -> None:
|
|
|
|
reloaded.clear()
|
|
|
|
reloaded.clear()
|
|
|
|
tasks = [
|
|
|
|
tasks = [
|
|
|
|
# This reload task will start executing first, (all)
|
|
|
|
# This reload task will start executing first, (all)
|
|
|
|
reloader.execute_service(ServiceCall("test", "test")),
|
|
|
|
reloader.execute_service(ServiceCall(hass, "test", "test")),
|
|
|
|
# These reload tasks will be deduplicated to (target1, target2, target3, target4)
|
|
|
|
# These reload tasks will be deduplicated to (target1, target2, target3, target4)
|
|
|
|
# while the first task is reloaded.
|
|
|
|
# while the first task is reloaded.
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target1"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target2"})),
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target1"})
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target3"})),
|
|
|
|
),
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target4"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target2"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target3"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target4"})
|
|
|
|
|
|
|
|
),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
await asyncio.gather(*tasks)
|
|
|
|
await asyncio.gather(*tasks)
|
|
|
|
assert reloaded == unordered(["all", "target1", "target2", "target3", "target4"])
|
|
|
|
assert reloaded == unordered(["all", "target1", "target2", "target3", "target4"])
|
|
|
@ -2093,21 +2148,45 @@ async def test_reload_service_helper(hass: HomeAssistant) -> None:
|
|
|
|
reloaded.clear()
|
|
|
|
reloaded.clear()
|
|
|
|
tasks = [
|
|
|
|
tasks = [
|
|
|
|
# This reload task will start executing first, (target1)
|
|
|
|
# This reload task will start executing first, (target1)
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target1"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target1"})
|
|
|
|
|
|
|
|
),
|
|
|
|
# These reload tasks will be deduplicated to (target2, target3, target4, target1)
|
|
|
|
# These reload tasks will be deduplicated to (target2, target3, target4, target1)
|
|
|
|
# while the first task is reloaded, note that target1 can't be deduplicated
|
|
|
|
# while the first task is reloaded, note that target1 can't be deduplicated
|
|
|
|
# because it's already being reloaded.
|
|
|
|
# because it's already being reloaded.
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target2"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target3"})),
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target2"})
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target4"})),
|
|
|
|
),
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target1"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target2"})),
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target3"})
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target3"})),
|
|
|
|
),
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target4"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target1"})),
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target4"})
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target2"})),
|
|
|
|
),
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target3"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target4"})),
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target1"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target2"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target3"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target4"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target1"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target2"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target3"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target4"})
|
|
|
|
|
|
|
|
),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
await asyncio.gather(*tasks)
|
|
|
|
await asyncio.gather(*tasks)
|
|
|
|
assert reloaded == unordered(
|
|
|
|
assert reloaded == unordered(
|
|
|
@ -2118,14 +2197,22 @@ async def test_reload_service_helper(hass: HomeAssistant) -> None:
|
|
|
|
reloaded.clear()
|
|
|
|
reloaded.clear()
|
|
|
|
tasks = [
|
|
|
|
tasks = [
|
|
|
|
# This reload task will start executing first, (target1)
|
|
|
|
# This reload task will start executing first, (target1)
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target1"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target1"})
|
|
|
|
|
|
|
|
),
|
|
|
|
# These reload tasks will be deduplicated to (target2, target3, target4, all)
|
|
|
|
# These reload tasks will be deduplicated to (target2, target3, target4, all)
|
|
|
|
# while the first task is reloaded.
|
|
|
|
# while the first task is reloaded.
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target2"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target3"})),
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target2"})
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target4"})),
|
|
|
|
),
|
|
|
|
reloader.execute_service(ServiceCall("test", "test")),
|
|
|
|
reloader.execute_service(
|
|
|
|
reloader.execute_service(ServiceCall("test", "test")),
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target3"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target4"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(ServiceCall(hass, "test", "test")),
|
|
|
|
|
|
|
|
reloader.execute_service(ServiceCall(hass, "test", "test")),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
await asyncio.gather(*tasks)
|
|
|
|
await asyncio.gather(*tasks)
|
|
|
|
assert reloaded == unordered(["target1", "target2", "target3", "target4", "all"])
|
|
|
|
assert reloaded == unordered(["target1", "target2", "target3", "target4", "all"])
|
|
|
@ -2134,17 +2221,33 @@ async def test_reload_service_helper(hass: HomeAssistant) -> None:
|
|
|
|
reloaded.clear()
|
|
|
|
reloaded.clear()
|
|
|
|
tasks = [
|
|
|
|
tasks = [
|
|
|
|
# This reload task will start executing first, (all)
|
|
|
|
# This reload task will start executing first, (all)
|
|
|
|
reloader.execute_service(ServiceCall("test", "test")),
|
|
|
|
reloader.execute_service(ServiceCall(hass, "test", "test")),
|
|
|
|
# These reload tasks will be deduplicated to (target1, target2, target3, target4)
|
|
|
|
# These reload tasks will be deduplicated to (target1, target2, target3, target4)
|
|
|
|
# while the first task is reloaded.
|
|
|
|
# while the first task is reloaded.
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target1"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target2"})),
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target1"})
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target3"})),
|
|
|
|
),
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target4"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target1"})),
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target2"})
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target2"})),
|
|
|
|
),
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target3"})),
|
|
|
|
reloader.execute_service(
|
|
|
|
reloader.execute_service(ServiceCall("test", "test", {"target": "target4"})),
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target3"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target4"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target1"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target2"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target3"})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
reloader.execute_service(
|
|
|
|
|
|
|
|
ServiceCall(hass, "test", "test", {"target": "target4"})
|
|
|
|
|
|
|
|
),
|
|
|
|
]
|
|
|
|
]
|
|
|
|
await asyncio.gather(*tasks)
|
|
|
|
await asyncio.gather(*tasks)
|
|
|
|
assert reloaded == unordered(["all", "target1", "target2", "target3", "target4"])
|
|
|
|
assert reloaded == unordered(["all", "target1", "target2", "target3", "target4"])
|
|
|
|