Use start_reconfigure_flow in config flow tests (#127191)

* Use start_reconfigure_flow in config flow tests

* Adjust fritz
pull/127334/head
epenet 2024-10-02 10:01:15 +02:00 committed by GitHub
parent 2a2af01d12
commit 9873371413
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
27 changed files with 77 additions and 464 deletions

View File

@ -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"

View File

@ -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,

View File

@ -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"] == {}

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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}},

View File

@ -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(

View File

@ -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"

View File

@ -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(

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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",

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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(

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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"