Use start_reauth helper method in integration tests (t) (#124794)
This commit is contained in:
parent
dd52f4c84a
commit
7652c35ee6
20 changed files with 61 additions and 366 deletions
|
@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, MagicMock
|
||||||
from tailscale import TailscaleAuthenticationError, TailscaleConnectionError
|
from tailscale import TailscaleAuthenticationError, TailscaleConnectionError
|
||||||
|
|
||||||
from homeassistant.components.tailscale.const import CONF_TAILNET, DOMAIN
|
from homeassistant.components.tailscale.const import CONF_TAILNET, DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.const import CONF_API_KEY
|
from homeassistant.const import CONF_API_KEY
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
@ -128,15 +128,7 @@ async def test_reauth_flow(
|
||||||
"""Test the reauthentication configuration flow."""
|
"""Test the reauthentication configuration flow."""
|
||||||
mock_config_entry.add_to_hass(hass)
|
mock_config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_config_entry.unique_id,
|
|
||||||
"entry_id": mock_config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_config_entry.data,
|
|
||||||
)
|
|
||||||
assert result.get("type") is FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "reauth_confirm"
|
assert result.get("step_id") == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -170,15 +162,7 @@ async def test_reauth_with_authentication_error(
|
||||||
"""
|
"""
|
||||||
mock_config_entry.add_to_hass(hass)
|
mock_config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_config_entry.unique_id,
|
|
||||||
"entry_id": mock_config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_config_entry.data,
|
|
||||||
)
|
|
||||||
assert result.get("type") is FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "reauth_confirm"
|
assert result.get("step_id") == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -222,15 +206,7 @@ async def test_reauth_api_error(
|
||||||
"""Test API error during reauthentication."""
|
"""Test API error during reauthentication."""
|
||||||
mock_config_entry.add_to_hass(hass)
|
mock_config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_config_entry.unique_id,
|
|
||||||
"entry_id": mock_config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_config_entry.data,
|
|
||||||
)
|
|
||||||
assert result.get("type") is FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "reauth_confirm"
|
assert result.get("step_id") == "reauth_confirm"
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,7 @@ from syrupy.assertion import SnapshotAssertion
|
||||||
from homeassistant.components import zeroconf
|
from homeassistant.components import zeroconf
|
||||||
from homeassistant.components.dhcp import DhcpServiceInfo
|
from homeassistant.components.dhcp import DhcpServiceInfo
|
||||||
from homeassistant.components.tailwind.const import DOMAIN
|
from homeassistant.components.tailwind.const import DOMAIN
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import SOURCE_DHCP, SOURCE_USER, SOURCE_ZEROCONF
|
||||||
SOURCE_DHCP,
|
|
||||||
SOURCE_REAUTH,
|
|
||||||
SOURCE_USER,
|
|
||||||
SOURCE_ZEROCONF,
|
|
||||||
)
|
|
||||||
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
from homeassistant.const import CONF_HOST, CONF_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
|
||||||
|
@ -311,15 +306,7 @@ async def test_reauth_flow(
|
||||||
mock_config_entry.add_to_hass(hass)
|
mock_config_entry.add_to_hass(hass)
|
||||||
assert mock_config_entry.data[CONF_TOKEN] == "123456"
|
assert mock_config_entry.data[CONF_TOKEN] == "123456"
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_config_entry.unique_id,
|
|
||||||
"entry_id": mock_config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_config_entry.data,
|
|
||||||
)
|
|
||||||
assert result.get("type") is FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "reauth_confirm"
|
assert result.get("step_id") == "reauth_confirm"
|
||||||
|
|
||||||
|
@ -354,15 +341,7 @@ async def test_reauth_flow_errors(
|
||||||
mock_config_entry.add_to_hass(hass)
|
mock_config_entry.add_to_hass(hass)
|
||||||
mock_tailwind.status.side_effect = side_effect
|
mock_tailwind.status.side_effect = side_effect
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_config_entry.unique_id,
|
|
||||||
"entry_id": mock_config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_config_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
|
|
|
@ -9,7 +9,7 @@ from homeassistant.components.tankerkoenig.const import (
|
||||||
CONF_STATIONS,
|
CONF_STATIONS,
|
||||||
DOMAIN,
|
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_LATITUDE,
|
CONF_LATITUDE,
|
||||||
|
@ -162,6 +162,10 @@ async def test_user_no_stations(hass: HomeAssistant) -> None:
|
||||||
async def test_reauth(hass: HomeAssistant, config_entry: MockConfigEntry) -> None:
|
async def test_reauth(hass: HomeAssistant, config_entry: MockConfigEntry) -> None:
|
||||||
"""Test starting a flow by user to re-auth."""
|
"""Test starting a flow by user to re-auth."""
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
# re-auth initialized
|
||||||
|
result = await config_entry.start_reauth_flow(hass)
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "reauth_confirm"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -171,15 +175,6 @@ async def test_reauth(hass: HomeAssistant, config_entry: MockConfigEntry) -> Non
|
||||||
"homeassistant.components.tankerkoenig.config_flow.Tankerkoenig.nearby_stations",
|
"homeassistant.components.tankerkoenig.config_flow.Tankerkoenig.nearby_stations",
|
||||||
) as mock_nearby_stations,
|
) as mock_nearby_stations,
|
||||||
):
|
):
|
||||||
# re-auth initialized
|
|
||||||
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"] == "reauth_confirm"
|
|
||||||
|
|
||||||
# re-auth unsuccessful
|
# re-auth unsuccessful
|
||||||
mock_nearby_stations.side_effect = TankerkoenigInvalidKeyError("Booom!")
|
mock_nearby_stations.side_effect = TankerkoenigInvalidKeyError("Booom!")
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
|
|
@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, patch
|
||||||
from pytautulli import exceptions
|
from pytautulli import exceptions
|
||||||
|
|
||||||
from homeassistant.components.tautulli.const import DOMAIN
|
from homeassistant.components.tautulli.const import 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, CONF_URL, CONF_VERIFY_SSL
|
from homeassistant.const import CONF_API_KEY, CONF_SOURCE, CONF_URL, 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
|
||||||
|
@ -156,15 +156,7 @@ async def test_flow_reauth(
|
||||||
"""Test reauth flow."""
|
"""Test reauth flow."""
|
||||||
with patch("homeassistant.components.tautulli.PLATFORMS", []):
|
with patch("homeassistant.components.tautulli.PLATFORMS", []):
|
||||||
entry = await setup_integration(hass, aioclient_mock)
|
entry = await setup_integration(hass, aioclient_mock)
|
||||||
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"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
@ -193,14 +185,7 @@ async def test_flow_reauth_error(
|
||||||
"""Test reauth flow with invalid authentication."""
|
"""Test reauth flow with invalid authentication."""
|
||||||
with patch("homeassistant.components.tautulli.PLATFORMS", []):
|
with patch("homeassistant.components.tautulli.PLATFORMS", []):
|
||||||
entry = await setup_integration(hass, aioclient_mock)
|
entry = await setup_integration(hass, aioclient_mock)
|
||||||
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,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
with patch_config_flow_tautulli(AsyncMock()) as tautullimock:
|
with patch_config_flow_tautulli(AsyncMock()) as tautullimock:
|
||||||
tautullimock.side_effect = exceptions.PyTautulliAuthenticationException
|
tautullimock.side_effect = exceptions.PyTautulliAuthenticationException
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
|
|
@ -10,7 +10,7 @@ from pytedee_async import (
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.tedee.const import CONF_LOCAL_ACCESS_TOKEN, DOMAIN
|
from homeassistant.components.tedee.const import CONF_LOCAL_ACCESS_TOKEN, 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_HOST, CONF_WEBHOOK_ID
|
from homeassistant.const import CONF_HOST, CONF_WEBHOOK_ID
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
@ -122,18 +122,7 @@ async def test_reauth_flow(
|
||||||
|
|
||||||
mock_config_entry.add_to_hass(hass)
|
mock_config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
reauth_result = await hass.config_entries.flow.async_init(
|
reauth_result = await mock_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_config_entry.unique_id,
|
|
||||||
"entry_id": mock_config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data={
|
|
||||||
CONF_LOCAL_ACCESS_TOKEN: LOCAL_ACCESS_TOKEN,
|
|
||||||
CONF_HOST: "192.168.1.42",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
reauth_result["flow_id"],
|
reauth_result["flow_id"],
|
||||||
|
|
|
@ -16,7 +16,7 @@ from homeassistant.components.tesla_fleet.const import (
|
||||||
SCOPES,
|
SCOPES,
|
||||||
TOKEN_URL,
|
TOKEN_URL,
|
||||||
)
|
)
|
||||||
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
|
||||||
|
@ -211,15 +211,7 @@ async def test_reauthentication(
|
||||||
)
|
)
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await old_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": old_entry.unique_id,
|
|
||||||
"entry_id": old_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=old_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
flows = hass.config_entries.flow.async_progress()
|
flows = hass.config_entries.flow.async_progress()
|
||||||
assert len(flows) == 1
|
assert len(flows) == 1
|
||||||
|
@ -267,15 +259,7 @@ async def test_reauth_account_mismatch(
|
||||||
old_entry = MockConfigEntry(domain=DOMAIN, unique_id="baduid", version=1, data={})
|
old_entry = MockConfigEntry(domain=DOMAIN, unique_id="baduid", version=1, data={})
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await old_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": old_entry.unique_id,
|
|
||||||
"entry_id": old_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=old_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
flows = hass.config_entries.flow.async_progress()
|
flows = hass.config_entries.flow.async_progress()
|
||||||
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
|
result = await hass.config_entries.flow.async_configure(flows[0]["flow_id"], {})
|
||||||
|
|
|
@ -94,14 +94,7 @@ async def test_reauth(hass: HomeAssistant, mock_metadata) -> None:
|
||||||
)
|
)
|
||||||
mock_entry.add_to_hass(hass)
|
mock_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result1 = await hass.config_entries.flow.async_init(
|
result1 = await mock_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=BAD_CONFIG,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result1["type"] is FlowResultType.FORM
|
assert result1["type"] is FlowResultType.FORM
|
||||||
assert result1["step_id"] == "reauth_confirm"
|
assert result1["step_id"] == "reauth_confirm"
|
||||||
|
@ -144,15 +137,7 @@ async def test_reauth_errors(
|
||||||
)
|
)
|
||||||
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=BAD_CONFIG,
|
|
||||||
)
|
|
||||||
|
|
||||||
mock_metadata.side_effect = side_effect
|
mock_metadata.side_effect = side_effect
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
|
|
|
@ -143,14 +143,7 @@ async def test_reauth(
|
||||||
)
|
)
|
||||||
mock_entry.add_to_hass(hass)
|
mock_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result1 = await hass.config_entries.flow.async_init(
|
result1 = await mock_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": mock_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=TEST_CONFIG,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result1["type"] is FlowResultType.FORM
|
assert result1["type"] is FlowResultType.FORM
|
||||||
assert result1["step_id"] == "reauth_confirm"
|
assert result1["step_id"] == "reauth_confirm"
|
||||||
|
@ -194,15 +187,7 @@ async def test_reauth_errors(
|
||||||
)
|
)
|
||||||
mock_entry.add_to_hass(hass)
|
mock_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result1 = await hass.config_entries.flow.async_init(
|
result1 = 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=TEST_CONFIG,
|
|
||||||
)
|
|
||||||
|
|
||||||
result2 = await hass.config_entries.flow.async_configure(
|
result2 = await hass.config_entries.flow.async_configure(
|
||||||
result1["flow_id"],
|
result1["flow_id"],
|
||||||
|
|
|
@ -4,7 +4,7 @@ import pytest
|
||||||
from ttn_client import TTNAuthError
|
from ttn_client import TTNAuthError
|
||||||
|
|
||||||
from homeassistant.components.thethingsnetwork.const import CONF_APP_ID, DOMAIN
|
from homeassistant.components.thethingsnetwork.const import CONF_APP_ID, 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_HOST
|
from homeassistant.const import CONF_API_KEY, CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.data_entry_flow import FlowResultType
|
from homeassistant.data_entry_flow import FlowResultType
|
||||||
|
@ -12,6 +12,8 @@ from homeassistant.data_entry_flow import FlowResultType
|
||||||
from . import init_integration
|
from . import init_integration
|
||||||
from .conftest import API_KEY, APP_ID, HOST
|
from .conftest import API_KEY, APP_ID, HOST
|
||||||
|
|
||||||
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
USER_DATA = {CONF_HOST: HOST, CONF_APP_ID: APP_ID, CONF_API_KEY: API_KEY}
|
USER_DATA = {CONF_HOST: HOST, CONF_APP_ID: APP_ID, CONF_API_KEY: API_KEY}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,21 +94,13 @@ async def test_duplicate_entry(
|
||||||
|
|
||||||
|
|
||||||
async def test_step_reauth(
|
async def test_step_reauth(
|
||||||
hass: HomeAssistant, mock_ttnclient, mock_config_entry
|
hass: HomeAssistant, mock_ttnclient, mock_config_entry: MockConfigEntry
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that the reauth step works."""
|
"""Test that the reauth step works."""
|
||||||
|
|
||||||
await init_integration(hass, mock_config_entry)
|
await init_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,
|
|
||||||
"unique_id": APP_ID,
|
|
||||||
"entry_id": mock_config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=USER_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 not result["errors"]
|
assert not result["errors"]
|
||||||
|
|
|
@ -6,13 +6,15 @@ import pytest
|
||||||
from pytile.errors import InvalidAuthError, TileError
|
from pytile.errors import InvalidAuthError, TileError
|
||||||
|
|
||||||
from homeassistant.components.tile import DOMAIN
|
from homeassistant.components.tile import DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_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_USERNAME
|
from .conftest import TEST_PASSWORD, TEST_USERNAME
|
||||||
|
|
||||||
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("mock_login_response", "errors"),
|
("mock_login_response", "errors"),
|
||||||
|
@ -77,12 +79,10 @@ async def test_import_entry(hass: HomeAssistant, config, mock_pytile) -> None:
|
||||||
|
|
||||||
|
|
||||||
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"])
|
||||||
|
|
|
@ -9,7 +9,7 @@ from homeassistant.components.totalconnect.const import (
|
||||||
CONF_USERCODES,
|
CONF_USERCODES,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
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
|
||||||
|
@ -141,9 +141,7 @@ async def test_reauth(hass: HomeAssistant) -> 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": 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"
|
||||||
|
|
||||||
|
|
|
@ -251,14 +251,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,
|
|
||||||
},
|
|
||||||
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"
|
||||||
|
@ -298,14 +291,7 @@ async def test_async_step_reauth_invalid_auth(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,
|
|
||||||
},
|
|
||||||
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"
|
||||||
|
|
|
@ -110,15 +110,7 @@ async def test_reauthentication(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await old_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": old_entry.unique_id,
|
|
||||||
"entry_id": old_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=old_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
@ -151,15 +143,7 @@ async def test_reauthentication_failure(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await old_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": old_entry.unique_id,
|
|
||||||
"entry_id": old_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=old_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
@ -189,15 +173,7 @@ async def test_reauthentication_unknown_failure(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await old_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": old_entry.unique_id,
|
|
||||||
"entry_id": old_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=old_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
@ -227,15 +203,7 @@ async def test_reauthentication_failure_no_existing_entry(hass: HomeAssistant) -
|
||||||
)
|
)
|
||||||
old_entry.add_to_hass(hass)
|
old_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await old_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"unique_id": old_entry.unique_id,
|
|
||||||
"entry_id": old_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=old_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
|
@ -208,15 +208,7 @@ async def test_reauth_flow(hass: HomeAssistant) -> 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,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
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
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
@ -280,15 +272,7 @@ async def test_reauth_flow_error(
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
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,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
data=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.trafikverket_camera.config_flow.TrafikverketCamera.async_get_cameras",
|
"homeassistant.components.trafikverket_camera.config_flow.TrafikverketCamera.async_get_cameras",
|
||||||
|
|
|
@ -128,15 +128,7 @@ async def test_reauth_flow(hass: HomeAssistant) -> 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,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
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
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
@ -203,15 +195,7 @@ async def test_reauth_flow_error(
|
||||||
)
|
)
|
||||||
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=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.trafikverket_ferry.config_flow.TrafikverketFerry.async_get_next_ferry_stop",
|
"homeassistant.components.trafikverket_ferry.config_flow.TrafikverketFerry.async_get_next_ferry_stop",
|
||||||
|
|
|
@ -246,15 +246,7 @@ async def test_reauth_flow(hass: HomeAssistant) -> 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,
|
|
||||||
"unique_id": entry.unique_id,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
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
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
@ -328,15 +320,7 @@ async def test_reauth_flow_error(
|
||||||
)
|
)
|
||||||
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=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
@ -418,15 +402,7 @@ async def test_reauth_flow_error_departures(
|
||||||
)
|
)
|
||||||
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=entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
|
|
|
@ -116,14 +116,7 @@ async def test_reauth_flow(hass: HomeAssistant) -> 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=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
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
@ -182,14 +175,7 @@ async def test_reauth_flow_fails(
|
||||||
)
|
)
|
||||||
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["step_id"] == "reauth_confirm"
|
assert result["step_id"] == "reauth_confirm"
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["errors"] == {}
|
assert result["errors"] == {}
|
||||||
|
|
|
@ -160,14 +160,7 @@ async def test_reauth_success(hass: HomeAssistant) -> None:
|
||||||
entry = MockConfigEntry(domain=transmission.DOMAIN, data=MOCK_CONFIG_DATA)
|
entry = MockConfigEntry(domain=transmission.DOMAIN, data=MOCK_CONFIG_DATA)
|
||||||
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)
|
||||||
transmission.DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
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"
|
||||||
|
@ -197,14 +190,7 @@ async def test_reauth_failed(hass: HomeAssistant, mock_api: MagicMock) -> 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)
|
||||||
transmission.DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
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"
|
||||||
|
@ -232,14 +218,7 @@ async def test_reauth_failed_connection_error(
|
||||||
)
|
)
|
||||||
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)
|
||||||
transmission.DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": config_entries.SOURCE_REAUTH,
|
|
||||||
"entry_id": entry.entry_id,
|
|
||||||
},
|
|
||||||
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"
|
||||||
|
|
|
@ -8,7 +8,7 @@ import pytest
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components.tuya.const import CONF_APP_TYPE, CONF_USER_CODE, DOMAIN
|
from homeassistant.components.tuya.const import CONF_APP_TYPE, CONF_USER_CODE, 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
|
||||||
|
|
||||||
|
@ -145,15 +145,7 @@ async def test_reauth_flow(
|
||||||
"""Test the reauthentication configuration flow."""
|
"""Test the reauthentication configuration flow."""
|
||||||
mock_config_entry.add_to_hass(hass)
|
mock_config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_config_entry.unique_id,
|
|
||||||
"entry_id": mock_config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_config_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result.get("type") is FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "scan"
|
assert result.get("step_id") == "scan"
|
||||||
|
@ -185,15 +177,7 @@ async def test_reauth_flow_migration(
|
||||||
assert CONF_APP_TYPE in mock_old_config_entry.data
|
assert CONF_APP_TYPE in mock_old_config_entry.data
|
||||||
assert CONF_USER_CODE not in mock_old_config_entry.data
|
assert CONF_USER_CODE not in mock_old_config_entry.data
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_old_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_old_config_entry.unique_id,
|
|
||||||
"entry_id": mock_old_config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_old_config_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result.get("type") is FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "reauth_user_code"
|
assert result.get("step_id") == "reauth_user_code"
|
||||||
|
@ -229,15 +213,7 @@ async def test_reauth_flow_failed_qr_code(
|
||||||
"""Test an error occurring while retrieving the QR code."""
|
"""Test an error occurring while retrieving the QR code."""
|
||||||
mock_old_config_entry.add_to_hass(hass)
|
mock_old_config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await mock_old_config_entry.start_reauth_flow(hass)
|
||||||
DOMAIN,
|
|
||||||
context={
|
|
||||||
"source": SOURCE_REAUTH,
|
|
||||||
"unique_id": mock_old_config_entry.unique_id,
|
|
||||||
"entry_id": mock_old_config_entry.entry_id,
|
|
||||||
},
|
|
||||||
data=mock_old_config_entry.data,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Something went wrong getting the QR code (like an invalid user code)
|
# Something went wrong getting the QR code (like an invalid user code)
|
||||||
mock_tuya_login_control.qr_code.return_value["success"] = False
|
mock_tuya_login_control.qr_code.return_value["success"] = False
|
||||||
|
|
|
@ -10,7 +10,7 @@ from homeassistant.components.twitch.const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
OAUTH2_AUTHORIZE,
|
OAUTH2_AUTHORIZE,
|
||||||
)
|
)
|
||||||
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 FlowResult, FlowResultType
|
from homeassistant.data_entry_flow import FlowResult, FlowResultType
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
|
@ -109,14 +109,7 @@ async def test_reauth(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check reauth flow."""
|
"""Check reauth flow."""
|
||||||
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"
|
||||||
|
|
||||||
|
@ -184,14 +177,7 @@ async def test_reauth_wrong_account(
|
||||||
twitch_mock.return_value.get_users = lambda *args, **kwargs: get_generator(
|
twitch_mock.return_value.get_users = lambda *args, **kwargs: get_generator(
|
||||||
"get_users_2.json", TwitchUser
|
"get_users_2.json", TwitchUser
|
||||||
)
|
)
|
||||||
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"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue