mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use start_reauth helper method in integration tests (h-l) (#124787)
This commit is contained in:
parent
174f22aa2f
commit
9d633f2087
@ -246,14 +246,7 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:
|
||||
"homeassistant.components.hive.config_flow.Auth.login",
|
||||
side_effect=hive_exceptions.HiveInvalidPassword(),
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"unique_id": mock_config.unique_id,
|
||||
},
|
||||
data=mock_config.data,
|
||||
)
|
||||
result = await mock_config.start_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "invalid_password"}
|
||||
@ -305,14 +298,7 @@ async def test_reauth_2fa_flow(hass: HomeAssistant) -> None:
|
||||
"homeassistant.components.hive.config_flow.Auth.login",
|
||||
side_effect=hive_exceptions.HiveInvalidPassword(),
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"unique_id": mock_config.unique_id,
|
||||
},
|
||||
data=mock_config.data,
|
||||
)
|
||||
result = await mock_config.start_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "invalid_password"}
|
||||
|
@ -341,13 +341,7 @@ async def test_reauth_flow(
|
||||
"""Test reauth flow while API is enabled."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"entry_id": mock_config_entry.entry_id,
|
||||
},
|
||||
)
|
||||
result = await mock_config_entry.start_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
@ -367,13 +361,7 @@ async def test_reauth_error(
|
||||
mock_homewizardenergy.device.side_effect = DisabledError
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"entry_id": mock_config_entry.entry_id,
|
||||
},
|
||||
)
|
||||
result = await mock_config_entry.start_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
@ -10,7 +10,7 @@ from homeassistant.components.honeywell.const import (
|
||||
CONF_HEAT_AWAY_TEMPERATURE,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER, ConfigEntryState
|
||||
from homeassistant.config_entries import SOURCE_USER, ConfigEntryState
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
@ -129,21 +129,7 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:
|
||||
unique_id="test-username",
|
||||
)
|
||||
mock_entry.add_to_hass(hass)
|
||||
with patch(
|
||||
"homeassistant.components.honeywell.async_setup_entry",
|
||||
return_value=True,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"unique_id": mock_entry.unique_id,
|
||||
"entry_id": mock_entry.entry_id,
|
||||
},
|
||||
data={CONF_USERNAME: "test-username", CONF_PASSWORD: "new-password"},
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
result = await mock_entry.start_reauth_flow(hass)
|
||||
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -177,16 +163,7 @@ async def test_reauth_flow_auth_error(hass: HomeAssistant, client: MagicMock) ->
|
||||
)
|
||||
mock_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"unique_id": mock_entry.unique_id,
|
||||
"entry_id": mock_entry.entry_id,
|
||||
},
|
||||
data={CONF_USERNAME: "test-username", CONF_PASSWORD: "new-password"},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
result = await mock_entry.start_reauth_flow(hass)
|
||||
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
@ -226,17 +203,7 @@ async def test_reauth_flow_connnection_error(
|
||||
unique_id="test-username",
|
||||
)
|
||||
mock_entry.add_to_hass(hass)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"unique_id": mock_entry.unique_id,
|
||||
"entry_id": mock_entry.entry_id,
|
||||
},
|
||||
data={CONF_USERNAME: "test-username", CONF_PASSWORD: "new-password"},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await mock_entry.start_reauth_flow(hass)
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
@ -385,15 +385,7 @@ async def test_reauth(
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
context = {
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"unique_id": entry.unique_id,
|
||||
"entry_id": entry.entry_id,
|
||||
}
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context=context, data=entry.data
|
||||
)
|
||||
|
||||
result = await entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["data_schema"] is not None
|
||||
|
@ -124,9 +124,9 @@ def add_test_config_entry(
|
||||
hass: HomeAssistant,
|
||||
data: dict[str, Any] | None = None,
|
||||
options: dict[str, Any] | None = None,
|
||||
) -> ConfigEntry:
|
||||
) -> MockConfigEntry:
|
||||
"""Add a test config entry."""
|
||||
config_entry: MockConfigEntry = MockConfigEntry(
|
||||
config_entry = MockConfigEntry(
|
||||
entry_id=TEST_CONFIG_ENTRY_ID,
|
||||
domain=DOMAIN,
|
||||
data=data
|
||||
|
@ -20,7 +20,7 @@ from homeassistant.components.hyperion.const import (
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_SSDP, SOURCE_USER
|
||||
from homeassistant.config_entries import SOURCE_SSDP, SOURCE_USER
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
CONF_HOST,
|
||||
@ -861,12 +861,7 @@ async def test_reauth_success(hass: HomeAssistant) -> None:
|
||||
),
|
||||
patch("homeassistant.components.hyperion.async_setup_entry", return_value=True),
|
||||
):
|
||||
result = await _init_flow(
|
||||
hass,
|
||||
source=SOURCE_REAUTH,
|
||||
data=config_data,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
result = await config_entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await _configure_flow(
|
||||
@ -886,18 +881,13 @@ async def test_reauth_cannot_connect(hass: HomeAssistant) -> None:
|
||||
CONF_PORT: TEST_PORT,
|
||||
}
|
||||
|
||||
add_test_config_entry(hass, data=config_data)
|
||||
config_entry = add_test_config_entry(hass, data=config_data)
|
||||
client = create_mock_client()
|
||||
client.async_client_connect = AsyncMock(return_value=False)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.hyperion.client.HyperionClient", return_value=client
|
||||
):
|
||||
result = await _init_flow(
|
||||
hass,
|
||||
source=SOURCE_REAUTH,
|
||||
data=config_data,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
result = await config_entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
@ -18,7 +18,7 @@ from homeassistant.components.icloud.const import (
|
||||
DEFAULT_WITH_FAMILY,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
@ -386,12 +386,7 @@ async def test_password_update(
|
||||
)
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_REAUTH, "unique_id": config_entry.unique_id},
|
||||
data={**MOCK_CONFIG},
|
||||
)
|
||||
|
||||
result = await config_entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@ -410,12 +405,7 @@ async def test_password_update_wrong_password(hass: HomeAssistant) -> None:
|
||||
)
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_REAUTH, "unique_id": config_entry.unique_id},
|
||||
data={**MOCK_CONFIG},
|
||||
)
|
||||
|
||||
result = await config_entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
with patch(
|
||||
|
@ -215,15 +215,7 @@ async def test_reauth_success(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_REAUTH,
|
||||
"entry_id": entry.entry_id,
|
||||
},
|
||||
data=MOCK_CONFIG,
|
||||
)
|
||||
|
||||
result = await entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["description_placeholders"] == {CONF_USERNAME: "email@email.com"}
|
||||
@ -256,15 +248,7 @@ async def test_reauth_failed(hass: HomeAssistant) -> None:
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"entry_id": entry.entry_id,
|
||||
},
|
||||
data=MOCK_CONFIG,
|
||||
)
|
||||
|
||||
result = await entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@ -294,15 +278,7 @@ async def test_reauth_failed_conn_error(hass: HomeAssistant) -> None:
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"entry_id": entry.entry_id,
|
||||
},
|
||||
data=MOCK_CONFIG,
|
||||
)
|
||||
|
||||
result = await entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
|
@ -6,7 +6,7 @@ from pyecotrend_ista import LoginError, ServerError
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.ista_ecotrend.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
@ -98,15 +98,7 @@ async def test_reauth(
|
||||
|
||||
ista_config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"entry_id": ista_config_entry.entry_id,
|
||||
"unique_id": ista_config_entry.unique_id,
|
||||
},
|
||||
)
|
||||
|
||||
result = await ista_config_entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@ -148,15 +140,7 @@ async def test_reauth_error_and_recover(
|
||||
|
||||
ista_config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"entry_id": ista_config_entry.entry_id,
|
||||
"unique_id": ista_config_entry.unique_id,
|
||||
},
|
||||
)
|
||||
|
||||
result = await ista_config_entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
|
@ -644,10 +644,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_REAUTH, "unique_id": MOCK_UUID},
|
||||
)
|
||||
result = await entry.start_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
@ -222,14 +222,7 @@ async def test_reauth(
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"entry_id": mock_config_entry.entry_id,
|
||||
},
|
||||
data=USER_INPUT,
|
||||
)
|
||||
result = await mock_config_entry.start_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
@ -272,14 +265,7 @@ async def test_reauth_cannot_connect(
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"entry_id": mock_config_entry.entry_id,
|
||||
},
|
||||
data=USER_INPUT,
|
||||
)
|
||||
result = await mock_config_entry.start_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
@ -339,14 +325,7 @@ async def test_reauth_invalid(
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"entry_id": mock_config_entry.entry_id,
|
||||
},
|
||||
data=USER_INPUT,
|
||||
)
|
||||
result = await mock_config_entry.start_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
@ -400,14 +379,7 @@ async def test_reauth_exception(
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"entry_id": mock_config_entry.entry_id,
|
||||
},
|
||||
data=USER_INPUT,
|
||||
)
|
||||
result = await mock_config_entry.start_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
@ -125,14 +125,7 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:
|
||||
)
|
||||
mock_config.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"entry_id": mock_config.entry_id,
|
||||
},
|
||||
data=FIXTURE_OLD_USER_INPUT,
|
||||
)
|
||||
result = await mock_config.start_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
@ -6,7 +6,7 @@ from jvcprojector import JvcProjectorAuthError, JvcProjectorConnectError
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.jvc_projector.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
@ -163,14 +163,7 @@ async def test_reauth_config_flow_success(
|
||||
hass: HomeAssistant, mock_device: AsyncMock, mock_integration: MockConfigEntry
|
||||
) -> None:
|
||||
"""Test reauth config flow success."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"entry_id": mock_integration.entry_id,
|
||||
},
|
||||
data={CONF_HOST: MOCK_HOST, CONF_PORT: MOCK_PORT},
|
||||
)
|
||||
result = await mock_integration.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@ -194,14 +187,7 @@ async def test_reauth_config_flow_auth_error(
|
||||
"""Test reauth config flow when connect fails."""
|
||||
mock_device.connect.side_effect = JvcProjectorAuthError
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"entry_id": mock_integration.entry_id,
|
||||
},
|
||||
data={CONF_HOST: MOCK_HOST, CONF_PORT: MOCK_PORT},
|
||||
)
|
||||
result = await mock_integration.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@ -218,14 +204,7 @@ async def test_reauth_config_flow_auth_error(
|
||||
|
||||
mock_device.connect.side_effect = None
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"entry_id": mock_integration.entry_id,
|
||||
},
|
||||
data={CONF_HOST: MOCK_HOST, CONF_PORT: MOCK_PORT},
|
||||
)
|
||||
result = await mock_integration.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@ -249,14 +228,7 @@ async def test_reauth_config_flow_connect_error(
|
||||
"""Test reauth config flow when connect fails."""
|
||||
mock_device.connect.side_effect = JvcProjectorConnectError
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"entry_id": mock_integration.entry_id,
|
||||
},
|
||||
data={CONF_HOST: MOCK_HOST, CONF_PORT: MOCK_PORT},
|
||||
)
|
||||
result = await mock_integration.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@ -273,14 +245,7 @@ async def test_reauth_config_flow_connect_error(
|
||||
|
||||
mock_device.connect.side_effect = None
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"entry_id": mock_integration.entry_id,
|
||||
},
|
||||
data={CONF_HOST: MOCK_HOST, CONF_PORT: MOCK_PORT},
|
||||
)
|
||||
result = await mock_integration.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
|
@ -251,16 +251,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||
)
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": config_entries.SOURCE_REAUTH,
|
||||
"entry_id": mock_config_entry.entry_id,
|
||||
"title_placeholders": {"name": mock_config_entry.title},
|
||||
"unique_id": mock_config_entry.unique_id,
|
||||
},
|
||||
data=data,
|
||||
)
|
||||
result = await mock_config_entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
|
@ -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_REAUTH,
|
||||
SOURCE_USER,
|
||||
ConfigEntryState,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_BLUETOOTH, SOURCE_USER, ConfigEntryState
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_MAC,
|
||||
@ -247,15 +242,7 @@ async def test_reauth_flow(
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"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_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
@ -20,12 +20,7 @@ from homeassistant.components.ssdp import (
|
||||
ATTR_UPNP_SERIAL,
|
||||
SsdpServiceInfo,
|
||||
)
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_DHCP,
|
||||
SOURCE_REAUTH,
|
||||
SOURCE_SSDP,
|
||||
SOURCE_USER,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_DHCP, SOURCE_SSDP, SOURCE_USER
|
||||
from homeassistant.const import CONF_API_KEY, CONF_DEVICE, CONF_HOST, CONF_MAC
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
@ -753,15 +748,7 @@ async def test_reauth_cloud_import(
|
||||
"""Test reauth flow importing api keys from the cloud."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"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_reauth_flow(hass)
|
||||
|
||||
flow_id = result["flow_id"]
|
||||
|
||||
@ -817,15 +804,7 @@ async def test_reauth_cloud_abort_device_not_found(
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
hass.config_entries.async_update_entry(mock_config_entry, unique_id="UKNOWN_DEVICE")
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"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_reauth_flow(hass)
|
||||
|
||||
flow_id = result["flow_id"]
|
||||
|
||||
@ -872,15 +851,7 @@ async def test_reauth_manual(
|
||||
"""Test reauth flow with manual entry."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"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_reauth_flow(hass)
|
||||
|
||||
flow_id = result["flow_id"]
|
||||
|
||||
@ -914,15 +885,7 @@ async def test_reauth_manual_sky(
|
||||
"""Test reauth flow with manual entry for LaMetric Sky."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"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_reauth_flow(hass)
|
||||
|
||||
flow_id = result["flow_id"]
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
from laundrify_aio import exceptions
|
||||
|
||||
from homeassistant.components.laundrify.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_CODE, CONF_SOURCE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
@ -95,9 +95,8 @@ async def test_form_unkown_exception(
|
||||
|
||||
async def test_step_reauth(hass: HomeAssistant) -> None:
|
||||
"""Test the reauth form is shown."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_REAUTH}
|
||||
)
|
||||
config_entry = create_entry(hass)
|
||||
result = await config_entry.start_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
@ -1,13 +1,15 @@
|
||||
"""Test Lidarr config flow."""
|
||||
|
||||
from homeassistant.components.lidarr.const import DEFAULT_NAME, DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import CONF_API_KEY, CONF_SOURCE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from .conftest import CONF_DATA, MOCK_INPUT, ComponentSetup
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_flow_user_form(hass: HomeAssistant, connection) -> None:
|
||||
"""Test that the user set up form is served."""
|
||||
@ -95,20 +97,14 @@ async def test_flow_user_unknown_error(hass: HomeAssistant, unknown) -> None:
|
||||
|
||||
|
||||
async def test_flow_reauth(
|
||||
hass: HomeAssistant, setup_integration: ComponentSetup, connection
|
||||
hass: HomeAssistant,
|
||||
setup_integration: ComponentSetup,
|
||||
connection,
|
||||
config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test reauth."""
|
||||
await setup_integration()
|
||||
entry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
CONF_SOURCE: SOURCE_REAUTH,
|
||||
"entry_id": entry.entry_id,
|
||||
"unique_id": entry.unique_id,
|
||||
},
|
||||
data=CONF_DATA,
|
||||
)
|
||||
result = await config_entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@ -123,4 +119,4 @@ async def test_flow_reauth(
|
||||
)
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
assert entry.data[CONF_API_KEY] == "abc123"
|
||||
assert config_entry.data[CONF_API_KEY] == "abc123"
|
||||
|
@ -6,7 +6,7 @@ from linear_garage_door.errors import InvalidLoginError
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.linear_garage_door.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
@ -61,16 +61,7 @@ async def test_reauth(
|
||||
) -> None:
|
||||
"""Test reauthentication."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
"source": SOURCE_REAUTH,
|
||||
"entry_id": mock_config_entry.entry_id,
|
||||
"title_placeholders": {"name": mock_config_entry.title},
|
||||
"unique_id": mock_config_entry.unique_id,
|
||||
},
|
||||
data=mock_config_entry.data,
|
||||
)
|
||||
result = await mock_config_entry.start_reauth_flow(hass)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
|
@ -7,7 +7,7 @@ from pylitterbot.exceptions import LitterRobotException, LitterRobotLoginExcepti
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import litterrobot
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_SOURCE
|
||||
from homeassistant.const import CONF_PASSWORD
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
@ -124,15 +124,7 @@ async def test_step_reauth(hass: HomeAssistant, mock_account: Account) -> None:
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
CONF_SOURCE: config_entries.SOURCE_REAUTH,
|
||||
"entry_id": entry.entry_id,
|
||||
"unique_id": entry.unique_id,
|
||||
},
|
||||
data=entry.data,
|
||||
)
|
||||
result = await entry.start_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
@ -164,15 +156,7 @@ async def test_step_reauth_failed(hass: HomeAssistant, mock_account: Account) ->
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={
|
||||
CONF_SOURCE: config_entries.SOURCE_REAUTH,
|
||||
"entry_id": entry.entry_id,
|
||||
"unique_id": entry.unique_id,
|
||||
},
|
||||
data=entry.data,
|
||||
)
|
||||
result = await entry.start_reauth_flow(hass)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
@ -126,9 +126,7 @@ async def test_reauthentication_flow(
|
||||
)
|
||||
old_entry.add_to_hass(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=old_entry.data
|
||||
)
|
||||
result = await old_entry.start_reauth_flow(hass)
|
||||
|
||||
flows = hass.config_entries.flow.async_progress()
|
||||
assert len(flows) == 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user