Fetch ServiceNotFound message from translation cache (#113893)

pull/113923/head
Jan Bouwhuis 2024-03-21 06:54:29 +01:00 committed by GitHub
parent 8edbf88da1
commit dc38d152df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -261,7 +261,6 @@ class ServiceNotFound(HomeAssistantError):
"""Initialize error."""
super().__init__(
self,
f"Service {domain}.{service} not found.",
translation_domain="homeassistant",
translation_key="service_not_found",
translation_placeholders={"domain": domain, "service": service},

View File

@ -1676,8 +1676,18 @@ async def test_serviceregistry_service_that_not_exists(hass: HomeAssistant) -> N
await hass.async_block_till_done()
assert len(calls_remove) == 0
with pytest.raises(ServiceNotFound):
with pytest.raises(ServiceNotFound) as exc:
await hass.services.async_call("test_do_not", "exist", {})
assert exc.value.translation_domain == "homeassistant"
assert exc.value.translation_key == "service_not_found"
assert exc.value.translation_placeholders == {
"domain": "test_do_not",
"service": "exist",
}
assert exc.value.domain == "test_do_not"
assert exc.value.service == "exist"
assert str(exc.value) == "Service test_do_not.exist not found."
async def test_serviceregistry_async_service_raise_exception(