Split the LG Netcast user flow init from its data (#180787)

This commit is contained in:
Franck Nijhof
2026-08-30 15:24:43 +02:00
committed by GitHub
parent f314d3011e
commit b4997d58dd
@@ -39,7 +39,15 @@ async def test_user_invalid_host(hass: HomeAssistant) -> None:
"""Test that errors are shown when the host is invalid."""
with _patch_lg_netcast():
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: "invalid/host"}
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={CONF_HOST: "invalid/host"},
)
assert result["errors"] == {CONF_HOST: "invalid_host"}
@@ -49,7 +57,15 @@ async def test_manual_host(hass: HomeAssistant) -> None:
"""Test manual host configuration."""
with _patch_lg_netcast():
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: IP_ADDRESS}
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={CONF_HOST: IP_ADDRESS},
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
@@ -81,7 +97,15 @@ async def test_manual_host_no_connection_during_authorize(hass: HomeAssistant) -
"""Test manual host configuration."""
with _patch_lg_netcast(fail_connection=True):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: IP_ADDRESS}
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={CONF_HOST: IP_ADDRESS},
)
assert result["type"] is data_entry_flow.FlowResultType.ABORT
@@ -94,7 +118,15 @@ async def test_manual_host_invalid_details_during_authorize(
"""Test manual host configuration."""
with _patch_lg_netcast(invalid_details=True):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: IP_ADDRESS}
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={CONF_HOST: IP_ADDRESS},
)
assert result["type"] is data_entry_flow.FlowResultType.ABORT
@@ -105,7 +137,15 @@ async def test_manual_host_unsuccessful_details_response(hass: HomeAssistant) ->
"""Test manual host configuration."""
with _patch_lg_netcast(always_404=True):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: IP_ADDRESS}
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={CONF_HOST: IP_ADDRESS},
)
assert result["type"] is data_entry_flow.FlowResultType.ABORT
@@ -116,7 +156,15 @@ async def test_manual_host_no_unique_id_response(hass: HomeAssistant) -> None:
"""Test manual host configuration."""
with _patch_lg_netcast(no_unique_id=True):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: IP_ADDRESS}
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={CONF_HOST: IP_ADDRESS},
)
assert result["type"] is data_entry_flow.FlowResultType.ABORT
@@ -127,7 +175,15 @@ async def test_invalid_session_id(hass: HomeAssistant) -> None:
"""Test Invalid Session ID."""
with _patch_lg_netcast(session_error=True):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: IP_ADDRESS}
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={CONF_HOST: IP_ADDRESS},
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
@@ -166,7 +222,15 @@ async def test_display_access_token_aborted(hass: HomeAssistant) -> None:
):
mock_interval.side_effect = _async_track_time_interval
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: IP_ADDRESS}
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={CONF_HOST: IP_ADDRESS},
)
assert result["type"] is data_entry_flow.FlowResultType.FORM