mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use start_reauth helper method in config flow tests (a-d) (#124780)
* Use start_reauth helper method in integration tests (a-d) * Revert broadlink * Revert bthome
This commit is contained in:
parent
99335a07e5
commit
bdd3aa8e39
@ -133,13 +133,7 @@ async def test_async_step_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,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
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,13 +173,7 @@ async def test_async_step_reauth_exception(
|
|||||||
)
|
)
|
||||||
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,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.aseko_pool_live.config_flow.WebAccount.login",
|
"homeassistant.components.aseko_pool_live.config_flow.WebAccount.login",
|
||||||
|
@ -173,14 +173,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
|||||||
mock_entry.add_to_hass(hass)
|
mock_entry.add_to_hass(hass)
|
||||||
|
|
||||||
# Test failed reauth
|
# Test failed reauth
|
||||||
result5 = await hass.config_entries.flow.async_init(
|
result5 = await mock_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=FAKE_DATA,
|
|
||||||
)
|
|
||||||
assert result5["step_id"] == "reauth_confirm"
|
assert result5["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
|
@ -10,6 +10,8 @@ from homeassistant.components.blink import DOMAIN
|
|||||||
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 tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
async def test_form(hass: HomeAssistant) -> None:
|
async def test_form(hass: HomeAssistant) -> None:
|
||||||
"""Test we get the form."""
|
"""Test we get the form."""
|
||||||
@ -292,10 +294,11 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
async def test_reauth_shows_user_step(hass: HomeAssistant) -> None:
|
async def test_reauth_shows_user_step(hass: HomeAssistant) -> None:
|
||||||
"""Test reauth shows the user form."""
|
"""Test reauth shows the user form."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
mock_entry = MockConfigEntry(
|
||||||
DOMAIN,
|
domain=DOMAIN,
|
||||||
context={"source": config_entries.SOURCE_REAUTH},
|
|
||||||
data={"username": "blink@example.com", "password": "invalid_password"},
|
data={"username": "blink@example.com", "password": "invalid_password"},
|
||||||
)
|
)
|
||||||
|
mock_entry.add_to_hass(hass)
|
||||||
|
result = await mock_entry.start_reauth_flow(hass)
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
@ -129,6 +129,11 @@ async def test_reauth(
|
|||||||
expected_api_token: str,
|
expected_api_token: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test reauth flow."""
|
"""Test reauth flow."""
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
result = await config_entry.start_reauth_flow(hass)
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
"homeassistant.components.blue_current.config_flow.Client.validate_api_token",
|
"homeassistant.components.blue_current.config_flow.Client.validate_api_token",
|
||||||
@ -146,20 +151,6 @@ async def test_reauth(
|
|||||||
lambda self, on_data, on_open: hass.loop.create_future(),
|
lambda self, on_data, on_open: hass.loop.create_future(),
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
config_entry.add_to_hass(hass)
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": config_entry.entry_id,
|
|
||||||
"unique_id": config_entry.unique_id,
|
|
||||||
},
|
|
||||||
data={"api_token": "123"},
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
|
||||||
assert result["step_id"] == "user"
|
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={"api_token": "1234567890"},
|
user_input={"api_token": "1234567890"},
|
||||||
|
@ -188,15 +188,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
assert config_entry.data == config_entry_with_wrong_password["data"]
|
assert config_entry.data == config_entry_with_wrong_password["data"]
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": config_entry.unique_id,
|
|
||||||
"entry_id": config_entry.entry_id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
@ -646,11 +646,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
|||||||
title="shc012345",
|
title="shc012345",
|
||||||
)
|
)
|
||||||
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=mock_config.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"
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ from homeassistant.components.braviatv.const import (
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
NICKNAME_PREFIX,
|
NICKNAME_PREFIX,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_SSDP, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_SSDP, SOURCE_USER
|
||||||
from homeassistant.const import CONF_CLIENT_ID, CONF_HOST, CONF_MAC, CONF_PIN
|
from homeassistant.const import CONF_CLIENT_ID, CONF_HOST, CONF_MAC, CONF_PIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
@ -405,6 +405,9 @@ async def test_reauth_successful(hass: HomeAssistant, use_psk, new_pin) -> None:
|
|||||||
title="TV-Model",
|
title="TV-Model",
|
||||||
)
|
)
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
result = await config_entry.start_reauth_flow(hass)
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "authorize"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch("pybravia.BraviaClient.connect"),
|
patch("pybravia.BraviaClient.connect"),
|
||||||
@ -421,15 +424,6 @@ async def test_reauth_successful(hass: HomeAssistant, use_psk, new_pin) -> None:
|
|||||||
return_value={},
|
return_value={},
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH, "entry_id": config_entry.entry_id},
|
|
||||||
data=config_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
|
||||||
assert result["step_id"] == "authorize"
|
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], user_input={CONF_USE_PSK: use_psk}
|
result["flow_id"], user_input={CONF_USE_PSK: use_psk}
|
||||||
)
|
)
|
||||||
|
@ -10,7 +10,7 @@ from bring_api.exceptions import (
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.bring.const import DOMAIN
|
from homeassistant.components.bring.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.const import CONF_EMAIL, 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
|
||||||
@ -123,15 +123,7 @@ async def test_flow_reauth(
|
|||||||
|
|
||||||
bring_config_entry.add_to_hass(hass)
|
bring_config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await bring_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"entry_id": bring_config_entry.entry_id,
|
|
||||||
"unique_id": bring_config_entry.unique_id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
@ -171,15 +163,7 @@ async def test_flow_reauth_error_and_recover(
|
|||||||
|
|
||||||
bring_config_entry.add_to_hass(hass)
|
bring_config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await bring_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"entry_id": bring_config_entry.entry_id,
|
|
||||||
"unique_id": bring_config_entry.unique_id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -110,15 +110,7 @@ async def test_reauth(
|
|||||||
unique_id="test-username",
|
unique_id="test-username",
|
||||||
)
|
)
|
||||||
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,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
data=None,
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -106,13 +106,7 @@ async def test_reauth_success(
|
|||||||
|
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
@ -147,13 +141,7 @@ async def test_reauth_failure(
|
|||||||
|
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from unittest.mock import MagicMock
|
|||||||
import pycfdns
|
import pycfdns
|
||||||
|
|
||||||
from homeassistant.components.cloudflare.const import CONF_RECORDS, DOMAIN
|
from homeassistant.components.cloudflare.const import CONF_RECORDS, DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.const import CONF_API_TOKEN, CONF_SOURCE, CONF_ZONE
|
from homeassistant.const import CONF_API_TOKEN, CONF_SOURCE, CONF_ZONE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
@ -151,15 +151,7 @@ async def test_reauth_flow(hass: HomeAssistant, cfupdate_flow: MagicMock) -> Non
|
|||||||
entry = MockConfigEntry(domain=DOMAIN, data=ENTRY_CONFIG)
|
entry = MockConfigEntry(domain=DOMAIN, data=ENTRY_CONFIG)
|
||||||
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": SOURCE_REAUTH,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
"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"
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ from aiocomelit import CannotAuthenticate, CannotConnect
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.comelit.const import DOMAIN
|
from homeassistant.components.comelit.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_PIN, CONF_PORT
|
from homeassistant.const import CONF_HOST, CONF_PIN, CONF_PORT
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
@ -100,6 +100,9 @@ async def test_reauth_successful(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
mock_config = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_BRIDGE_DATA)
|
mock_config = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_BRIDGE_DATA)
|
||||||
mock_config.add_to_hass(hass)
|
mock_config.add_to_hass(hass)
|
||||||
|
result = await mock_config.start_reauth_flow(hass)
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
@ -113,15 +116,6 @@ async def test_reauth_successful(hass: HomeAssistant) -> None:
|
|||||||
):
|
):
|
||||||
mock_request_get.return_value.status_code = 200
|
mock_request_get.return_value.status_code = 200
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH, "entry_id": mock_config.entry_id},
|
|
||||||
data=mock_config.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={
|
user_input={
|
||||||
@ -147,6 +141,9 @@ async def test_reauth_not_successful(hass: HomeAssistant, side_effect, error) ->
|
|||||||
|
|
||||||
mock_config = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_BRIDGE_DATA)
|
mock_config = MockConfigEntry(domain=DOMAIN, data=MOCK_USER_BRIDGE_DATA)
|
||||||
mock_config.add_to_hass(hass)
|
mock_config.add_to_hass(hass)
|
||||||
|
result = await mock_config.start_reauth_flow(hass)
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch("aiocomelit.api.ComeliteSerialBridgeApi.login", side_effect=side_effect),
|
patch("aiocomelit.api.ComeliteSerialBridgeApi.login", side_effect=side_effect),
|
||||||
@ -155,15 +152,6 @@ async def test_reauth_not_successful(hass: HomeAssistant, side_effect, error) ->
|
|||||||
),
|
),
|
||||||
patch("homeassistant.components.comelit.async_setup_entry"),
|
patch("homeassistant.components.comelit.async_setup_entry"),
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_REAUTH, "entry_id": mock_config.entry_id},
|
|
||||||
data=mock_config.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={
|
user_input={
|
||||||
|
@ -22,12 +22,7 @@ from homeassistant.components.deconz.const import (
|
|||||||
)
|
)
|
||||||
from homeassistant.components.hassio import HassioServiceInfo
|
from homeassistant.components.hassio import HassioServiceInfo
|
||||||
from homeassistant.components.ssdp import ATTR_UPNP_MANUFACTURER_URL, ATTR_UPNP_SERIAL
|
from homeassistant.components.ssdp import ATTR_UPNP_MANUFACTURER_URL, ATTR_UPNP_SERIAL
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import SOURCE_HASSIO, SOURCE_SSDP, SOURCE_USER
|
||||||
SOURCE_HASSIO,
|
|
||||||
SOURCE_REAUTH,
|
|
||||||
SOURCE_SSDP,
|
|
||||||
SOURCE_USER,
|
|
||||||
)
|
|
||||||
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT, CONTENT_TYPE_JSON
|
from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT, CONTENT_TYPE_JSON
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
@ -407,12 +402,7 @@ async def test_reauth_flow_update_configuration(
|
|||||||
config_entry_setup: MockConfigEntry,
|
config_entry_setup: MockConfigEntry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Verify reauth flow can update gateway API key."""
|
"""Verify reauth flow can update gateway API key."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await config_entry_setup.start_reauth_flow(hass)
|
||||||
DECONZ_DOMAIN,
|
|
||||||
data=config_entry_setup.data,
|
|
||||||
context={"source": SOURCE_REAUTH},
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "link"
|
assert result["step_id"] == "link"
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.deluge.const import DEFAULT_NAME, DOMAIN
|
from homeassistant.components.deluge.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_SOURCE
|
from homeassistant.const import CONF_SOURCE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
@ -113,16 +113,7 @@ async def test_flow_reauth(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={
|
|
||||||
CONF_SOURCE: SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
},
|
|
||||||
data=CONF_DATA,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "user"
|
assert result["step_id"] == "user"
|
||||||
|
|
||||||
|
@ -164,21 +164,17 @@ async def test_zeroconf_wrong_device(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
async def test_form_reauth(hass: HomeAssistant) -> None:
|
async def test_form_reauth(hass: HomeAssistant) -> None:
|
||||||
"""Test that the reauth confirmation form is served."""
|
"""Test that the reauth confirmation form is served."""
|
||||||
mock_config = MockConfigEntry(domain=DOMAIN, unique_id="123456", data={})
|
mock_config = MockConfigEntry(
|
||||||
mock_config.add_to_hass(hass)
|
domain=DOMAIN,
|
||||||
result = await hass.config_entries.flow.async_init(
|
unique_id="123456",
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": mock_config.entry_id,
|
|
||||||
},
|
|
||||||
data={
|
data={
|
||||||
"username": "test-username",
|
"username": "test-username",
|
||||||
"password": "test-password",
|
"password": "test-password",
|
||||||
"mydevolo_url": "https://test_mydevolo_url.test",
|
"mydevolo_url": "https://test_mydevolo_url.test",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
mock_config.add_to_hass(hass)
|
||||||
|
result = await mock_config.start_reauth_flow(hass)
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
@ -205,20 +201,17 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
|
|||||||
@pytest.mark.parametrize("credentials_valid", [False])
|
@pytest.mark.parametrize("credentials_valid", [False])
|
||||||
async def test_form_invalid_credentials_reauth(hass: HomeAssistant) -> None:
|
async def test_form_invalid_credentials_reauth(hass: HomeAssistant) -> None:
|
||||||
"""Test if we get the error message on invalid credentials."""
|
"""Test if we get the error message on invalid credentials."""
|
||||||
mock_config = MockConfigEntry(domain=DOMAIN, unique_id="123456", data={})
|
mock_config = MockConfigEntry(
|
||||||
mock_config.add_to_hass(hass)
|
domain=DOMAIN,
|
||||||
result = await hass.config_entries.flow.async_init(
|
unique_id="123456",
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": mock_config.entry_id,
|
|
||||||
},
|
|
||||||
data={
|
data={
|
||||||
"username": "test-username",
|
"username": "test-username",
|
||||||
"password": "test-password",
|
"password": "test-password",
|
||||||
"mydevolo_url": "https://test_mydevolo_url.test",
|
"mydevolo_url": "https://test_mydevolo_url.test",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
mock_config.add_to_hass(hass)
|
||||||
|
result = await mock_config.start_reauth_flow(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
@ -230,20 +223,17 @@ async def test_form_invalid_credentials_reauth(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
async def test_form_uuid_change_reauth(hass: HomeAssistant) -> None:
|
async def test_form_uuid_change_reauth(hass: HomeAssistant) -> None:
|
||||||
"""Test that the reauth confirmation form is served."""
|
"""Test that the reauth confirmation form is served."""
|
||||||
mock_config = MockConfigEntry(domain=DOMAIN, unique_id="123456", data={})
|
mock_config = MockConfigEntry(
|
||||||
mock_config.add_to_hass(hass)
|
domain=DOMAIN,
|
||||||
result = await hass.config_entries.flow.async_init(
|
unique_id="123456",
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": mock_config.entry_id,
|
|
||||||
},
|
|
||||||
data={
|
data={
|
||||||
"username": "test-username",
|
"username": "test-username",
|
||||||
"password": "test-password",
|
"password": "test-password",
|
||||||
"mydevolo_url": "https://test_mydevolo_url.test",
|
"mydevolo_url": "https://test_mydevolo_url.test",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
mock_config.add_to_hass(hass)
|
||||||
|
result = await mock_config.start_reauth_flow(hass)
|
||||||
|
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
@ -179,18 +179,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
|
|||||||
entry = configure_integration(hass)
|
entry = configure_integration(hass)
|
||||||
await hass.config_entries.async_setup(entry.entry_id)
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
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,
|
|
||||||
"title_placeholders": {
|
|
||||||
CONF_NAME: DISCOVERY_INFO.hostname.split(".")[0],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ from unittest.mock import AsyncMock, Mock, patch
|
|||||||
import nextcord
|
import nextcord
|
||||||
|
|
||||||
from homeassistant.components.discord.const import DOMAIN
|
from homeassistant.components.discord.const import DOMAIN
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import CONF_API_TOKEN, CONF_NAME
|
from homeassistant.const import CONF_API_TOKEN, CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ CONF_DATA = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def create_entry(hass: HomeAssistant) -> ConfigEntry:
|
def create_entry(hass: HomeAssistant) -> MockConfigEntry:
|
||||||
"""Add config entry in Home Assistant."""
|
"""Add config entry in Home Assistant."""
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
|
@ -4,7 +4,7 @@ import nextcord
|
|||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.discord.const import DOMAIN
|
from homeassistant.components.discord.const import DOMAIN
|
||||||
from homeassistant.const import CONF_API_TOKEN, CONF_SOURCE
|
from homeassistant.const import CONF_API_TOKEN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
|
||||||
@ -123,16 +123,7 @@ async def test_flow_user_unknown_error(hass: HomeAssistant) -> None:
|
|||||||
async def test_flow_reauth(hass: HomeAssistant) -> None:
|
async def test_flow_reauth(hass: HomeAssistant) -> None:
|
||||||
"""Test a reauth flow."""
|
"""Test a reauth flow."""
|
||||||
entry = create_entry(hass)
|
entry = create_entry(hass)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
CONF_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"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -310,11 +310,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
|||||||
data={"address": DKEY_DISCOVERY_INFO.address},
|
data={"address": DKEY_DISCOVERY_INFO.address},
|
||||||
)
|
)
|
||||||
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=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"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user