mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use start_reauth helper method in integration tests (m-o) (#124790)
This commit is contained in:
parent
731aaaafe2
commit
57a73d1b1b
@ -6,7 +6,7 @@ from aiomealie import About, MealieAuthenticationError, MealieConnectionError
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.mealie.const import DOMAIN
|
from homeassistant.components.mealie.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_RECONFIGURE, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_RECONFIGURE, SOURCE_USER
|
||||||
from homeassistant.const import CONF_API_TOKEN, CONF_HOST, CONF_VERIFY_SSL
|
from homeassistant.const import CONF_API_TOKEN, CONF_HOST, CONF_VERIFY_SSL
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
@ -152,11 +152,7 @@ async def test_reauth_flow(
|
|||||||
"""Test reauth flow."""
|
"""Test reauth flow."""
|
||||||
await setup_integration(hass, mock_config_entry)
|
await setup_integration(hass, mock_config_entry)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH, "entry_id": mock_config_entry.entry_id},
|
|
||||||
data=mock_config_entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
@ -179,11 +175,7 @@ async def test_reauth_flow_wrong_account(
|
|||||||
"""Test reauth flow with wrong account."""
|
"""Test reauth flow with wrong account."""
|
||||||
await setup_integration(hass, mock_config_entry)
|
await setup_integration(hass, mock_config_entry)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH, "entry_id": mock_config_entry.entry_id},
|
|
||||||
data=mock_config_entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
@ -218,11 +210,7 @@ async def test_reauth_flow_exceptions(
|
|||||||
await setup_integration(hass, mock_config_entry)
|
await setup_integration(hass, mock_config_entry)
|
||||||
mock_mealie_client.get_user_info.side_effect = exception
|
mock_mealie_client.get_user_info.side_effect = exception
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH, "entry_id": mock_config_entry.entry_id},
|
|
||||||
data=mock_config_entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -123,11 +123,7 @@ async def test_reauth_flow(hass: HomeAssistant, mock_meater) -> None:
|
|||||||
)
|
)
|
||||||
mock_config.add_to_hass(hass)
|
mock_config.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"source": config_entries.SOURCE_REAUTH},
|
|
||||||
data=data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
@ -9,7 +9,7 @@ import pytest
|
|||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.melcloud.const import DOMAIN
|
from homeassistant.components.melcloud.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_RECONFIGURE
|
from homeassistant.config_entries import SOURCE_RECONFIGURE
|
||||||
from homeassistant.const import CONF_PASSWORD
|
from homeassistant.const import CONF_PASSWORD
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
@ -166,15 +166,7 @@ async def test_token_reauthentication(
|
|||||||
)
|
)
|
||||||
mock_entry.add_to_hass(hass)
|
mock_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_entry.unique_id,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
@ -212,15 +204,7 @@ async def test_form_errors_reauthentication(
|
|||||||
)
|
)
|
||||||
mock_entry.add_to_hass(hass)
|
mock_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_entry.unique_id,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.melcloud.async_setup_entry",
|
"homeassistant.components.melcloud.async_setup_entry",
|
||||||
@ -270,15 +254,7 @@ async def test_client_errors_reauthentication(
|
|||||||
)
|
)
|
||||||
mock_entry.add_to_hass(hass)
|
mock_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_entry.unique_id,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.melcloud.async_setup_entry",
|
"homeassistant.components.melcloud.async_setup_entry",
|
||||||
|
@ -6,7 +6,7 @@ from microBeesPy import MicroBeesException
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.microbees.const import DOMAIN
|
from homeassistant.components.microbees.const import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
@ -144,14 +144,7 @@ async def test_config_reauth_profile(
|
|||||||
"""Test reauth an existing profile reauthenticates the config entry."""
|
"""Test reauth an existing profile reauthenticates the config entry."""
|
||||||
await setup_integration(hass, config_entry)
|
await setup_integration(hass, config_entry)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"entry_id": config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=config_entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
@ -205,14 +198,7 @@ async def test_config_reauth_wrong_account(
|
|||||||
"""Test reauth with wrong account."""
|
"""Test reauth with wrong account."""
|
||||||
await setup_integration(hass, config_entry)
|
await setup_integration(hass, config_entry)
|
||||||
microbees.return_value.getMyProfile.return_value.id = 12345
|
microbees.return_value.getMyProfile.return_value.id = 12345
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"entry_id": config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=config_entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -175,14 +175,7 @@ async def test_reauth_success(hass: HomeAssistant, api) -> None:
|
|||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
data=DEMO_USER_INPUT,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
@ -207,14 +200,7 @@ async def test_reauth_failed(hass: HomeAssistant, auth_error) -> None:
|
|||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
data=DEMO_USER_INPUT,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
@ -240,14 +226,7 @@ async def test_reauth_failed_conn_error(hass: HomeAssistant, conn_error) -> None
|
|||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
data=DEMO_USER_INPUT,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
@ -154,14 +154,7 @@ async def test_config_reauth_profile(
|
|||||||
"""Test reauth an existing profile reauthenticates the config entry."""
|
"""Test reauth an existing profile reauthenticates the config entry."""
|
||||||
await setup_integration(hass, polling_config_entry)
|
await setup_integration(hass, polling_config_entry)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await polling_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"entry_id": polling_config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=polling_config_entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
@ -223,14 +216,7 @@ async def test_config_reauth_wrong_account(
|
|||||||
"""Test reauth with wrong account."""
|
"""Test reauth with wrong account."""
|
||||||
await setup_integration(hass, polling_config_entry)
|
await setup_integration(hass, polling_config_entry)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await polling_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"entry_id": polling_config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=polling_config_entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -264,14 +264,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
config_entry = create_mock_motioneye_config_entry(hass, data=config_data)
|
config_entry = create_mock_motioneye_config_entry(hass, data=config_data)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=config_entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
|
@ -1551,14 +1551,7 @@ async def test_step_reauth(
|
|||||||
assert result["context"]["source"] == "reauth"
|
assert result["context"]["source"] == "reauth"
|
||||||
|
|
||||||
# Show the form
|
# Show the form
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await config_entry.start_reauth_flow(hass)
|
||||||
mqtt.DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=config_entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -105,14 +105,7 @@ async def test_flow_reauth(
|
|||||||
|
|
||||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": mock_config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_config_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import pytest
|
|||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.components.nam.const import DOMAIN
|
from homeassistant.components.nam.const import DOMAIN
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
SOURCE_REAUTH,
|
|
||||||
SOURCE_RECONFIGURE,
|
SOURCE_RECONFIGURE,
|
||||||
SOURCE_USER,
|
SOURCE_USER,
|
||||||
SOURCE_ZEROCONF,
|
SOURCE_ZEROCONF,
|
||||||
@ -122,6 +121,9 @@ async def test_reauth_successful(hass: HomeAssistant) -> None:
|
|||||||
data={"host": "10.10.2.3"},
|
data={"host": "10.10.2.3"},
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
result = await entry.start_reauth_flow(hass)
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
@ -133,15 +135,6 @@ async def test_reauth_successful(hass: HomeAssistant) -> None:
|
|||||||
return_value="aa:bb:cc:dd:ee:ff",
|
return_value="aa:bb:cc:dd:ee:ff",
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH, "entry_id": entry.entry_id},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
|
||||||
assert result["step_id"] == "reauth_confirm"
|
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=VALID_AUTH,
|
user_input=VALID_AUTH,
|
||||||
@ -160,20 +153,14 @@ async def test_reauth_unsuccessful(hass: HomeAssistant) -> None:
|
|||||||
data={"host": "10.10.2.3"},
|
data={"host": "10.10.2.3"},
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
result = await entry.start_reauth_flow(hass)
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.nam.NettigoAirMonitor.async_check_credentials",
|
"homeassistant.components.nam.NettigoAirMonitor.async_check_credentials",
|
||||||
side_effect=ApiError("API Error"),
|
side_effect=ApiError("API Error"),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH, "entry_id": entry.entry_id},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
|
||||||
assert result["step_id"] == "reauth_confirm"
|
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input=VALID_AUTH,
|
user_input=VALID_AUTH,
|
||||||
|
@ -297,15 +297,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
|||||||
return_value=True,
|
return_value=True,
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "link"
|
assert result["step_id"] == "link"
|
||||||
|
|
||||||
|
@ -111,16 +111,15 @@ async def test_reauth(
|
|||||||
hass, NEATO_DOMAIN, ClientCredential(CLIENT_ID, CLIENT_SECRET)
|
hass, NEATO_DOMAIN, ClientCredential(CLIENT_ID, CLIENT_SECRET)
|
||||||
)
|
)
|
||||||
|
|
||||||
MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
entry_id="my_entry",
|
entry_id="my_entry",
|
||||||
domain=NEATO_DOMAIN,
|
domain=NEATO_DOMAIN,
|
||||||
data={"username": "abcdef", "password": "123456", "vendor": "neato"},
|
data={"username": "abcdef", "password": "123456", "vendor": "neato"},
|
||||||
).add_to_hass(hass)
|
)
|
||||||
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
# Should show form
|
# Should show form
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
"neato", context={"source": config_entries.SOURCE_REAUTH}
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import pytest
|
|||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.nextcloud.const import DOMAIN
|
from homeassistant.components.nextcloud.const import 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.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
@ -135,11 +135,7 @@ async def test_reauth(hass: HomeAssistant, snapshot: SnapshotAssertion) -> None:
|
|||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
# start reauth flow
|
# start reauth flow
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH, "entry_id": entry.entry_id},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -6,13 +6,15 @@ from aionotion.errors import InvalidCredentialsError, NotionError
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.notion import CONF_REFRESH_TOKEN, CONF_USER_UUID, DOMAIN
|
from homeassistant.components.notion import CONF_REFRESH_TOKEN, CONF_USER_UUID, 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.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
from .conftest import TEST_PASSWORD, TEST_REFRESH_TOKEN, TEST_USER_UUID, TEST_USERNAME
|
from .conftest import TEST_PASSWORD, TEST_REFRESH_TOKEN, TEST_USER_UUID, TEST_USERNAME
|
||||||
|
|
||||||
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||||
|
|
||||||
|
|
||||||
@ -90,21 +92,13 @@ async def test_duplicate_error(hass: HomeAssistant, config, config_entry) -> Non
|
|||||||
async def test_reauth(
|
async def test_reauth(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config,
|
config,
|
||||||
config_entry,
|
config_entry: MockConfigEntry,
|
||||||
errors,
|
errors,
|
||||||
get_client_with_exception,
|
get_client_with_exception,
|
||||||
mock_aionotion,
|
mock_aionotion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that re-auth works."""
|
"""Test that re-auth works."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"entry_id": config_entry.entry_id,
|
|
||||||
"unique_id": config_entry.unique_id,
|
|
||||||
},
|
|
||||||
data=config,
|
|
||||||
)
|
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
# Test errors that can arise when getting a Notion API client:
|
# Test errors that can arise when getting a Notion API client:
|
||||||
|
@ -210,9 +210,7 @@ async def test_reauth_success(hass: HomeAssistant) -> None:
|
|||||||
"""Test starting a reauthentication flow."""
|
"""Test starting a reauthentication flow."""
|
||||||
entry = await setup_nuki_integration(hass)
|
entry = await setup_nuki_integration(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
@ -241,9 +239,7 @@ async def test_reauth_invalid_auth(hass: HomeAssistant) -> None:
|
|||||||
"""Test starting a reauthentication flow with invalid auth."""
|
"""Test starting a reauthentication flow with invalid auth."""
|
||||||
entry = await setup_nuki_integration(hass)
|
entry = await setup_nuki_integration(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
@ -265,9 +261,7 @@ async def test_reauth_cannot_connect(hass: HomeAssistant) -> None:
|
|||||||
"""Test starting a reauthentication flow with cannot connect."""
|
"""Test starting a reauthentication flow with cannot connect."""
|
||||||
entry = await setup_nuki_integration(hass)
|
entry = await setup_nuki_integration(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
@ -289,9 +283,7 @@ async def test_reauth_unknown_exception(hass: HomeAssistant) -> None:
|
|||||||
"""Test starting a reauthentication flow with an unknown exception."""
|
"""Test starting a reauthentication flow with an unknown exception."""
|
||||||
entry = await setup_nuki_integration(hass)
|
entry = await setup_nuki_integration(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -580,15 +580,7 @@ async def test_reauth_form(hass: HomeAssistant) -> None:
|
|||||||
unique_id="1234",
|
unique_id="1234",
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
||||||
|
@ -769,11 +769,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
|
|||||||
"""Test reauthenticate."""
|
"""Test reauthenticate."""
|
||||||
entry, _, _ = await setup_onvif_integration(hass)
|
entry, _, _ = await setup_onvif_integration(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"source": config_entries.SOURCE_REAUTH, "entry_id": entry.entry_id},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
assert (
|
assert (
|
||||||
|
@ -200,16 +200,7 @@ async def test_reauth(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Test we can reauthenticate the config entry."""
|
"""Test we can reauthenticate the config entry."""
|
||||||
mock_config_entry.add_to_hass(hass)
|
mock_config_entry.add_to_hass(hass)
|
||||||
flow_context = {
|
result = await mock_config_entry.start_reauth_flow(hass)
|
||||||
"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,
|
|
||||||
}
|
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN, context=flow_context, data=mock_config_entry.data
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] is None
|
assert result["errors"] is None
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import pytest
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.openuv import CONF_FROM_WINDOW, CONF_TO_WINDOW, DOMAIN
|
from homeassistant.components.openuv import CONF_FROM_WINDOW, CONF_TO_WINDOW, DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_API_KEY,
|
CONF_API_KEY,
|
||||||
CONF_ELEVATION,
|
CONF_ELEVATION,
|
||||||
@ -19,6 +19,8 @@ from homeassistant.data_entry_flow import FlowResultType
|
|||||||
|
|
||||||
from .conftest import TEST_API_KEY, TEST_ELEVATION, TEST_LATITUDE, TEST_LONGITUDE
|
from .conftest import TEST_API_KEY, TEST_ELEVATION, TEST_LATITUDE, TEST_LONGITUDE
|
||||||
|
|
||||||
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||||
|
|
||||||
|
|
||||||
@ -105,12 +107,10 @@ async def test_options_flow(
|
|||||||
|
|
||||||
|
|
||||||
async def test_step_reauth(
|
async def test_step_reauth(
|
||||||
hass: HomeAssistant, config, config_entry, setup_config_entry
|
hass: HomeAssistant, config, config_entry: MockConfigEntry, setup_config_entry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that the reauth step works."""
|
"""Test that the reauth step works."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN, context={"source": SOURCE_REAUTH}, data=config
|
|
||||||
)
|
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||||
|
@ -65,15 +65,7 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:
|
|||||||
"homeassistant.components.osoenergy.config_flow.OSOEnergy.get_user_email",
|
"homeassistant.components.osoenergy.config_flow.OSOEnergy.get_user_email",
|
||||||
return_value=None,
|
return_value=None,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_config.unique_id,
|
|
||||||
"entry_id": mock_config.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_config.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {"base": "invalid_auth"}
|
assert result["errors"] == {"base": "invalid_auth"}
|
||||||
|
@ -573,15 +573,7 @@ async def test_cloud_reauth_success(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
mock_entry.add_to_hass(hass)
|
mock_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_entry.unique_id,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "cloud"
|
assert result["step_id"] == "cloud"
|
||||||
@ -623,15 +615,7 @@ async def test_cloud_reauth_wrong_account(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
mock_entry.add_to_hass(hass)
|
mock_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_entry.unique_id,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "cloud"
|
assert result["step_id"] == "cloud"
|
||||||
@ -672,15 +656,7 @@ async def test_local_reauth_success(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
mock_entry.add_to_hass(hass)
|
mock_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_entry.unique_id,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "local_or_cloud"
|
assert result["step_id"] == "local_or_cloud"
|
||||||
@ -731,15 +707,7 @@ async def test_local_reauth_wrong_account(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
mock_entry.add_to_hass(hass)
|
mock_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_entry.unique_id,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_entry.data,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "local_or_cloud"
|
assert result["step_id"] == "local_or_cloud"
|
||||||
|
|
||||||
|
@ -121,15 +121,15 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
async def test_reauth_authorization_error(hass: HomeAssistant) -> None:
|
async def test_reauth_authorization_error(hass: HomeAssistant) -> None:
|
||||||
"""Test we show user form on authorization error."""
|
"""Test we show user form on authorization error."""
|
||||||
|
mock_config = MockConfigEntry(
|
||||||
|
domain=DOMAIN, unique_id=UNIQUE_ID, data=FIXTURE_USER_INPUT
|
||||||
|
)
|
||||||
|
mock_config.add_to_hass(hass)
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.ovo_energy.config_flow.OVOEnergy.authenticate",
|
"homeassistant.components.ovo_energy.config_flow.OVOEnergy.authenticate",
|
||||||
return_value=False,
|
return_value=False,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"source": config_entries.SOURCE_REAUTH},
|
|
||||||
data=FIXTURE_USER_INPUT,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth"
|
assert result["step_id"] == "reauth"
|
||||||
@ -147,15 +147,15 @@ async def test_reauth_authorization_error(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
async def test_reauth_connection_error(hass: HomeAssistant) -> None:
|
async def test_reauth_connection_error(hass: HomeAssistant) -> None:
|
||||||
"""Test we show user form on connection error."""
|
"""Test we show user form on connection error."""
|
||||||
|
mock_config = MockConfigEntry(
|
||||||
|
domain=DOMAIN, unique_id=UNIQUE_ID, data=FIXTURE_USER_INPUT
|
||||||
|
)
|
||||||
|
mock_config.add_to_hass(hass)
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.ovo_energy.config_flow.OVOEnergy.authenticate",
|
"homeassistant.components.ovo_energy.config_flow.OVOEnergy.authenticate",
|
||||||
side_effect=aiohttp.ClientError,
|
side_effect=aiohttp.ClientError,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={"source": config_entries.SOURCE_REAUTH},
|
|
||||||
data=FIXTURE_USER_INPUT,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth"
|
assert result["step_id"] == "reauth"
|
||||||
@ -173,20 +173,15 @@ async def test_reauth_connection_error(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
async def test_reauth_flow(hass: HomeAssistant) -> None:
|
async def test_reauth_flow(hass: HomeAssistant) -> None:
|
||||||
"""Test reauth works."""
|
"""Test reauth works."""
|
||||||
with patch(
|
|
||||||
"homeassistant.components.ovo_energy.config_flow.OVOEnergy.authenticate",
|
|
||||||
return_value=False,
|
|
||||||
):
|
|
||||||
mock_config = MockConfigEntry(
|
mock_config = MockConfigEntry(
|
||||||
domain=DOMAIN, unique_id=UNIQUE_ID, data=FIXTURE_USER_INPUT
|
domain=DOMAIN, unique_id=UNIQUE_ID, data=FIXTURE_USER_INPUT
|
||||||
)
|
)
|
||||||
mock_config.add_to_hass(hass)
|
mock_config.add_to_hass(hass)
|
||||||
|
with patch(
|
||||||
result = await hass.config_entries.flow.async_init(
|
"homeassistant.components.ovo_energy.config_flow.OVOEnergy.authenticate",
|
||||||
DOMAIN,
|
return_value=False,
|
||||||
context={"source": config_entries.SOURCE_REAUTH},
|
):
|
||||||
data=FIXTURE_USER_INPUT,
|
result = await mock_config.start_reauth_flow(hass)
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth"
|
assert result["step_id"] == "reauth"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user