mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Fix missing translation string in emoncms (#129859)
This commit is contained in:
parent
4729b19dc6
commit
6caa4baa00
@ -79,6 +79,7 @@ class EmoncmsConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Initiate a flow via the UI."""
|
"""Initiate a flow via the UI."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
description_placeholders = {}
|
||||||
|
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
self._async_abort_entries_match(
|
self._async_abort_entries_match(
|
||||||
@ -91,7 +92,8 @@ class EmoncmsConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self.hass, user_input[CONF_URL], user_input[CONF_API_KEY]
|
self.hass, user_input[CONF_URL], user_input[CONF_API_KEY]
|
||||||
)
|
)
|
||||||
if not result[CONF_SUCCESS]:
|
if not result[CONF_SUCCESS]:
|
||||||
errors["base"] = result[CONF_MESSAGE]
|
errors["base"] = "api_error"
|
||||||
|
description_placeholders = {"details": result[CONF_MESSAGE]}
|
||||||
else:
|
else:
|
||||||
self.include_only_feeds = user_input.get(CONF_ONLY_INCLUDE_FEEDID)
|
self.include_only_feeds = user_input.get(CONF_ONLY_INCLUDE_FEEDID)
|
||||||
self.url = user_input[CONF_URL]
|
self.url = user_input[CONF_URL]
|
||||||
@ -115,6 +117,7 @@ class EmoncmsConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
user_input,
|
user_input,
|
||||||
),
|
),
|
||||||
errors=errors,
|
errors=errors,
|
||||||
|
description_placeholders=description_placeholders,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_choose_feeds(
|
async def async_step_choose_feeds(
|
||||||
@ -177,6 +180,7 @@ class EmoncmsOptionsFlow(OptionsFlow):
|
|||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Manage the options."""
|
"""Manage the options."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
|
description_placeholders = {}
|
||||||
data = self.options if self.options else self.config_entry.data
|
data = self.options if self.options else self.config_entry.data
|
||||||
url = data[CONF_URL]
|
url = data[CONF_URL]
|
||||||
api_key = data[CONF_API_KEY]
|
api_key = data[CONF_API_KEY]
|
||||||
@ -184,7 +188,8 @@ class EmoncmsOptionsFlow(OptionsFlow):
|
|||||||
options: list = include_only_feeds
|
options: list = include_only_feeds
|
||||||
result = await get_feed_list(self.hass, url, api_key)
|
result = await get_feed_list(self.hass, url, api_key)
|
||||||
if not result[CONF_SUCCESS]:
|
if not result[CONF_SUCCESS]:
|
||||||
errors["base"] = result[CONF_MESSAGE]
|
errors["base"] = "api_error"
|
||||||
|
description_placeholders = {"details": result[CONF_MESSAGE]}
|
||||||
else:
|
else:
|
||||||
options = get_options(result[CONF_MESSAGE])
|
options = get_options(result[CONF_MESSAGE])
|
||||||
dropdown = {"options": options, "mode": "dropdown", "multiple": True}
|
dropdown = {"options": options, "mode": "dropdown", "multiple": True}
|
||||||
@ -209,4 +214,5 @@ class EmoncmsOptionsFlow(OptionsFlow):
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
errors=errors,
|
errors=errors,
|
||||||
|
description_placeholders=description_placeholders,
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
|
"error": {
|
||||||
|
"api_error": "An error occured in the pyemoncms API : {details}"
|
||||||
|
},
|
||||||
"step": {
|
"step": {
|
||||||
"user": {
|
"user": {
|
||||||
"data": {
|
"data": {
|
||||||
@ -19,6 +22,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"options": {
|
"options": {
|
||||||
|
"error": {
|
||||||
|
"api_error": "[%key:component::emoncms::config::error::api_error%]"
|
||||||
|
},
|
||||||
"step": {
|
"step": {
|
||||||
"init": {
|
"init": {
|
||||||
"data": {
|
"data": {
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
from unittest.mock import AsyncMock
|
from unittest.mock import AsyncMock
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
from homeassistant.components.emoncms.const import CONF_ONLY_INCLUDE_FEEDID, DOMAIN
|
from homeassistant.components.emoncms.const import CONF_ONLY_INCLUDE_FEEDID, DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_URL
|
from homeassistant.const import CONF_API_KEY, CONF_URL
|
||||||
@ -44,7 +42,7 @@ async def test_flow_import_failure(
|
|||||||
data=YAML,
|
data=YAML,
|
||||||
)
|
)
|
||||||
assert result["type"] is FlowResultType.ABORT
|
assert result["type"] is FlowResultType.ABORT
|
||||||
assert result["reason"] == EMONCMS_FAILURE["message"]
|
assert result["reason"] == "api_error"
|
||||||
|
|
||||||
|
|
||||||
async def test_flow_import_already_configured(
|
async def test_flow_import_already_configured(
|
||||||
@ -129,10 +127,6 @@ async def test_options_flow(
|
|||||||
assert config_entry.options == CONFIG_ENTRY
|
assert config_entry.options == CONFIG_ENTRY
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize( # Remove when translations fixed
|
|
||||||
"ignore_translations",
|
|
||||||
["component.emoncms.options.error.failure"],
|
|
||||||
)
|
|
||||||
async def test_options_flow_failure(
|
async def test_options_flow_failure(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
mock_setup_entry: AsyncMock,
|
mock_setup_entry: AsyncMock,
|
||||||
@ -144,6 +138,7 @@ async def test_options_flow_failure(
|
|||||||
await setup_integration(hass, config_entry)
|
await setup_integration(hass, config_entry)
|
||||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert result["errors"]["base"] == "failure"
|
assert result["errors"]["base"] == "api_error"
|
||||||
|
assert result["description_placeholders"]["details"] == "failure"
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "init"
|
assert result["step_id"] == "init"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user