Always include homeassistant translations in tests (#162850)

This commit is contained in:
epenet
2026-02-13 20:17:48 +01:00
committed by GitHub
parent e80bb871e4
commit a301a9c4b6
9 changed files with 47 additions and 47 deletions

View File

@@ -58,7 +58,6 @@ from homeassistant.exceptions import (
ServiceValidationError,
)
from homeassistant.helpers.json import json_dumps
from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util
from homeassistant.util.async_ import create_eager_task
from homeassistant.util.read_only_dict import ReadOnlyDict
@@ -1348,18 +1347,6 @@ async def test_eventbus_max_length_exceeded(hass: HomeAssistant) -> None:
"this_event_exceeds_the_max_character_length_even_with_the_new_limit"
)
# Without cached translations the translation key is returned
with pytest.raises(MaxLengthExceeded) as exc_info:
hass.bus.async_fire(long_evt_name)
assert str(exc_info.value) == "max_length_exceeded"
assert exc_info.value.property_name == "event_type"
assert exc_info.value.max_length == 64
assert exc_info.value.value == long_evt_name
# Fetch translations
await async_setup_component(hass, "homeassistant", {})
# With cached translations the formatted message is returned
with pytest.raises(MaxLengthExceeded) as exc_info:
hass.bus.async_fire(long_evt_name)
@@ -1368,6 +1355,7 @@ async def test_eventbus_max_length_exceeded(hass: HomeAssistant) -> None:
str(exc_info.value)
== f"Value {long_evt_name} for property event_type has a maximum length of 64 characters"
)
assert exc_info.value.translation_key == "max_length_exceeded"
assert exc_info.value.property_name == "event_type"
assert exc_info.value.max_length == 64
assert exc_info.value.value == long_evt_name
@@ -1732,7 +1720,6 @@ async def test_serviceregistry_remove_service(hass: HomeAssistant) -> None:
async def test_serviceregistry_service_that_not_exists(hass: HomeAssistant) -> None:
"""Test remove service that not exists."""
await async_setup_component(hass, "homeassistant", {})
calls_remove = async_capture_events(hass, EVENT_SERVICE_REMOVED)
assert not hass.services.has_service("test_xxx", "test_yyy")
hass.services.async_remove("test_xxx", "test_yyy")
@@ -1830,7 +1817,6 @@ async def test_services_call_return_response_requires_blocking(
hass: HomeAssistant,
) -> None:
"""Test that non-blocking service calls cannot ask for response data."""
await async_setup_component(hass, "homeassistant", {})
async_mock_service(hass, "test_domain", "test_service")
with pytest.raises(ServiceValidationError, match="blocking=False") as exc:
await hass.services.async_call(
@@ -1860,7 +1846,6 @@ async def test_serviceregistry_return_response_invalid(
hass: HomeAssistant, response_data: Any, expected_error: str
) -> None:
"""Test service call response data must be json serializable objects."""
await async_setup_component(hass, "homeassistant", {})
def service_handler(call: ServiceCall) -> ServiceResponse:
"""Service handler coroutine."""
@@ -1897,7 +1882,6 @@ async def test_serviceregistry_return_response_arguments(
expected_error: str,
) -> None:
"""Test service call response data invalid arguments."""
await async_setup_component(hass, "homeassistant", {})
hass.services.async_register(
"test_domain",