Split the Pi-hole user flow init from its data (#180776)

This commit is contained in:
Franck Nijhof
2026-08-30 13:07:05 +02:00
committed by GitHub
parent 64bd0cccae
commit c9c9bbb1d7
+54 -10
View File
@@ -59,9 +59,15 @@ async def test_flow_user_with_api_key_v6(hass: HomeAssistant) -> None:
# duplicated server
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
data=CONFIG_FLOW_USER,
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=CONFIG_FLOW_USER,
)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@@ -109,9 +115,15 @@ async def test_flow_user_with_api_key_v5(hass: HomeAssistant) -> None:
# duplicated server
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
data=CONFIG_FLOW_USER,
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=CONFIG_FLOW_USER,
)
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@@ -122,7 +134,15 @@ async def test_flow_user_invalid(hass: HomeAssistant) -> None:
mocked_hole = _create_mocked_hole(raise_exception=True)
with _patch_config_flow_hole(mocked_hole), _patch_init_hole(mocked_hole):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG_FLOW_USER
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=CONFIG_FLOW_USER,
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
@@ -136,7 +156,15 @@ async def test_flow_user_invalid_v6(hass: HomeAssistant) -> None:
)
with _patch_config_flow_hole(mocked_hole), _patch_init_hole(mocked_hole):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG_FLOW_USER
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=CONFIG_FLOW_USER,
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
@@ -176,7 +204,15 @@ async def test_flow_user_invalid_host(hass: HomeAssistant) -> None:
mocked_hole = _create_mocked_hole(api_version=6, wrong_host=True)
with _patch_config_flow_hole(mocked_hole), _patch_init_hole(mocked_hole):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG_FLOW_USER
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=CONFIG_FLOW_USER,
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
@@ -188,7 +224,15 @@ async def test_flow_error_response(hass: HomeAssistant) -> None:
mocked_hole = _create_mocked_hole(api_version=5, ftl_error=True, has_data=False)
with _patch_config_flow_hole(mocked_hole), _patch_init_hole(mocked_hole):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG_FLOW_USER
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=CONFIG_FLOW_USER,
)
assert mocked_hole.instances[-1].data == FTL_ERROR
assert result["type"] is FlowResultType.FORM