mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Use reauth_confirm in co2signal (#124781)
This commit is contained in:
parent
7d61dd13d9
commit
2900fa733d
@ -131,16 +131,23 @@ class ElectricityMapsConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
)
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle the reauth step."""
|
||||
data_schema = vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_API_KEY): cv.string,
|
||||
}
|
||||
)
|
||||
return await self._validate_and_create("reauth", data_schema, entry_data)
|
||||
return await self._validate_and_create(
|
||||
"reauth_confirm", data_schema, user_input
|
||||
)
|
||||
|
||||
async def _validate_and_create(
|
||||
self, step_id: str, data_schema: vol.Schema, data: Mapping[str, Any]
|
||||
self, step_id: str, data_schema: vol.Schema, data: Mapping[str, Any] | None
|
||||
) -> ConfigFlowResult:
|
||||
"""Validate data and show form if it is invalid."""
|
||||
errors: dict[str, str] = {}
|
||||
|
@ -19,7 +19,7 @@
|
||||
"country_code": "Country code"
|
||||
}
|
||||
},
|
||||
"reauth": {
|
||||
"reauth_confirm": {
|
||||
"data": {
|
||||
"api_key": "[%key:common::config_flow::data::access_token%]"
|
||||
}
|
||||
|
@ -198,17 +198,10 @@ async def test_reauth(
|
||||
"""Test reauth flow."""
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
init_result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"entry_id": config_entry.entry_id,
|
||||
},
|
||||
data=None,
|
||||
)
|
||||
init_result = await config_entry.start_reauth_flow(hass)
|
||||
|
||||
assert init_result["type"] is FlowResultType.FORM
|
||||
assert init_result["step_id"] == "reauth"
|
||||
assert init_result["step_id"] == "reauth_confirm"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.co2signal.async_setup_entry",
|
||||
|
@ -109,4 +109,4 @@ async def test_sensor_reauth_triggered(
|
||||
|
||||
assert (flows := hass.config_entries.flow.async_progress())
|
||||
assert len(flows) == 1
|
||||
assert flows[0]["step_id"] == "reauth"
|
||||
assert flows[0]["step_id"] == "reauth_confirm"
|
||||
|
Loading…
x
Reference in New Issue
Block a user