From fe880f8f7288bdd165f81f43c450f0fb37c70162 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 7 Nov 2026 11:27:25 +0100 Subject: [PATCH] Config flow tests: assert only the reason placeholder Reauth forms also carry Home Assistant's own name placeholder. Co-authored-by: Cursor --- tests/test_config_flow.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 23eb9a5..cb357b2 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -206,7 +206,7 @@ async def test_reauth_bad_token_keeps_old_tokens(hass: HomeAssistant) -> None: assert result["type"] is FlowResultType.FORM assert result["step_id"] == "token" assert result["errors"] == {"base": "token_rejected"} - assert result["description_placeholders"] == {"reason": TOKEN_REJECTED_REASON} + assert result["description_placeholders"]["reason"] == TOKEN_REJECTED_REASON assert entry.data[CONF_ACCESS_TOKEN] == "old-access" assert entry.data[CONF_REFRESH_TOKEN] == "old-refresh" @@ -221,9 +221,7 @@ async def test_reauth_wrong_password_returns_to_reauth_confirm( assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" assert result["errors"] == {"base": "invalid_credentials"} - assert result["description_placeholders"] == { - "reason": "Incorrect username or password" - } + assert result["description_placeholders"]["reason"] == "Incorrect username or password" assert entry.data[CONF_ACCESS_TOKEN] == "old-access" # Corrected credentials lead to a fresh token, then success. @@ -252,7 +250,7 @@ async def test_reauth_other_failure_is_invalid_auth(hass: HomeAssistant) -> None assert result["step_id"] == "token" assert result["errors"] == {"base": "invalid_auth"} - assert result["description_placeholders"] == {"reason": "no reason given"} + assert result["description_placeholders"]["reason"] == "no reason given" assert entry.data[CONF_ACCESS_TOKEN] == "old-access" @@ -391,11 +389,11 @@ async def _run_user_setup(hass, client): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) - assert result["description_placeholders"] == {"reason": ""} + assert result["description_placeholders"]["reason"] == "" result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_EMAIL: EMAIL, CONF_PASSWORD: PASSWORD} ) - assert result["description_placeholders"] == {"reason": ""} + assert result["description_placeholders"]["reason"] == "" return await hass.config_entries.flow.async_configure( result["flow_id"], {"recaptcha_token": TOKEN} ) @@ -409,9 +407,7 @@ async def test_user_setup_wrong_password_returns_to_user_form( assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {"base": "invalid_credentials"} - assert result["description_placeholders"] == { - "reason": "Incorrect username or password" - } + assert result["description_placeholders"]["reason"] == "Incorrect username or password" async def test_user_setup_token_rejected(hass: HomeAssistant) -> None: @@ -419,7 +415,7 @@ async def test_user_setup_token_rejected(hass: HomeAssistant) -> None: assert result["step_id"] == "token" assert result["errors"] == {"base": "token_rejected"} - assert result["description_placeholders"] == {"reason": TOKEN_REJECTED_REASON} + assert result["description_placeholders"]["reason"] == TOKEN_REJECTED_REASON async def test_user_setup_other_auth_failure(hass: HomeAssistant) -> None: @@ -427,9 +423,7 @@ async def test_user_setup_other_auth_failure(hass: HomeAssistant) -> None: assert result["step_id"] == "token" assert result["errors"] == {"base": "invalid_auth"} - assert result["description_placeholders"] == { - "reason": "USER_PASSWORD_AUTH flow not enabled for this client" - } + assert result["description_placeholders"]["reason"] == "USER_PASSWORD_AUTH flow not enabled for this client" # --- Translations must cover every reachable abort reason ---