Convert translation helper to use async_get_integration (#23054)
* Convert translation helper to use async_get_integration * Simplify after comments * Lint * Fix typing * Typo
This commit is contained in:
parent
b767232e50
commit
3f69d0283d
2 changed files with 39 additions and 50 deletions
|
@ -8,6 +8,7 @@ import pytest
|
|||
from homeassistant import config_entries
|
||||
import homeassistant.helpers.translation as translation
|
||||
from homeassistant.setup import async_setup_component
|
||||
from tests.common import mock_coro
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -52,20 +53,20 @@ async def test_component_translation_file(hass):
|
|||
'test_package'
|
||||
})
|
||||
|
||||
assert path.normpath(translation.component_translation_file(
|
||||
assert path.normpath(await translation.component_translation_file(
|
||||
hass, 'switch.test', 'en')) == path.normpath(hass.config.path(
|
||||
'custom_components', 'test', '.translations', 'switch.en.json'))
|
||||
|
||||
assert path.normpath(translation.component_translation_file(
|
||||
assert path.normpath(await translation.component_translation_file(
|
||||
hass, 'switch.test_embedded', 'en')) == path.normpath(hass.config.path(
|
||||
'custom_components', 'test_embedded', '.translations',
|
||||
'switch.en.json'))
|
||||
|
||||
assert path.normpath(translation.component_translation_file(
|
||||
hass, 'test_standalone', 'en')) == path.normpath(hass.config.path(
|
||||
'custom_components', '.translations', 'test_standalone.en.json'))
|
||||
assert await translation.component_translation_file(
|
||||
hass, 'test_standalone', 'en'
|
||||
) is None
|
||||
|
||||
assert path.normpath(translation.component_translation_file(
|
||||
assert path.normpath(await translation.component_translation_file(
|
||||
hass, 'test_package', 'en')) == path.normpath(hass.config.path(
|
||||
'custom_components', 'test_package', '.translations', 'en.json'))
|
||||
|
||||
|
@ -133,7 +134,7 @@ async def test_get_translations_loads_config_flows(hass, mock_config_flows):
|
|||
mock_config_flows.append('component1')
|
||||
|
||||
with patch.object(translation, 'component_translation_file',
|
||||
return_value='bla.json'), \
|
||||
return_value=mock_coro('bla.json')), \
|
||||
patch.object(translation, 'load_translations_files', return_value={
|
||||
'component1': {'hello': 'world'}}):
|
||||
translations = await translation.async_get_translations(hass, 'en')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue