Split user flow init and data submission in met config flow tests (#182522)

This commit is contained in:
Chris
2026-09-18 07:12:50 +02:00
committed by GitHub
parent 4b1c9350b6
commit d47e3fc9c3
+17 -3
View File
@@ -72,7 +72,11 @@ async def test_create_entry(hass: HomeAssistant) -> None:
}
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=test_data
)
assert result["type"] is FlowResultType.CREATE_ENTRY
@@ -86,9 +90,15 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
Test when the form should show when user puts existing location
in the config gui. Then the form should show with error.
"""
# Coordinates as the flow stores them: the schema validates them as floats.
first_entry = MockConfigEntry(
domain=DOMAIN,
data={"name": "home", CONF_LATITUDE: 0, CONF_LONGITUDE: 0, CONF_ELEVATION: 0},
data={
"name": "home",
CONF_LATITUDE: 0.0,
CONF_LONGITUDE: 0.0,
CONF_ELEVATION: 0,
},
)
first_entry.add_to_hass(hass)
@@ -100,7 +110,11 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
}
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=test_data
)
assert result["type"] is FlowResultType.FORM