Fix modern_forms config flow test logic (#130491)

pull/130707/head
epenet 2024-11-15 15:05:59 +01:00 committed by GitHub
parent 3c3a6dff04
commit 821f9b8a41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 28 deletions

View File

@ -62,7 +62,9 @@ async def init_integration(
) )
entry = MockConfigEntry( entry = MockConfigEntry(
domain=DOMAIN, data={CONF_HOST: "192.168.1.123", CONF_MAC: "AA:BB:CC:DD:EE:FF"} domain=DOMAIN,
data={CONF_HOST: "192.168.1.123", CONF_MAC: "AA:BB:CC:DD:EE:FF"},
unique_id="AA:BB:CC:DD:EE:FF",
) )
entry.add_to_hass(hass) entry.add_to_hass(hass)

View File

@ -17,7 +17,7 @@
'pref_disable_polling': False, 'pref_disable_polling': False,
'source': 'user', 'source': 'user',
'title': 'Mock Title', 'title': 'Mock Title',
'unique_id': None, 'unique_id': 'AA:BB:CC:DD:EE:FF',
'version': 1, 'version': 1,
}), }),
'device': dict({ 'device': dict({

View File

@ -113,7 +113,11 @@ async def test_connection_error(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, DOMAIN,
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
data={CONF_HOST: "example.com"}, )
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={CONF_HOST: "example.com"},
) )
assert result.get("type") is FlowResultType.FORM assert result.get("type") is FlowResultType.FORM
@ -193,24 +197,14 @@ async def test_user_device_exists_abort(
await init_integration(hass, aioclient_mock, skip_setup=True) await init_integration(hass, aioclient_mock, skip_setup=True)
await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
data={
"host": "192.168.1.123",
"hostname": "example.local.",
"properties": {CONF_MAC: "AA:BB:CC:DD:EE:FF"},
},
)
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, DOMAIN,
context={"source": SOURCE_USER}, context={"source": SOURCE_USER},
data={ )
"host": "192.168.1.123",
"hostname": "example.local.", result = await hass.config_entries.flow.async_configure(
"properties": {CONF_MAC: "AA:BB:CC:DD:EE:FF"}, result["flow_id"],
}, user_input={CONF_HOST: "192.168.1.123"},
) )
assert result.get("type") is FlowResultType.ABORT assert result.get("type") is FlowResultType.ABORT
@ -223,16 +217,6 @@ async def test_zeroconf_with_mac_device_exists_abort(
"""Test we abort zeroconf flow if a Modern Forms device already configured.""" """Test we abort zeroconf flow if a Modern Forms device already configured."""
await init_integration(hass, aioclient_mock, skip_setup=True) await init_integration(hass, aioclient_mock, skip_setup=True)
await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
data={
"host": "192.168.1.123",
"hostname": "example.local.",
"properties": {CONF_MAC: "AA:BB:CC:DD:EE:FF"},
},
)
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, DOMAIN,
context={"source": SOURCE_ZEROCONF}, context={"source": SOURCE_ZEROCONF},