mirror of
https://github.com/home-assistant/core.git
synced 2025-04-27 18:57:57 +00:00
Fix tests
This commit is contained in:
parent
7468cc21be
commit
6f27c5ae46
@ -95,30 +95,23 @@ async def test_get_translations(hass, mock_config_flows):
|
|||||||
assert await async_setup_component(hass, "switch", {"switch": {"platform": "test"}})
|
assert await async_setup_component(hass, "switch", {"switch": {"platform": "test"}})
|
||||||
|
|
||||||
translations = await translation.async_get_translations(hass, "en")
|
translations = await translation.async_get_translations(hass, "en")
|
||||||
assert translations == {
|
|
||||||
"component.switch.state.string1": "Value 1",
|
assert translations["component.switch.state.string1"] == "Value 1"
|
||||||
"component.switch.state.string2": "Value 2",
|
assert translations["component.switch.state.string2"] == "Value 2"
|
||||||
}
|
|
||||||
|
|
||||||
translations = await translation.async_get_translations(hass, "de")
|
translations = await translation.async_get_translations(hass, "de")
|
||||||
assert translations == {
|
assert translations["component.switch.state.string1"] == "German Value 1"
|
||||||
"component.switch.state.string1": "German Value 1",
|
assert translations["component.switch.state.string2"] == "German Value 2"
|
||||||
"component.switch.state.string2": "German Value 2",
|
|
||||||
}
|
|
||||||
|
|
||||||
# Test a partial translation
|
# Test a partial translation
|
||||||
translations = await translation.async_get_translations(hass, "es")
|
translations = await translation.async_get_translations(hass, "es")
|
||||||
assert translations == {
|
assert translations["component.switch.state.string1"] == "Spanish Value 1"
|
||||||
"component.switch.state.string1": "Spanish Value 1",
|
assert translations["component.switch.state.string2"] == "Value 2"
|
||||||
"component.switch.state.string2": "Value 2",
|
|
||||||
}
|
|
||||||
|
|
||||||
# Test that an untranslated language falls back to English.
|
# Test that an untranslated language falls back to English.
|
||||||
translations = await translation.async_get_translations(hass, "invalid-language")
|
translations = await translation.async_get_translations(hass, "invalid-language")
|
||||||
assert translations == {
|
assert translations["component.switch.state.string1"] == "Value 1"
|
||||||
"component.switch.state.string1": "Value 1",
|
assert translations["component.switch.state.string2"] == "Value 2"
|
||||||
"component.switch.state.string2": "Value 2",
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async def test_get_translations_loads_config_flows(hass, mock_config_flows):
|
async def test_get_translations_loads_config_flows(hass, mock_config_flows):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user