mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 07:51:46 -05:00
Split The Things Network user flow init from its data (#180660)
This commit is contained in:
@@ -28,10 +28,8 @@ async def test_user(hass: HomeAssistant, mock_ttnclient) -> None:
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
data=USER_DATA,
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=USER_DATA
|
||||
)
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == APP_ID
|
||||
@@ -54,17 +52,21 @@ async def test_user_errors(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
data=USER_DATA,
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=USER_DATA
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert base_error in result["errors"]["base"]
|
||||
|
||||
# Recover
|
||||
mock_ttnclient.return_value.fetch_data.side_effect = None
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
data=USER_DATA,
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=USER_DATA
|
||||
)
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
@@ -84,10 +86,8 @@ async def test_duplicate_entry(
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
data=USER_DATA,
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=USER_DATA
|
||||
)
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
Reference in New Issue
Block a user