mirror of
https://github.com/home-assistant/core.git
synced 2025-11-06 09:29:27 +00:00
Raise if referenced entity does not support service (#68394)
This commit is contained in:
@@ -552,6 +552,20 @@ async def test_call_with_required_features(hass, mock_entities):
|
||||
actual = [call[0][0] for call in test_service_mock.call_args_list]
|
||||
assert all(entity in actual for entity in expected)
|
||||
|
||||
# Test we raise if we target entity ID that does not support the service
|
||||
test_service_mock.reset_mock()
|
||||
with pytest.raises(exceptions.HomeAssistantError):
|
||||
await service.entity_service_call(
|
||||
hass,
|
||||
[Mock(entities=mock_entities)],
|
||||
test_service_mock,
|
||||
ha.ServiceCall(
|
||||
"test_domain", "test_service", {"entity_id": "light.living_room"}
|
||||
),
|
||||
required_features=[SUPPORT_A],
|
||||
)
|
||||
assert test_service_mock.call_count == 0
|
||||
|
||||
|
||||
async def test_call_with_both_required_features(hass, mock_entities):
|
||||
"""Test service calls invoked only if entity has both features."""
|
||||
|
||||
Reference in New Issue
Block a user