From 1aeba8a9bdbf44c12bf10af564d1901c3137151c Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 1 Jun 2022 09:44:22 +0200 Subject: [PATCH] Use Mapping for async_step_reauth in discord (#72812) * Fix tests * Cleanup code accordingly --- homeassistant/components/discord/config_flow.py | 10 ++++------ tests/components/discord/test_config_flow.py | 7 +------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/discord/config_flow.py b/homeassistant/components/discord/config_flow.py index bce27feced3..93027132850 100644 --- a/homeassistant/components/discord/config_flow.py +++ b/homeassistant/components/discord/config_flow.py @@ -1,7 +1,9 @@ """Config flow for Discord integration.""" from __future__ import annotations +from collections.abc import Mapping import logging +from typing import Any from aiohttp.client_exceptions import ClientConnectorError import nextcord @@ -21,13 +23,9 @@ CONFIG_SCHEMA = vol.Schema({vol.Required(CONF_API_TOKEN): str}) class DiscordFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): """Handle a config flow for Discord.""" - async def async_step_reauth(self, user_input: dict | None = None) -> FlowResult: + async def async_step_reauth(self, data: Mapping[str, Any]) -> FlowResult: """Handle a reauthorization flow request.""" - if user_input is not None: - return await self.async_step_reauth_confirm() - - self._set_confirm_only() - return self.async_show_form(step_id="reauth") + return await self.async_step_reauth_confirm() async def async_step_reauth_confirm( self, user_input: dict[str, str] | None = None diff --git a/tests/components/discord/test_config_flow.py b/tests/components/discord/test_config_flow.py index 59030187866..9d4966929be 100644 --- a/tests/components/discord/test_config_flow.py +++ b/tests/components/discord/test_config_flow.py @@ -128,14 +128,9 @@ async def test_flow_reauth(hass: HomeAssistant) -> None: "entry_id": entry.entry_id, "unique_id": entry.unique_id, }, + data=entry.data, ) - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM - assert result["step_id"] == "reauth" - result = await hass.config_entries.flow.async_configure( - result["flow_id"], - user_input={}, - ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "reauth_confirm"