mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Fix bug in check_translations fixture (#139206)
* Fix bug in check_translations fixture * Fix check for ignored translation errors * Fix websocket_api test
This commit is contained in:
parent
72f690d681
commit
b662d32e44
@ -624,7 +624,8 @@ async def _validate_translation(
|
|||||||
if not translation_required:
|
if not translation_required:
|
||||||
return
|
return
|
||||||
|
|
||||||
if full_key in translation_errors:
|
if translation_errors.get(full_key) in {"used", "unused"}:
|
||||||
|
# This translation key is in the ignore list, mark it as used
|
||||||
translation_errors[full_key] = "used"
|
translation_errors[full_key] = "used"
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -864,6 +865,7 @@ async def check_translations(
|
|||||||
if not isinstance(ignore_translations, list):
|
if not isinstance(ignore_translations, list):
|
||||||
ignore_translations = [ignore_translations]
|
ignore_translations = [ignore_translations]
|
||||||
|
|
||||||
|
# Set all ignored translation keys to "unused"
|
||||||
translation_errors = {k: "unused" for k in ignore_translations}
|
translation_errors = {k: "unused" for k in ignore_translations}
|
||||||
|
|
||||||
translation_coros = set()
|
translation_coros = set()
|
||||||
@ -945,10 +947,11 @@ async def check_translations(
|
|||||||
# Run final checks
|
# Run final checks
|
||||||
unused_ignore = [k for k, v in translation_errors.items() if v == "unused"]
|
unused_ignore = [k for k, v in translation_errors.items() if v == "unused"]
|
||||||
if unused_ignore:
|
if unused_ignore:
|
||||||
|
# Some ignored translations were not used
|
||||||
pytest.fail(
|
pytest.fail(
|
||||||
f"Unused ignore translations: {', '.join(unused_ignore)}. "
|
f"Unused ignore translations: {', '.join(unused_ignore)}. "
|
||||||
"Please remove them from the ignore_translations fixture."
|
"Please remove them from the ignore_translations fixture."
|
||||||
)
|
)
|
||||||
for description in translation_errors.values():
|
for description in translation_errors.values():
|
||||||
if description not in {"used", "unused"}:
|
if description != "used":
|
||||||
pytest.fail(description)
|
pytest.fail(description)
|
||||||
|
@ -540,6 +540,10 @@ async def test_call_service_schema_validation_error(
|
|||||||
assert len(calls) == 0
|
assert len(calls) == 0
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"ignore_translations",
|
||||||
|
["component.test.exceptions.custom_error.message"],
|
||||||
|
)
|
||||||
async def test_call_service_error(
|
async def test_call_service_error(
|
||||||
hass: HomeAssistant, websocket_client: MockHAClientWebSocket
|
hass: HomeAssistant, websocket_client: MockHAClientWebSocket
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user