mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add filter to translation event listeners to avoid creating tasks (#110732)
This commit is contained in:
@@ -602,12 +602,21 @@ async def test_setup(hass: HomeAssistant):
|
||||
await hass.async_block_till_done()
|
||||
mock.assert_not_called()
|
||||
|
||||
# Should not be called if the language is the current language
|
||||
with patch(
|
||||
"homeassistant.helpers.translation._async_load_state_translations_to_cache",
|
||||
) as mock:
|
||||
hass.bus.async_fire(EVENT_CORE_CONFIG_UPDATE, {"language": "en"})
|
||||
await hass.async_block_till_done()
|
||||
mock.assert_called_once_with(hass, hass.config.language, None)
|
||||
mock.assert_not_called()
|
||||
|
||||
# Should be called if the language is different
|
||||
with patch(
|
||||
"homeassistant.helpers.translation._async_load_state_translations_to_cache",
|
||||
) as mock:
|
||||
hass.bus.async_fire(EVENT_CORE_CONFIG_UPDATE, {"language": "es"})
|
||||
await hass.async_block_till_done()
|
||||
mock.assert_called_once_with(hass, "es", None)
|
||||
|
||||
with patch(
|
||||
"homeassistant.helpers.translation._async_load_state_translations_to_cache",
|
||||
|
||||
Reference in New Issue
Block a user