From 98733714131df50dc351f58d60997da92059eee2 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:01:15 +0200 Subject: [PATCH] Use start_reconfigure_flow in config flow tests (#127191) * Use start_reconfigure_flow in config flow tests * Adjust fritz --- tests/components/brother/test_config_flow.py | 42 ++--------------- .../bryant_evolution/test_config_flow.py | 8 +--- .../enphase_envoy/test_config_flow.py | 46 +++---------------- .../components/feedreader/test_config_flow.py | 20 ++------ tests/components/fritz/test_config_flow.py | 19 ++------ tests/components/fritzbox/test_config_flow.py | 14 ++---- tests/components/fronius/test_config_flow.py | 45 ++---------------- .../google_travel_time/test_config_flow.py | 42 ++--------------- .../here_travel_time/test_config_flow.py | 8 +--- tests/components/holiday/test_config_flow.py | 24 ++-------- .../components/homeworks/test_config_flow.py | 22 ++------- .../jewish_calendar/test_config_flow.py | 11 +---- .../components/lamarzocco/test_config_flow.py | 17 +------ tests/components/lcn/test_config_flow.py | 18 +------- tests/components/madvr/test_config_flow.py | 17 ++----- tests/components/mealie/test_config_flow.py | 20 ++------ tests/components/melcloud/test_config_flow.py | 21 +-------- tests/components/nam/test_config_flow.py | 33 ++----------- tests/components/pyload/test_config_flow.py | 20 ++------ tests/components/reolink/test_config_flow.py | 8 +--- tests/components/shelly/test_config_flow.py | 28 ++--------- tests/components/smhi/test_config_flow.py | 8 +--- tests/components/solarlog/test_config_flow.py | 10 +--- tests/components/tado/test_config_flow.py | 8 +--- tests/components/tedee/test_config_flow.py | 15 +----- tests/components/vallox/conftest.py | 9 +--- .../waze_travel_time/test_config_flow.py | 8 +--- 27 files changed, 77 insertions(+), 464 deletions(-) diff --git a/tests/components/brother/test_config_flow.py b/tests/components/brother/test_config_flow.py index ac7af4cc912..0dc179061b4 100644 --- a/tests/components/brother/test_config_flow.py +++ b/tests/components/brother/test_config_flow.py @@ -8,11 +8,7 @@ import pytest from homeassistant.components import zeroconf from homeassistant.components.brother.const import DOMAIN -from homeassistant.config_entries import ( - SOURCE_RECONFIGURE, - SOURCE_USER, - SOURCE_ZEROCONF, -) +from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF from homeassistant.const import CONF_HOST, CONF_TYPE from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -262,14 +258,7 @@ async def test_reconfigure_successful( """Test starting a reconfigure flow.""" await init_integration(hass, mock_config_entry) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": mock_config_entry.entry_id, - }, - data=mock_config_entry.data, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -305,14 +294,7 @@ async def test_reconfigure_not_successful( """Test starting a reconfigure flow but no connection found.""" await init_integration(hass, mock_config_entry) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": mock_config_entry.entry_id, - }, - data=mock_config_entry.data, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -351,14 +333,7 @@ async def test_reconfigure_invalid_hostname( """Test starting a reconfigure flow but no connection found.""" await init_integration(hass, mock_config_entry) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": mock_config_entry.entry_id, - }, - data=mock_config_entry.data, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -381,14 +356,7 @@ async def test_reconfigure_not_the_same_device( """Test starting the reconfiguration process, but with a different printer.""" await init_integration(hass, mock_config_entry) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": mock_config_entry.entry_id, - }, - data=mock_config_entry.data, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/bryant_evolution/test_config_flow.py b/tests/components/bryant_evolution/test_config_flow.py index 39d203201eb..7f870c0cdf9 100644 --- a/tests/components/bryant_evolution/test_config_flow.py +++ b/tests/components/bryant_evolution/test_config_flow.py @@ -134,13 +134,7 @@ async def test_reconfigure( """Test that reconfigure discovers additional systems and zones.""" # Reconfigure with additional systems and zones. - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": mock_evolution_entry.entry_id, - }, - ) + result = await mock_evolution_entry.start_reconfigure_flow(hass) with ( patch.object( BryantEvolutionLocalClient, diff --git a/tests/components/enphase_envoy/test_config_flow.py b/tests/components/enphase_envoy/test_config_flow.py index 42e41051e0a..f519935e6fc 100644 --- a/tests/components/enphase_envoy/test_config_flow.py +++ b/tests/components/enphase_envoy/test_config_flow.py @@ -13,11 +13,7 @@ from homeassistant.components.enphase_envoy.const import ( OPTION_DIAGNOSTICS_INCLUDE_FIXTURES, OPTION_DIAGNOSTICS_INCLUDE_FIXTURES_DEFAULT_VALUE, ) -from homeassistant.config_entries import ( - SOURCE_RECONFIGURE, - SOURCE_USER, - SOURCE_ZEROCONF, -) +from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -698,13 +694,7 @@ async def test_reconfigure( ) -> None: """Test we can reconfiger the entry.""" await setup_integration(hass, config_entry) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": config_entry.entry_id, - }, - ) + result = await config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" assert result["errors"] == {} @@ -740,13 +730,7 @@ async def test_reconfigure_nochange( ) -> None: """Test we get the reconfigure form and apply nochange.""" await setup_integration(hass, config_entry) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": config_entry.entry_id, - }, - ) + result = await config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" assert result["errors"] == {} @@ -782,13 +766,7 @@ async def test_reconfigure_otherenvoy( ) -> None: """Test entering ip of other envoy and prevent changing it based on serial.""" await setup_integration(hass, config_entry) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": config_entry.entry_id, - }, - ) + result = await config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" assert result["errors"] == {} @@ -853,13 +831,7 @@ async def test_reconfigure_auth_failure( """Test changing credentials for existing host with auth failure.""" await setup_integration(hass, config_entry) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": config_entry.entry_id, - }, - ) + result = await config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["errors"] == {} @@ -928,13 +900,7 @@ async def test_reconfigure_change_ip_to_existing( assert other_entry.data[CONF_USERNAME] == "other-username" assert other_entry.data[CONF_PASSWORD] == "other-password" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": config_entry.entry_id, - }, - ) + result = await config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" assert result["errors"] == {} diff --git a/tests/components/feedreader/test_config_flow.py b/tests/components/feedreader/test_config_flow.py index 47bccce902f..29e52c5b01e 100644 --- a/tests/components/feedreader/test_config_flow.py +++ b/tests/components/feedreader/test_config_flow.py @@ -11,7 +11,7 @@ from homeassistant.components.feedreader.const import ( DEFAULT_MAX_ENTRIES, DOMAIN, ) -from homeassistant.config_entries import SOURCE_RECONFIGURE, SOURCE_USER +from homeassistant.config_entries import SOURCE_USER from homeassistant.const import CONF_URL from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -162,14 +162,7 @@ async def test_reconfigure(hass: HomeAssistant, feedparser) -> None: await hass.async_block_till_done() # init user flow - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -201,14 +194,7 @@ async def test_reconfigure_errors( entry.add_to_hass(hass) # init user flow - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/fritz/test_config_flow.py b/tests/components/fritz/test_config_flow.py index deefe7e4e77..b3e9a838645 100644 --- a/tests/components/fritz/test_config_flow.py +++ b/tests/components/fritz/test_config_flow.py @@ -23,7 +23,7 @@ from homeassistant.components.fritz.const import ( FRITZ_AUTH_EXCEPTIONS, ) from homeassistant.components.ssdp import ATTR_UPNP_UDN -from homeassistant.config_entries import SOURCE_RECONFIGURE, SOURCE_SSDP, SOURCE_USER +from homeassistant.config_entries import SOURCE_SSDP, SOURCE_USER from homeassistant.const import ( CONF_HOST, CONF_PASSWORD, @@ -452,14 +452,9 @@ async def test_reconfigure_successful( mock_request_post.return_value.status_code = 200 mock_request_post.return_value.text = MOCK_REQUEST - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": mock_config.entry_id, - "show_advanced_options": show_advanced_options, - }, - data=mock_config.data, + result = await mock_config.start_reconfigure_flow( + hass, + context={"show_advanced_options": show_advanced_options}, ) assert result["type"] is FlowResultType.FORM @@ -514,11 +509,7 @@ async def test_reconfigure_not_successful( mock_request_post.return_value.status_code = 200 mock_request_post.return_value.text = MOCK_REQUEST - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_RECONFIGURE, "entry_id": mock_config.entry_id}, - data=mock_config.data, - ) + result = await mock_config.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/fritzbox/test_config_flow.py b/tests/components/fritzbox/test_config_flow.py index fd53bd2e637..fc63684e5d1 100644 --- a/tests/components/fritzbox/test_config_flow.py +++ b/tests/components/fritzbox/test_config_flow.py @@ -12,7 +12,7 @@ from requests.exceptions import HTTPError from homeassistant.components import ssdp from homeassistant.components.fritzbox.const import DOMAIN from homeassistant.components.ssdp import ATTR_UPNP_FRIENDLY_NAME, ATTR_UPNP_UDN -from homeassistant.config_entries import SOURCE_RECONFIGURE, SOURCE_SSDP, SOURCE_USER +from homeassistant.config_entries import SOURCE_SSDP, SOURCE_USER from homeassistant.const import CONF_DEVICES, CONF_HOST, CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -196,11 +196,7 @@ async def test_reconfigure_success(hass: HomeAssistant, fritz: Mock) -> None: assert mock_config.data[CONF_USERNAME] == "fake_user" assert mock_config.data[CONF_PASSWORD] == "fake_pass" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_RECONFIGURE, "entry_id": mock_config.entry_id}, - data=mock_config.data, - ) + result = await mock_config.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -229,11 +225,7 @@ async def test_reconfigure_failed(hass: HomeAssistant, fritz: Mock) -> None: assert mock_config.data[CONF_USERNAME] == "fake_user" assert mock_config.data[CONF_PASSWORD] == "fake_pass" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_RECONFIGURE, "entry_id": mock_config.entry_id}, - data=mock_config.data, - ) + result = await mock_config.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/fronius/test_config_flow.py b/tests/components/fronius/test_config_flow.py index 41593a0ad2e..b85aafb2e1e 100644 --- a/tests/components/fronius/test_config_flow.py +++ b/tests/components/fronius/test_config_flow.py @@ -352,14 +352,7 @@ async def test_reconfigure(hass: HomeAssistant) -> None: ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure" @@ -406,14 +399,7 @@ async def test_reconfigure_cannot_connect(hass: HomeAssistant) -> None: ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) with ( patch( @@ -448,14 +434,7 @@ async def test_reconfigure_unexpected(hass: HomeAssistant) -> None: ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) with patch( "pyfronius.Fronius.current_logger_info", @@ -484,14 +463,7 @@ async def test_reconfigure_already_configured(hass: HomeAssistant) -> None: ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure" @@ -545,14 +517,7 @@ async def test_reconfigure_already_existing(hass: HomeAssistant) -> None: ) entry_2.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) with patch( "pyfronius.Fronius.current_logger_info", return_value={"unique_identifier": {"value": entry_2_uid}}, diff --git a/tests/components/google_travel_time/test_config_flow.py b/tests/components/google_travel_time/test_config_flow.py index b3e6ea0f1fc..7600c669464 100644 --- a/tests/components/google_travel_time/test_config_flow.py +++ b/tests/components/google_travel_time/test_config_flow.py @@ -198,14 +198,7 @@ async def test_malformed_api_key(hass: HomeAssistant) -> None: @pytest.mark.usefixtures("validate_config_entry", "bypass_setup") async def test_reconfigure(hass: HomeAssistant, mock_config: MockConfigEntry) -> None: """Test reconfigure flow.""" - reconfigure_result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": mock_config.entry_id, - }, - data=mock_config.data, - ) + reconfigure_result = await mock_config.start_reconfigure_flow(hass) assert reconfigure_result["type"] is FlowResultType.FORM assert reconfigure_result["step_id"] == "reconfigure_confirm" @@ -229,14 +222,7 @@ async def test_reconfigure_invalid_config_entry( hass: HomeAssistant, mock_config: MockConfigEntry ) -> None: """Test we get the form.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": mock_config.entry_id, - }, - data=mock_config.data, - ) + result = await mock_config.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["errors"] is None result2 = await hass.config_entries.flow.async_configure( @@ -267,13 +253,7 @@ async def test_reconfigure_invalid_api_key( hass: HomeAssistant, mock_config: MockConfigEntry ) -> None: """Test we get the form.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": mock_config.entry_id, - }, - ) + result = await mock_config.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["errors"] is None result2 = await hass.config_entries.flow.async_configure( @@ -303,13 +283,7 @@ async def test_reconfigure_transport_error( hass: HomeAssistant, mock_config: MockConfigEntry ) -> None: """Test we get the form.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": mock_config.entry_id, - }, - ) + result = await mock_config.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["errors"] is None result2 = await hass.config_entries.flow.async_configure( @@ -339,13 +313,7 @@ async def test_reconfigure_timeout( hass: HomeAssistant, mock_config: MockConfigEntry ) -> None: """Test we get the form.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": mock_config.entry_id, - }, - ) + result = await mock_config.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["errors"] is None result2 = await hass.config_entries.flow.async_configure( diff --git a/tests/components/here_travel_time/test_config_flow.py b/tests/components/here_travel_time/test_config_flow.py index ea3de64ed0c..ce210813fb2 100644 --- a/tests/components/here_travel_time/test_config_flow.py +++ b/tests/components/here_travel_time/test_config_flow.py @@ -323,13 +323,7 @@ async def do_common_reconfiguration_steps(hass: HomeAssistant) -> None: await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - reconfigure_result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - ) + reconfigure_result = await entry.start_reconfigure_flow(hass) assert reconfigure_result["type"] is FlowResultType.FORM assert reconfigure_result["step_id"] == "user" diff --git a/tests/components/holiday/test_config_flow.py b/tests/components/holiday/test_config_flow.py index 14e2b68234c..466dbaffd8b 100644 --- a/tests/components/holiday/test_config_flow.py +++ b/tests/components/holiday/test_config_flow.py @@ -230,13 +230,7 @@ async def test_reconfigure(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM result = await hass.config_entries.flow.async_configure( @@ -267,13 +261,7 @@ async def test_reconfigure_incorrect_language( ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM result = await hass.config_entries.flow.async_configure( @@ -308,13 +296,7 @@ async def test_reconfigure_entry_exists( ) entry2.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM result = await hass.config_entries.flow.async_configure( diff --git a/tests/components/homeworks/test_config_flow.py b/tests/components/homeworks/test_config_flow.py index f9deb2c20c9..503b936dc15 100644 --- a/tests/components/homeworks/test_config_flow.py +++ b/tests/components/homeworks/test_config_flow.py @@ -17,7 +17,7 @@ from homeassistant.components.homeworks.const import ( CONF_RELEASE_DELAY, DOMAIN, ) -from homeassistant.config_entries import SOURCE_RECONFIGURE, SOURCE_USER +from homeassistant.config_entries import SOURCE_USER from homeassistant.const import ( CONF_HOST, CONF_NAME, @@ -241,10 +241,7 @@ async def test_reconfigure_flow( """Test reconfigure flow.""" mock_config_entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_RECONFIGURE, "entry_id": mock_config_entry.entry_id}, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -309,10 +306,7 @@ async def test_reconfigure_flow_flow_duplicate( ) entry2.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_RECONFIGURE, "entry_id": entry1.entry_id}, - ) + result = await entry1.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -334,10 +328,7 @@ async def test_reconfigure_flow_flow_no_change( """Test reconfigure flow.""" mock_config_entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_RECONFIGURE, "entry_id": mock_config_entry.entry_id}, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -382,10 +373,7 @@ async def test_reconfigure_flow_credentials_password_only( """Test reconfigure flow.""" mock_config_entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_RECONFIGURE, "entry_id": mock_config_entry.entry_id}, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/jewish_calendar/test_config_flow.py b/tests/components/jewish_calendar/test_config_flow.py index b9a041261aa..1468a66efbb 100644 --- a/tests/components/jewish_calendar/test_config_flow.py +++ b/tests/components/jewish_calendar/test_config_flow.py @@ -14,7 +14,7 @@ from homeassistant.components.jewish_calendar.const import ( DEFAULT_LANGUAGE, DOMAIN, ) -from homeassistant.config_entries import SOURCE_RECONFIGURE, SOURCE_USER +from homeassistant.config_entries import SOURCE_USER from homeassistant.const import ( CONF_ELEVATION, CONF_LANGUAGE, @@ -175,14 +175,7 @@ async def test_reconfigure( await hass.async_block_till_done() # init user flow - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": mock_config_entry.entry_id, - }, - data=mock_config_entry.data, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/lamarzocco/test_config_flow.py b/tests/components/lamarzocco/test_config_flow.py index 4bb26fb5d30..7206013de10 100644 --- a/tests/components/lamarzocco/test_config_flow.py +++ b/tests/components/lamarzocco/test_config_flow.py @@ -7,12 +7,7 @@ from lmcloud.models import LaMarzoccoDeviceInfo from homeassistant.components.lamarzocco.config_flow import CONF_MACHINE from homeassistant.components.lamarzocco.const import CONF_USE_BLUETOOTH, DOMAIN -from homeassistant.config_entries import ( - SOURCE_BLUETOOTH, - SOURCE_RECONFIGURE, - SOURCE_USER, - ConfigEntryState, -) +from homeassistant.config_entries import SOURCE_BLUETOOTH, SOURCE_USER, ConfigEntryState from homeassistant.const import ( CONF_HOST, CONF_MAC, @@ -273,15 +268,7 @@ async def test_reconfigure_flow( """Testing reconfgure flow.""" mock_config_entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "unique_id": mock_config_entry.unique_id, - "entry_id": mock_config_entry.entry_id, - }, - data=mock_config_entry.data, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/lcn/test_config_flow.py b/tests/components/lcn/test_config_flow.py index 67c10b250a8..33b40e15b0c 100644 --- a/tests/components/lcn/test_config_flow.py +++ b/tests/components/lcn/test_config_flow.py @@ -204,14 +204,7 @@ async def test_step_reconfigure(hass: HomeAssistant, entry: MockConfigEntry) -> entry.add_to_hass(hass) old_entry_data = entry.data.copy() - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=old_entry_data, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -249,14 +242,7 @@ async def test_step_reconfigure_error( """Test for error in reconfigure step is handled correctly.""" entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] == data_entry_flow.FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/madvr/test_config_flow.py b/tests/components/madvr/test_config_flow.py index a2900d4be12..42081f3b9b5 100644 --- a/tests/components/madvr/test_config_flow.py +++ b/tests/components/madvr/test_config_flow.py @@ -6,7 +6,7 @@ from unittest.mock import AsyncMock, patch import pytest from homeassistant.components.madvr.const import DEFAULT_NAME, DOMAIN -from homeassistant.config_entries import SOURCE_RECONFIGURE, SOURCE_USER +from homeassistant.config_entries import SOURCE_USER from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -135,10 +135,7 @@ async def test_reconfigure_flow( ) -> None: """Test reconfigure flow.""" mock_config_entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_RECONFIGURE, "entry_id": mock_config_entry.entry_id}, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -176,10 +173,7 @@ async def test_reconfigure_new_device( """Test reconfigure flow.""" mock_config_entry.add_to_hass(hass) # test reconfigure with a new device (should fail) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_RECONFIGURE, "entry_id": mock_config_entry.entry_id}, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) # define new host new_host = "192.168.1.100" @@ -207,10 +201,7 @@ async def test_reconfigure_flow_errors( """Test error handling in reconfigure flow.""" mock_config_entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_RECONFIGURE, "entry_id": mock_config_entry.entry_id}, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/mealie/test_config_flow.py b/tests/components/mealie/test_config_flow.py index 777d25fdef5..aee2506b865 100644 --- a/tests/components/mealie/test_config_flow.py +++ b/tests/components/mealie/test_config_flow.py @@ -6,7 +6,7 @@ from aiomealie import About, MealieAuthenticationError, MealieConnectionError import pytest from homeassistant.components.mealie.const import DOMAIN -from homeassistant.config_entries import SOURCE_RECONFIGURE, SOURCE_USER +from homeassistant.config_entries import SOURCE_USER from homeassistant.const import CONF_API_TOKEN, CONF_HOST, CONF_VERIFY_SSL from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -242,11 +242,7 @@ async def test_reconfigure_flow( """Test reconfigure flow.""" await setup_integration(hass, mock_config_entry) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_RECONFIGURE, "entry_id": mock_config_entry.entry_id}, - data=mock_config_entry.data, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -275,11 +271,7 @@ async def test_reconfigure_flow_wrong_account( """Test reconfigure flow with wrong account.""" await setup_integration(hass, mock_config_entry) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_RECONFIGURE, "entry_id": mock_config_entry.entry_id}, - data=mock_config_entry.data, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -314,11 +306,7 @@ async def test_reconfigure_flow_exceptions( await setup_integration(hass, mock_config_entry) mock_mealie_client.get_user_info.side_effect = exception - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_RECONFIGURE, "entry_id": mock_config_entry.entry_id}, - data=mock_config_entry.data, - ) + result = await mock_config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/melcloud/test_config_flow.py b/tests/components/melcloud/test_config_flow.py index 74b16aab6ed..3f6e42ac264 100644 --- a/tests/components/melcloud/test_config_flow.py +++ b/tests/components/melcloud/test_config_flow.py @@ -9,7 +9,6 @@ import pytest from homeassistant import config_entries from homeassistant.components.melcloud.const import DOMAIN -from homeassistant.config_entries import SOURCE_RECONFIGURE from homeassistant.const import CONF_PASSWORD from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -304,15 +303,7 @@ async def test_reconfigure_flow( ) mock_entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "unique_id": mock_entry.unique_id, - "entry_id": mock_entry.entry_id, - }, - data=mock_entry.data, - ) + result = await mock_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM @@ -371,15 +362,7 @@ async def test_form_errors_reconfigure( ) mock_entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "unique_id": mock_entry.unique_id, - "entry_id": mock_entry.entry_id, - }, - data=mock_entry.data, - ) + result = await mock_entry.start_reconfigure_flow(hass) with patch( "homeassistant.components.melcloud.async_setup_entry", diff --git a/tests/components/nam/test_config_flow.py b/tests/components/nam/test_config_flow.py index f3465e59fb6..1d237694578 100644 --- a/tests/components/nam/test_config_flow.py +++ b/tests/components/nam/test_config_flow.py @@ -8,11 +8,7 @@ import pytest from homeassistant.components import zeroconf from homeassistant.components.nam.const import DOMAIN -from homeassistant.config_entries import ( - SOURCE_RECONFIGURE, - SOURCE_USER, - SOURCE_ZEROCONF, -) +from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -446,14 +442,7 @@ async def test_reconfigure_successful(hass: HomeAssistant) -> None: ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -496,14 +485,7 @@ async def test_reconfigure_not_successful(hass: HomeAssistant) -> None: ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -559,14 +541,7 @@ async def test_reconfigure_not_the_same_device(hass: HomeAssistant) -> None: ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/pyload/test_config_flow.py b/tests/components/pyload/test_config_flow.py index b4ff63e79f9..a3966987ae2 100644 --- a/tests/components/pyload/test_config_flow.py +++ b/tests/components/pyload/test_config_flow.py @@ -6,7 +6,7 @@ from pyloadapi.exceptions import CannotConnect, InvalidAuth, ParserError import pytest from homeassistant.components.pyload.const import DEFAULT_NAME, DOMAIN -from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_RECONFIGURE, SOURCE_USER +from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -247,14 +247,7 @@ async def test_reconfiguration( config_entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": config_entry.entry_id, - "unique_id": config_entry.unique_id, - }, - ) + result = await config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -289,14 +282,7 @@ async def test_reconfigure_errors( config_entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": config_entry.entry_id, - "unique_id": config_entry.unique_id, - }, - ) + result = await config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/reolink/test_config_flow.py b/tests/components/reolink/test_config_flow.py index 4ade0771ffb..9382d9f7901 100644 --- a/tests/components/reolink/test_config_flow.py +++ b/tests/components/reolink/test_config_flow.py @@ -540,13 +540,7 @@ async def test_reconfig(hass: HomeAssistant, mock_setup_entry: MagicMock) -> Non assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": config_entry.entry_id, - }, - ) + result = await config_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" diff --git a/tests/components/shelly/test_config_flow.py b/tests/components/shelly/test_config_flow.py index f03d90dbabb..316f9794471 100644 --- a/tests/components/shelly/test_config_flow.py +++ b/tests/components/shelly/test_config_flow.py @@ -23,7 +23,6 @@ from homeassistant.components.shelly.const import ( BLEScannerMode, ) from homeassistant.components.shelly.coordinator import ENTRY_RELOAD_COOLDOWN -from homeassistant.config_entries import SOURCE_RECONFIGURE from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType from homeassistant.setup import async_setup_component @@ -1362,14 +1361,7 @@ async def test_reconfigure_successful( ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -1401,14 +1393,7 @@ async def test_reconfigure_unsuccessful( ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" @@ -1445,14 +1430,7 @@ async def test_reconfigure_with_exception( ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - data=entry.data, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/smhi/test_config_flow.py b/tests/components/smhi/test_config_flow.py index a771bcc1e1d..4195d1e5d52 100644 --- a/tests/components/smhi/test_config_flow.py +++ b/tests/components/smhi/test_config_flow.py @@ -217,13 +217,7 @@ async def test_reconfigure_flow( name=entry.title, ) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM with patch( diff --git a/tests/components/solarlog/test_config_flow.py b/tests/components/solarlog/test_config_flow.py index ff7cc2209b4..df5c4bb3c7f 100644 --- a/tests/components/solarlog/test_config_flow.py +++ b/tests/components/solarlog/test_config_flow.py @@ -11,7 +11,7 @@ from solarlog_cli.solarlog_exceptions import ( from homeassistant.components.solarlog import config_flow from homeassistant.components.solarlog.const import CONF_HAS_PWD, DOMAIN -from homeassistant.config_entries import SOURCE_RECONFIGURE, SOURCE_USER +from homeassistant.config_entries import SOURCE_USER from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -205,13 +205,7 @@ async def test_reconfigure_flow( ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/tado/test_config_flow.py b/tests/components/tado/test_config_flow.py index 4f5f4180fb5..63b17dad13e 100644 --- a/tests/components/tado/test_config_flow.py +++ b/tests/components/tado/test_config_flow.py @@ -295,13 +295,7 @@ async def test_reconfigure_flow( ) entry.add_to_hass(hass) - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - ) + result = await entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM diff --git a/tests/components/tedee/test_config_flow.py b/tests/components/tedee/test_config_flow.py index 0fa3d62c26e..664c2f249d8 100644 --- a/tests/components/tedee/test_config_flow.py +++ b/tests/components/tedee/test_config_flow.py @@ -10,7 +10,7 @@ from pytedee_async import ( import pytest from homeassistant.components.tedee.const import CONF_LOCAL_ACCESS_TOKEN, DOMAIN -from homeassistant.config_entries import SOURCE_RECONFIGURE, SOURCE_USER +from homeassistant.config_entries import SOURCE_USER from homeassistant.const import CONF_HOST, CONF_WEBHOOK_ID from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType @@ -141,18 +141,7 @@ async def test_reconfigure_flow( mock_config_entry.add_to_hass(hass) - reconfigure_result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": SOURCE_RECONFIGURE, - "unique_id": mock_config_entry.unique_id, - "entry_id": mock_config_entry.entry_id, - }, - data={ - CONF_LOCAL_ACCESS_TOKEN: LOCAL_ACCESS_TOKEN, - CONF_HOST: "192.168.1.42", - }, - ) + reconfigure_result = await mock_config_entry.start_reconfigure_flow(hass) assert reconfigure_result["type"] is FlowResultType.FORM assert reconfigure_result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/vallox/conftest.py b/tests/components/vallox/conftest.py index 114728599e6..590dbc8de4b 100644 --- a/tests/components/vallox/conftest.py +++ b/tests/components/vallox/conftest.py @@ -5,7 +5,6 @@ from unittest.mock import AsyncMock, patch import pytest from vallox_websocket_api import MetricData -from homeassistant import config_entries from homeassistant.components.vallox.const import DOMAIN from homeassistant.config_entries import ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_NAME @@ -79,13 +78,7 @@ async def init_reconfigure_flow( hass: HomeAssistant, mock_entry, setup_vallox_entry ) -> tuple[MockConfigEntry, ConfigFlowResult]: """Initialize a config entry and a reconfigure flow for it.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": mock_entry.entry_id, - }, - ) + result = await mock_entry.start_reconfigure_flow(hass) assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reconfigure_confirm" diff --git a/tests/components/waze_travel_time/test_config_flow.py b/tests/components/waze_travel_time/test_config_flow.py index 87cb92f1522..9ff7509a52c 100644 --- a/tests/components/waze_travel_time/test_config_flow.py +++ b/tests/components/waze_travel_time/test_config_flow.py @@ -67,13 +67,7 @@ async def test_reconfigure(hass: HomeAssistant) -> None: await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - reconfigure_result = await hass.config_entries.flow.async_init( - DOMAIN, - context={ - "source": config_entries.SOURCE_RECONFIGURE, - "entry_id": entry.entry_id, - }, - ) + reconfigure_result = await entry.start_reconfigure_flow(hass) assert reconfigure_result["type"] is FlowResultType.FORM assert reconfigure_result["step_id"] == "user"