mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 05:06:13 +01:00
Always include homeassistant translations in tests (#162850)
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user