Split user flow init and data submission in ipma config flow tests (#183739)

This commit is contained in:
Manu
2026-09-30 14:38:44 +02:00
committed by GitHub
parent 1891884c5d
commit de9338d3e2
+15 -11
View File
@@ -8,14 +8,12 @@ import pytest
from homeassistant.components.ipma.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import MockLocation
from tests.common import MockConfigEntry
@pytest.fixture(name="ipma_setup", autouse=True)
def ipma_setup_fixture() -> Generator[None]:
@@ -43,7 +41,7 @@ async def test_config_flow(hass: HomeAssistant) -> None:
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
test_data,
user_input=test_data,
)
assert result["type"] is FlowResultType.CREATE_ENTRY
@@ -73,7 +71,7 @@ async def test_config_flow_failures(hass: HomeAssistant) -> None:
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
test_data,
user_input=test_data,
)
assert result["type"] is FlowResultType.FORM
@@ -84,7 +82,7 @@ async def test_config_flow_failures(hass: HomeAssistant) -> None:
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
test_data,
user_input=test_data,
)
assert result["type"] is FlowResultType.CREATE_ENTRY
@@ -95,22 +93,28 @@ async def test_config_flow_failures(hass: HomeAssistant) -> None:
}
async def test_flow_entry_already_exists(
hass: HomeAssistant, init_integration: MockConfigEntry
) -> None:
@pytest.mark.usefixtures("init_integration")
async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
"""Test user input for config_entry that already exists.
Test when the form should show when user puts existing location
in the config gui. Then the form should show with error.
"""
test_data = {
CONF_NAME: "Home",
CONF_LONGITUDE: 0,
CONF_LATITUDE: 0,
}
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=test_data
DOMAIN,
context={"source": SOURCE_USER},
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=test_data
)
await hass.async_block_till_done()