mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 17:31:15 -04:00
Split user flow init and data submission in met config flow tests (#182522)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user