Automatically add entry title as name placeholder in reauth (#64078)

This commit is contained in:
Franck Nijhof 2022-01-18 23:18:16 +01:00 committed by GitHub
parent 7943b0ff5e
commit 9e33a3014c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 0 deletions

View File

@ -608,6 +608,7 @@ class ConfigEntry:
flow_context = { flow_context = {
"source": SOURCE_REAUTH, "source": SOURCE_REAUTH,
"entry_id": self.entry_id, "entry_id": self.entry_id,
"title_placeholders": {"name": self.title},
"unique_id": self.unique_id, "unique_id": self.unique_id,
} }

View File

@ -897,6 +897,7 @@ async def test_setup_entry_no_token_reauth(hass: HomeAssistant) -> None:
CONF_SOURCE: SOURCE_REAUTH, CONF_SOURCE: SOURCE_REAUTH,
"entry_id": config_entry.entry_id, "entry_id": config_entry.entry_id,
"unique_id": config_entry.unique_id, "unique_id": config_entry.unique_id,
"title_placeholders": {"name": config_entry.title},
}, },
data=config_entry.data, data=config_entry.data,
) )
@ -925,6 +926,7 @@ async def test_setup_entry_bad_token_reauth(hass: HomeAssistant) -> None:
CONF_SOURCE: SOURCE_REAUTH, CONF_SOURCE: SOURCE_REAUTH,
"entry_id": config_entry.entry_id, "entry_id": config_entry.entry_id,
"unique_id": config_entry.unique_id, "unique_id": config_entry.unique_id,
"title_placeholders": {"name": config_entry.title},
}, },
data=config_entry.data, data=config_entry.data,
) )

View File

@ -43,6 +43,7 @@ async def test_setup_auth_failed(setup_component, hass, config_entry, smarttub_a
"source": SOURCE_REAUTH, "source": SOURCE_REAUTH,
"entry_id": config_entry.entry_id, "entry_id": config_entry.entry_id,
"unique_id": config_entry.unique_id, "unique_id": config_entry.unique_id,
"title_placeholders": {"name": config_entry.title},
}, },
data=config_entry.data, data=config_entry.data,
) )

View File

@ -33,6 +33,7 @@ async def test_config_entry_reauth(
CONF_SOURCE: SOURCE_REAUTH, CONF_SOURCE: SOURCE_REAUTH,
"entry_id": entry.entry_id, "entry_id": entry.entry_id,
"unique_id": entry.unique_id, "unique_id": entry.unique_id,
"title_placeholders": {"name": entry.title},
}, },
data=entry.data, data=entry.data,
) )

View File

@ -2739,6 +2739,7 @@ async def test_setup_raise_auth_failed(hass, caplog):
assert len(flows) == 1 assert len(flows) == 1
assert flows[0]["context"]["entry_id"] == entry.entry_id assert flows[0]["context"]["entry_id"] == entry.entry_id
assert flows[0]["context"]["source"] == config_entries.SOURCE_REAUTH assert flows[0]["context"]["source"] == config_entries.SOURCE_REAUTH
assert flows[0]["context"]["title_placeholders"] == {"name": "test_title"}
caplog.clear() caplog.clear()
entry.state = config_entries.ConfigEntryState.NOT_LOADED entry.state = config_entries.ConfigEntryState.NOT_LOADED