mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
remove redundant parts of exception translations
This commit is contained in:
@ -46,24 +46,19 @@ async def _async_upload_file(service_call: ServiceCall) -> None:
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="config_entry_not_found",
|
||||
translation_placeholders={"service": service_call.service},
|
||||
)
|
||||
|
||||
if target_entry.state is not ConfigEntryState.LOADED:
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="config_entry_not_loaded",
|
||||
translation_placeholders={"service": service_call.service},
|
||||
)
|
||||
|
||||
if not os.path.isfile(target_file):
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="file_not_found",
|
||||
translation_placeholders={
|
||||
"service": service_call.service,
|
||||
"file": target_file,
|
||||
},
|
||||
translation_placeholders={"file": target_file},
|
||||
)
|
||||
|
||||
coordinator = target_entry.runtime_data
|
||||
@ -75,11 +70,7 @@ async def _async_upload_file(service_call: ServiceCall) -> None:
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="album_not_found",
|
||||
translation_placeholders={
|
||||
"service": service_call.service,
|
||||
"album_id": target_album,
|
||||
"error": str(ex),
|
||||
},
|
||||
translation_placeholders={"album_id": target_album, "error": str(ex)},
|
||||
) from ex
|
||||
|
||||
try:
|
||||
@ -92,11 +83,7 @@ async def _async_upload_file(service_call: ServiceCall) -> None:
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="upload_failed",
|
||||
translation_placeholders={
|
||||
"service": service_call.service,
|
||||
"file": target_file,
|
||||
"error": str(ex),
|
||||
},
|
||||
translation_placeholders={"file": target_file, "error": str(ex)},
|
||||
) from ex
|
||||
|
||||
|
||||
|
@ -92,19 +92,19 @@
|
||||
},
|
||||
"exceptions": {
|
||||
"config_entry_not_found": {
|
||||
"message": "Failed to perform action \"{service}\". Config entry not found."
|
||||
"message": "Config entry not found."
|
||||
},
|
||||
"config_entry_not_loaded": {
|
||||
"message": "Failed to perform action \"{service}\". Config entry not loaded."
|
||||
"message": "Config entry not loaded."
|
||||
},
|
||||
"file_not_found": {
|
||||
"message": "Failed to perform action \"{service}\". File `{file}` not found."
|
||||
"message": "File `{file}` not found."
|
||||
},
|
||||
"album_not_found": {
|
||||
"message": "Failed to perform action \"{service}\". Album with ID `{album_id}` not found ({error})."
|
||||
"message": "Album with ID `{album_id}` not found ({error})."
|
||||
},
|
||||
"upload_failed": {
|
||||
"message": "Failed to perform action \"{service}\". Upload of file `{file}` failed ({error})."
|
||||
"message": "Upload of file `{file}` failed ({error})."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,10 +97,7 @@ async def test_upload_file_config_entry_not_found(
|
||||
"""Test upload_file service raising config_entry_not_found."""
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
with pytest.raises(
|
||||
ServiceValidationError,
|
||||
match='Failed to perform action "upload_file". Config entry not found',
|
||||
):
|
||||
with pytest.raises(ServiceValidationError, match="Config entry not found"):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_UPLOAD_FILE,
|
||||
@ -121,10 +118,7 @@ async def test_upload_file_config_entry_not_loaded(
|
||||
mock_config_entry.disabled_by = er.RegistryEntryDisabler.USER
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
with pytest.raises(
|
||||
ServiceValidationError,
|
||||
match='Failed to perform action "upload_file". Config entry not loaded',
|
||||
):
|
||||
with pytest.raises(ServiceValidationError, match="Config entry not loaded"):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_UPLOAD_FILE,
|
||||
@ -145,8 +139,7 @@ async def test_upload_file_file_not_found(
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
with pytest.raises(
|
||||
ServiceValidationError,
|
||||
match='Failed to perform action "upload_file". File `not_existing.file` not found',
|
||||
ServiceValidationError, match="File `not_existing.file` not found"
|
||||
):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
@ -182,7 +175,7 @@ async def test_upload_file_album_not_found(
|
||||
|
||||
with pytest.raises(
|
||||
ServiceValidationError,
|
||||
match='Failed to perform action "upload_file". Album with id `721e1a4b-aa12-441e-8d3b-5ac7ab283bb6` not found',
|
||||
match="Album with ID `721e1a4b-aa12-441e-8d3b-5ac7ab283bb6` not found",
|
||||
):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
@ -217,8 +210,7 @@ async def test_upload_file_upload_failed(
|
||||
}
|
||||
)
|
||||
with pytest.raises(
|
||||
ServiceValidationError,
|
||||
match=f'Failed to perform action "upload_file". Upload of file `{test_file.as_posix()}` failed',
|
||||
ServiceValidationError, match=f"Upload of file `{test_file.as_posix()}` failed"
|
||||
):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
@ -252,8 +244,7 @@ async def test_upload_file_to_album_upload_failed(
|
||||
}
|
||||
)
|
||||
with pytest.raises(
|
||||
ServiceValidationError,
|
||||
match=f'Failed to perform action "upload_file". Upload of file `{test_file.as_posix()}` failed',
|
||||
ServiceValidationError, match=f"Upload of file `{test_file.as_posix()}` failed"
|
||||
):
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
|
Reference in New Issue
Block a user