mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 07:51:46 -05:00
Ignore core authorization errors in translation checks (#180817)
Co-authored-by: Markus Tuominen <3738613+Markus98@users.noreply.github.com>
This commit is contained in:
co-authored by
Markus Tuominen
parent
20485cbf88
commit
caa25bf1b2
@@ -82,7 +82,7 @@ from homeassistant.data_entry_flow import (
|
||||
FlowResultType,
|
||||
section,
|
||||
)
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.exceptions import HomeAssistantError, Unauthorized
|
||||
from homeassistant.helpers import issue_registry as ir
|
||||
from homeassistant.helpers.translation import async_get_translations
|
||||
from homeassistant.helpers.typing import VolSchemaType
|
||||
@@ -1249,6 +1249,8 @@ async def _check_exception_translation(
|
||||
request: pytest.FixtureRequest,
|
||||
ignore_translations_for_mock_domains: set[str],
|
||||
) -> None:
|
||||
if isinstance(exception, Unauthorized):
|
||||
return
|
||||
if exception.translation_key is None:
|
||||
if (
|
||||
_get_request_quality_scale(request, "exception-translations")
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
"""Tests for component test fixtures."""
|
||||
|
||||
from collections.abc import Callable
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import Unauthorized, UnknownUser
|
||||
|
||||
from . import conftest as components_conftest
|
||||
|
||||
from tests.common import QualityScaleStatus
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"exception_type",
|
||||
[
|
||||
pytest.param(Unauthorized, id="unauthorized"),
|
||||
pytest.param(UnknownUser, id="unknown-user"),
|
||||
],
|
||||
)
|
||||
async def test_authorization_errors_do_not_require_integration_translations(
|
||||
hass: HomeAssistant,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
request: pytest.FixtureRequest,
|
||||
exception_type: Callable[[], Unauthorized],
|
||||
) -> None:
|
||||
"""Test core authorization errors do not require integration translations."""
|
||||
monkeypatch.setattr(
|
||||
components_conftest,
|
||||
"_get_request_quality_scale",
|
||||
lambda *_: QualityScaleStatus.DONE,
|
||||
)
|
||||
translation_errors: dict[str, str] = {}
|
||||
|
||||
await components_conftest._check_exception_translation(
|
||||
hass,
|
||||
exception_type(),
|
||||
translation_errors,
|
||||
request,
|
||||
set(),
|
||||
)
|
||||
|
||||
assert not translation_errors
|
||||
Reference in New Issue
Block a user