Use FlowResultType enum in config flow tests A-M (#114681)

This commit is contained in:
Joost Lekkerkerker 2024-04-03 09:21:17 +02:00 committed by GitHub
parent a767530970
commit b9281327c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
111 changed files with 997 additions and 961 deletions

View file

@ -113,7 +113,7 @@ async def test_integration_already_exists(hass: HomeAssistant) -> None:
data=VALID_CONFIG, data=VALID_CONFIG,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "single_instance_allowed" assert result["reason"] == "single_instance_allowed"

View file

@ -146,5 +146,5 @@ async def test_already_configured(hass: HomeAssistant, mock_hub_discover) -> Non
DOMAIN, context={"source": SOURCE_USER} DOMAIN, context={"source": SOURCE_USER}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found" assert result["reason"] == "no_devices_found"

View file

@ -58,7 +58,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == str(TEST_DATA["account_id"]) assert result3["title"] == str(TEST_DATA["account_id"])
assert result3["data"] == { assert result3["data"] == {
ACCOUNT_ID: TEST_DATA["account_id"], ACCOUNT_ID: TEST_DATA["account_id"],
@ -124,7 +124,7 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "abort" assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "already_configured" assert result3["reason"] == "already_configured"
@ -173,7 +173,7 @@ async def test_local_create_entry(hass: HomeAssistant) -> None:
) )
test_data[CONNECTION_TYPE] = LOCAL test_data[CONNECTION_TYPE] = LOCAL
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "8383838" assert result["title"] == "8383838"
assert result["data"] == { assert result["data"] == {
"connection_type": "Local", "connection_type": "Local",
@ -229,7 +229,7 @@ async def test_local_flow_entry_already_exists(hass: HomeAssistant) -> None:
test_data, test_data,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -116,7 +116,7 @@ async def test_integration_already_exists(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_USER}, context={"source": config_entries.SOURCE_USER},
) )
assert result assert result
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured" assert result.get("reason") == "already_configured"

View file

@ -127,7 +127,7 @@ async def test_form_duplicated_id(
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -98,7 +98,7 @@ async def test_duplicate_error(
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -35,7 +35,7 @@ async def test_form_invalid_auth(hass: HomeAssistant, config, setup_airnow) -> N
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config)
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
@ -46,7 +46,7 @@ async def test_form_invalid_location(hass: HomeAssistant, config, setup_airnow)
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config)
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_location"} assert result2["errors"] == {"base": "invalid_location"}
@ -57,7 +57,7 @@ async def test_form_cannot_connect(hass: HomeAssistant, config, setup_airnow) ->
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config)
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -68,7 +68,7 @@ async def test_form_empty_result(hass: HomeAssistant, config, setup_airnow) -> N
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config)
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_location"} assert result2["errors"] == {"base": "invalid_location"}
@ -79,7 +79,7 @@ async def test_form_unexpected(hass: HomeAssistant, config, setup_airnow) -> Non
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config)
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
@ -89,7 +89,7 @@ async def test_entry_already_exists(hass: HomeAssistant, config, config_entry) -
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config)
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"

View file

@ -121,5 +121,5 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=TEST_DATA DOMAIN, context={"source": config_entries.SOURCE_USER}, data=TEST_DATA
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -7,6 +7,7 @@ from airtouch4pyapi.airtouch import AirTouch, AirTouchAc, AirTouchGroup, AirTouc
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.airtouch4.const import DOMAIN from homeassistant.components.airtouch4.const import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
async def test_form(hass: HomeAssistant) -> None: async def test_form(hass: HomeAssistant) -> None:
@ -14,7 +15,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
mock_ac = AirTouchAc() mock_ac = AirTouchAc()
mock_groups = AirTouchGroup() mock_groups = AirTouchGroup()
@ -39,7 +40,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "0.0.0.1" assert result2["title"] == "0.0.0.1"
assert result2["data"] == { assert result2["data"] == {
"host": "0.0.0.1", "host": "0.0.0.1",
@ -62,7 +63,7 @@ async def test_form_timeout(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": "0.0.0.1"} result["flow_id"], {"host": "0.0.0.1"}
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -81,7 +82,7 @@ async def test_form_library_error_message(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": "0.0.0.1"} result["flow_id"], {"host": "0.0.0.1"}
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -100,7 +101,7 @@ async def test_form_connection_refused(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": "0.0.0.1"} result["flow_id"], {"host": "0.0.0.1"}
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -124,5 +125,5 @@ async def test_form_no_units(hass: HomeAssistant) -> None:
result["flow_id"], {"host": "0.0.0.1"} result["flow_id"], {"host": "0.0.0.1"}
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "no_units"} assert result2["errors"] == {"base": "no_units"}

View file

@ -177,7 +177,7 @@ async def test_form_duplicated_id(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -116,7 +116,7 @@ async def test_form_already_configured(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == config_entries.SOURCE_USER assert result["step_id"] == config_entries.SOURCE_USER
with patch( with patch(
@ -132,7 +132,7 @@ async def test_form_already_configured(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"

View file

@ -880,7 +880,7 @@ async def test_options_flow(
# Trigger options flow, first time # Trigger options flow, first time
result = await hass.config_entries.options.async_init(mock_config_entry.entry_id) result = await hass.config_entries.options.async_init(mock_config_entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
data_schema = result["data_schema"].schema data_schema = result["data_schema"].schema
assert set(data_schema) == {"enable_ime"} assert set(data_schema) == {"enable_ime"}
@ -889,7 +889,7 @@ async def test_options_flow(
result["flow_id"], result["flow_id"],
user_input={"enable_ime": False}, user_input={"enable_ime": False},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert mock_config_entry.options == {"enable_ime": False} assert mock_config_entry.options == {"enable_ime": False}
await hass.async_block_till_done() await hass.async_block_till_done()
@ -902,7 +902,7 @@ async def test_options_flow(
result["flow_id"], result["flow_id"],
user_input={"enable_ime": False}, user_input={"enable_ime": False},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert mock_config_entry.options == {"enable_ime": False} assert mock_config_entry.options == {"enable_ime": False}
await hass.async_block_till_done() await hass.async_block_till_done()
@ -915,7 +915,7 @@ async def test_options_flow(
result["flow_id"], result["flow_id"],
user_input={"enable_ime": True}, user_input={"enable_ime": True},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert mock_config_entry.options == {"enable_ime": True} assert mock_config_entry.options == {"enable_ime": True}
await hass.async_block_till_done() await hass.async_block_till_done()

View file

@ -136,7 +136,7 @@ async def test_user_adds_full_device(hass: HomeAssistant, full_device, pairing)
result6 = await hass.config_entries.flow.async_configure( result6 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"pin": 1234} result["flow_id"], {"pin": 1234}
) )
assert result6["type"] == "create_entry" assert result6["type"] is FlowResultType.CREATE_ENTRY
assert result6["data"] == { assert result6["data"] == {
"address": "127.0.0.1", "address": "127.0.0.1",
"credentials": { "credentials": {
@ -174,7 +174,7 @@ async def test_user_adds_dmap_device(
result6 = await hass.config_entries.flow.async_configure( result6 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"pin": 1234} result["flow_id"], {"pin": 1234}
) )
assert result6["type"] == "create_entry" assert result6["type"] is FlowResultType.CREATE_ENTRY
assert result6["data"] == { assert result6["data"] == {
"address": "127.0.0.1", "address": "127.0.0.1",
"credentials": {Protocol.DMAP.value: "dmap_creds"}, "credentials": {Protocol.DMAP.value: "dmap_creds"},
@ -540,7 +540,7 @@ async def test_ignores_disabled_service(
result3 = await hass.config_entries.flow.async_configure( result3 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"pin": 1111} result["flow_id"], {"pin": 1111}
) )
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["data"] == { assert result3["data"] == {
"address": "127.0.0.1", "address": "127.0.0.1",
"credentials": { "credentials": {
@ -621,7 +621,7 @@ async def test_zeroconf_add_mrp_device(
result3 = await hass.config_entries.flow.async_configure( result3 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"pin": 1111} result["flow_id"], {"pin": 1111}
) )
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["data"] == { assert result3["data"] == {
"address": "127.0.0.1", "address": "127.0.0.1",
"credentials": {Protocol.MRP.value: "mrp_creds"}, "credentials": {Protocol.MRP.value: "mrp_creds"},
@ -651,7 +651,7 @@ async def test_zeroconf_add_dmap_device(
assert result2["description_placeholders"] == {"protocol": "DMAP", "pin": "1111"} assert result2["description_placeholders"] == {"protocol": "DMAP", "pin": "1111"}
result3 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result3 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["data"] == { assert result3["data"] == {
"address": "127.0.0.1", "address": "127.0.0.1",
"credentials": {Protocol.DMAP.value: "dmap_creds"}, "credentials": {Protocol.DMAP.value: "dmap_creds"},
@ -1224,7 +1224,7 @@ async def test_option_start_off(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.options.async_configure( result2 = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={CONF_START_OFF: True} result["flow_id"], user_input={CONF_START_OFF: True}
) )
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options[CONF_START_OFF] assert config_entry.options[CONF_START_OFF]

View file

@ -23,7 +23,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -42,7 +42,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Aurora visibility" assert result2["title"] == "Aurora visibility"
assert result2["data"] == DATA assert result2["data"] == DATA
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -64,7 +64,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
DATA, DATA,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -85,7 +85,7 @@ async def test_with_unknown_error(hass: HomeAssistant) -> None:
DATA, DATA,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {"base": "unknown"} assert result["errors"] == {"base": "unknown"}

View file

@ -31,7 +31,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -91,7 +91,7 @@ async def test_form_no_comports(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_serial_ports" assert result["reason"] == "no_serial_ports"
@ -107,7 +107,7 @@ async def test_form_invalid_com_ports(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with patch( with patch(

View file

@ -233,5 +233,5 @@ async def test_reauth(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result7["type"] == "abort" assert result7["type"] is FlowResultType.ABORT
assert result7["reason"] == "reauth_successful" assert result7["reason"] == "reauth_successful"

View file

@ -56,14 +56,14 @@ async def test_form(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=None DOMAIN, context={"source": config_entries.SOURCE_USER}, data=None
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], result["flow_id"],
step1_config.copy(), step1_config.copy(),
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == step_id assert result2["step_id"] == step_id
result3 = await hass.config_entries.flow.async_configure( result3 = await hass.config_entries.flow.async_configure(
result2["flow_id"], result2["flow_id"],
@ -136,7 +136,7 @@ async def test_connection_error_sas(
context={"source": config_entries.SOURCE_USER}, context={"source": config_entries.SOURCE_USER},
data=BASE_CONFIG_SAS.copy(), data=BASE_CONFIG_SAS.copy(),
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
mock_get_eventhub_properties.side_effect = side_effect mock_get_eventhub_properties.side_effect = side_effect
@ -165,7 +165,7 @@ async def test_connection_error_cs(
context={"source": config_entries.SOURCE_USER}, context={"source": config_entries.SOURCE_USER},
data=BASE_CONFIG_CS.copy(), data=BASE_CONFIG_CS.copy(),
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
mock_from_connection_string.return_value.get_eventhub_properties.side_effect = ( mock_from_connection_string.return_value.get_eventhub_properties.side_effect = (
side_effect side_effect

View file

@ -30,7 +30,7 @@ async def test_form_user(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -113,7 +113,7 @@ async def test_zeroconf_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "My Fan" assert result2["title"] == "My Fan"
assert result2["data"] == {CONF_IP_ADDRESS: "127.0.0.1"} assert result2["data"] == {CONF_IP_ADDRESS: "127.0.0.1"}
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -182,7 +182,7 @@ async def test_user_flow_is_not_blocked_by_discovery(hass: HomeAssistant) -> Non
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (

View file

@ -66,7 +66,7 @@ async def test_flow_works(
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER} config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
@ -75,7 +75,7 @@ async def test_flow_works(
data={config_flow.CONF_HOST: "172.2.3.4", config_flow.CONF_PORT: 80}, data={config_flow.CONF_HOST: "172.2.3.4", config_flow.CONF_PORT: 80},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "My gate controller" assert result["title"] == "My gate controller"
assert result["data"] == { assert result["data"] == {
config_flow.CONF_HOST: "172.2.3.4", config_flow.CONF_HOST: "172.2.3.4",

View file

@ -17,7 +17,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -37,7 +37,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "blink" assert result2["title"] == "blink"
assert result2["result"].unique_id == "blink@example.com" assert result2["result"].unique_id == "blink@example.com"
assert result2["data"] == { assert result2["data"] == {
@ -72,7 +72,7 @@ async def test_form_2fa(hass: HomeAssistant) -> None:
{"username": "blink@example.com", "password": "example"}, {"username": "blink@example.com", "password": "example"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "2fa" assert result2["step_id"] == "2fa"
with ( with (
@ -98,7 +98,7 @@ async def test_form_2fa(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "blink" assert result3["title"] == "blink"
assert result3["result"].unique_id == "blink@example.com" assert result3["result"].unique_id == "blink@example.com"
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -123,7 +123,7 @@ async def test_form_2fa_connect_error(hass: HomeAssistant) -> None:
{"username": "blink@example.com", "password": "example"}, {"username": "blink@example.com", "password": "example"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "2fa" assert result2["step_id"] == "2fa"
with ( with (
@ -149,7 +149,7 @@ async def test_form_2fa_connect_error(hass: HomeAssistant) -> None:
result2["flow_id"], {"pin": "1234"} result2["flow_id"], {"pin": "1234"}
) )
assert result3["type"] == "form" assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {"base": "cannot_connect"} assert result3["errors"] == {"base": "cannot_connect"}
@ -172,7 +172,7 @@ async def test_form_2fa_invalid_key(hass: HomeAssistant) -> None:
{"username": "blink@example.com", "password": "example"}, {"username": "blink@example.com", "password": "example"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "2fa" assert result2["step_id"] == "2fa"
with ( with (
@ -200,7 +200,7 @@ async def test_form_2fa_invalid_key(hass: HomeAssistant) -> None:
result2["flow_id"], {"pin": "1234"} result2["flow_id"], {"pin": "1234"}
) )
assert result3["type"] == "form" assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {"base": "invalid_access_token"} assert result3["errors"] == {"base": "invalid_access_token"}
@ -223,7 +223,7 @@ async def test_form_2fa_unknown_error(hass: HomeAssistant) -> None:
{"username": "blink@example.com", "password": "example"}, {"username": "blink@example.com", "password": "example"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "2fa" assert result2["step_id"] == "2fa"
with ( with (
@ -249,7 +249,7 @@ async def test_form_2fa_unknown_error(hass: HomeAssistant) -> None:
result2["flow_id"], {"pin": "1234"} result2["flow_id"], {"pin": "1234"}
) )
assert result3["type"] == "form" assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {"base": "unknown"} assert result3["errors"] == {"base": "unknown"}
@ -267,7 +267,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
result["flow_id"], {"username": "blink@example.com", "password": "example"} result["flow_id"], {"username": "blink@example.com", "password": "example"}
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
@ -285,7 +285,7 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
result["flow_id"], {"username": "blink@example.com", "password": "example"} result["flow_id"], {"username": "blink@example.com", "password": "example"}
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}

View file

@ -15,6 +15,7 @@ from homeassistant.components.bond.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .common import ( from .common import (
patch_bond_bridge, patch_bond_bridge,
@ -35,7 +36,7 @@ async def test_user_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -53,7 +54,7 @@ async def test_user_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "bond-name" assert result2["title"] == "bond-name"
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: "some host", CONF_HOST: "some host",
@ -68,7 +69,7 @@ async def test_user_form_with_non_bridge(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -90,7 +91,7 @@ async def test_user_form_with_non_bridge(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "New Fan" assert result2["title"] == "New Fan"
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: "some host", CONF_HOST: "some host",
@ -117,7 +118,7 @@ async def test_user_form_invalid_auth(hass: HomeAssistant) -> None:
{CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"}, {CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
@ -137,7 +138,7 @@ async def test_user_form_cannot_connect(hass: HomeAssistant) -> None:
{CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"}, {CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -157,7 +158,7 @@ async def test_user_form_old_firmware(hass: HomeAssistant) -> None:
{CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"}, {CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "old_firmware"} assert result2["errors"] == {"base": "old_firmware"}
@ -205,7 +206,7 @@ async def test_user_form_one_entry_per_device_allowed(hass: HomeAssistant) -> No
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"
assert len(mock_setup_entry.mock_calls) == 0 assert len(mock_setup_entry.mock_calls) == 0
@ -228,7 +229,7 @@ async def test_zeroconf_form(hass: HomeAssistant) -> None:
type="mock_type", type="mock_type",
), ),
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -243,7 +244,7 @@ async def test_zeroconf_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "bond-name" assert result2["title"] == "bond-name"
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: "127.0.0.1", CONF_HOST: "127.0.0.1",
@ -270,7 +271,7 @@ async def test_zeroconf_form_token_unavailable(hass: HomeAssistant) -> None:
), ),
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -285,7 +286,7 @@ async def test_zeroconf_form_token_unavailable(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "bond-name" assert result2["title"] == "bond-name"
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: "127.0.0.1", CONF_HOST: "127.0.0.1",
@ -312,7 +313,7 @@ async def test_zeroconf_form_token_times_out(hass: HomeAssistant) -> None:
), ),
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -327,7 +328,7 @@ async def test_zeroconf_form_token_times_out(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "bond-name" assert result2["title"] == "bond-name"
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: "127.0.0.1", CONF_HOST: "127.0.0.1",
@ -359,7 +360,7 @@ async def test_zeroconf_form_with_token_available(hass: HomeAssistant) -> None:
), ),
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with _patch_async_setup_entry() as mock_setup_entry: with _patch_async_setup_entry() as mock_setup_entry:
@ -369,7 +370,7 @@ async def test_zeroconf_form_with_token_available(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "discovered-name" assert result2["title"] == "discovered-name"
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: "127.0.0.1", CONF_HOST: "127.0.0.1",
@ -403,7 +404,7 @@ async def test_zeroconf_form_with_token_available_name_unavailable(
), ),
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with _patch_async_setup_entry() as mock_setup_entry: with _patch_async_setup_entry() as mock_setup_entry:
@ -413,7 +414,7 @@ async def test_zeroconf_form_with_token_available_name_unavailable(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "ZXXX12345" assert result2["title"] == "ZXXX12345"
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: "127.0.0.1", CONF_HOST: "127.0.0.1",
@ -448,7 +449,7 @@ async def test_zeroconf_already_configured(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert entry.data["host"] == "127.0.0.2" assert entry.data["host"] == "127.0.0.2"
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -486,7 +487,7 @@ async def test_zeroconf_in_setup_retry_state(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert entry.data["host"] == "127.0.0.2" assert entry.data["host"] == "127.0.0.2"
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -533,7 +534,7 @@ async def test_zeroconf_already_configured_refresh_token(hass: HomeAssistant) ->
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert entry.data["host"] == "127.0.0.2" assert entry.data["host"] == "127.0.0.2"
assert entry.data[CONF_ACCESS_TOKEN] == "discovered-token" assert entry.data[CONF_ACCESS_TOKEN] == "discovered-token"
@ -572,7 +573,7 @@ async def test_zeroconf_already_configured_no_reload_same_host(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert len(mock_setup_entry.mock_calls) == 0 assert len(mock_setup_entry.mock_calls) == 0
@ -618,7 +619,7 @@ async def _help_test_form_unexpected_error(
result["flow_id"], user_input result["flow_id"], user_input
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}

View file

@ -16,6 +16,7 @@ from homeassistant.components import zeroconf
from homeassistant.components.bosch_shc.config_flow import write_tls_asset from homeassistant.components.bosch_shc.config_flow import write_tls_asset
from homeassistant.components.bosch_shc.const import CONF_SHC_CERT, CONF_SHC_KEY, DOMAIN from homeassistant.components.bosch_shc.const import CONF_SHC_CERT, CONF_SHC_KEY, DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -40,7 +41,7 @@ async def test_form_user(hass: HomeAssistant, mock_zeroconf: None) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -65,7 +66,7 @@ async def test_form_user(hass: HomeAssistant, mock_zeroconf: None) -> None:
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "credentials" assert result2["step_id"] == "credentials"
assert result2["errors"] == {} assert result2["errors"] == {}
@ -92,7 +93,7 @@ async def test_form_user(hass: HomeAssistant, mock_zeroconf: None) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "shc012345" assert result3["title"] == "shc012345"
assert result3["data"] == { assert result3["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -125,7 +126,7 @@ async def test_form_get_info_connection_error(
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "user" assert result2["step_id"] == "user"
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -147,7 +148,7 @@ async def test_form_get_info_exception(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "user" assert result2["step_id"] == "user"
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
@ -179,7 +180,7 @@ async def test_form_pairing_error(hass: HomeAssistant, mock_zeroconf: None) -> N
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "credentials" assert result2["step_id"] == "credentials"
assert result2["errors"] == {} assert result2["errors"] == {}
@ -193,7 +194,7 @@ async def test_form_pairing_error(hass: HomeAssistant, mock_zeroconf: None) -> N
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "form" assert result3["type"] is FlowResultType.FORM
assert result3["step_id"] == "credentials" assert result3["step_id"] == "credentials"
assert result3["errors"] == {"base": "pairing_failed"} assert result3["errors"] == {"base": "pairing_failed"}
@ -225,7 +226,7 @@ async def test_form_user_invalid_auth(hass: HomeAssistant, mock_zeroconf: None)
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "credentials" assert result2["step_id"] == "credentials"
assert result2["errors"] == {} assert result2["errors"] == {}
@ -251,7 +252,7 @@ async def test_form_user_invalid_auth(hass: HomeAssistant, mock_zeroconf: None)
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "form" assert result3["type"] is FlowResultType.FORM
assert result3["step_id"] == "credentials" assert result3["step_id"] == "credentials"
assert result3["errors"] == {"base": "invalid_auth"} assert result3["errors"] == {"base": "invalid_auth"}
@ -285,7 +286,7 @@ async def test_form_validate_connection_error(
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "credentials" assert result2["step_id"] == "credentials"
assert result2["errors"] == {} assert result2["errors"] == {}
@ -311,7 +312,7 @@ async def test_form_validate_connection_error(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "form" assert result3["type"] is FlowResultType.FORM
assert result3["step_id"] == "credentials" assert result3["step_id"] == "credentials"
assert result3["errors"] == {"base": "cannot_connect"} assert result3["errors"] == {"base": "cannot_connect"}
@ -345,7 +346,7 @@ async def test_form_validate_session_error(
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "credentials" assert result2["step_id"] == "credentials"
assert result2["errors"] == {} assert result2["errors"] == {}
@ -371,7 +372,7 @@ async def test_form_validate_session_error(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "form" assert result3["type"] is FlowResultType.FORM
assert result3["step_id"] == "credentials" assert result3["step_id"] == "credentials"
assert result3["errors"] == {"base": "session_error"} assert result3["errors"] == {"base": "session_error"}
@ -405,7 +406,7 @@ async def test_form_validate_exception(
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "credentials" assert result2["step_id"] == "credentials"
assert result2["errors"] == {} assert result2["errors"] == {}
@ -431,7 +432,7 @@ async def test_form_validate_exception(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "form" assert result3["type"] is FlowResultType.FORM
assert result3["step_id"] == "credentials" assert result3["step_id"] == "credentials"
assert result3["errors"] == {"base": "unknown"} assert result3["errors"] == {"base": "unknown"}
@ -471,7 +472,7 @@ async def test_form_already_configured(
{"host": "1.1.1.1"}, {"host": "1.1.1.1"},
) )
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"
# Test config entry got updated with latest IP # Test config entry got updated with latest IP
@ -502,7 +503,7 @@ async def test_zeroconf(hass: HomeAssistant, mock_zeroconf: None) -> None:
data=DISCOVERY_INFO, data=DISCOVERY_INFO,
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm_discovery" assert result["step_id"] == "confirm_discovery"
assert result["errors"] == {} assert result["errors"] == {}
context = next( context = next(
@ -516,7 +517,7 @@ async def test_zeroconf(hass: HomeAssistant, mock_zeroconf: None) -> None:
result["flow_id"], result["flow_id"],
{}, {},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "credentials" assert result2["step_id"] == "credentials"
with ( with (
@ -544,7 +545,7 @@ async def test_zeroconf(hass: HomeAssistant, mock_zeroconf: None) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "shc012345" assert result3["title"] == "shc012345"
assert result3["data"] == { assert result3["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -588,7 +589,7 @@ async def test_zeroconf_already_configured(
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
# Test config entry got updated with latest IP # Test config entry got updated with latest IP
@ -607,7 +608,7 @@ async def test_zeroconf_cannot_connect(
data=DISCOVERY_INFO, data=DISCOVERY_INFO,
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -626,7 +627,7 @@ async def test_zeroconf_not_bosch_shc(hass: HomeAssistant, mock_zeroconf: None)
), ),
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_bosch_shc" assert result["reason"] == "not_bosch_shc"
@ -650,7 +651,7 @@ async def test_reauth(hass: HomeAssistant, mock_zeroconf: None) -> None:
context={"source": config_entries.SOURCE_REAUTH}, context={"source": config_entries.SOURCE_REAUTH},
data=mock_config.data, data=mock_config.data,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm" assert result["step_id"] == "reauth_confirm"
with ( with (
@ -674,7 +675,7 @@ async def test_reauth(hass: HomeAssistant, mock_zeroconf: None) -> None:
{"host": "2.2.2.2"}, {"host": "2.2.2.2"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "credentials" assert result2["step_id"] == "credentials"
assert result2["errors"] == {} assert result2["errors"] == {}
@ -701,7 +702,7 @@ async def test_reauth(hass: HomeAssistant, mock_zeroconf: None) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "abort" assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "reauth_successful" assert result3["reason"] == "reauth_successful"
assert mock_config.data["host"] == "2.2.2.2" assert mock_config.data["host"] == "2.2.2.2"

View file

@ -86,7 +86,7 @@ async def test_flow_user_init_data_unknown_error_and_recover(
user_input=MOCK_DATA_STEP, user_input=MOCK_DATA_STEP,
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["result"].title == MOCK_DATA_STEP["email"] assert result["result"].title == MOCK_DATA_STEP["email"]
assert result["data"] == MOCK_DATA_STEP assert result["data"] == MOCK_DATA_STEP

View file

@ -11,6 +11,7 @@ from homeassistant import config_entries
from homeassistant.components import dhcp from homeassistant.components import dhcp
from homeassistant.components.broadlink.const import DOMAIN from homeassistant.components.broadlink.const import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import get_device from . import get_device
@ -42,7 +43,7 @@ async def test_flow_user_works(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -52,7 +53,7 @@ async def test_flow_user_works(hass: HomeAssistant) -> None:
{"host": device.host, "timeout": device.timeout}, {"host": device.host, "timeout": device.timeout},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "finish" assert result["step_id"] == "finish"
assert result["errors"] == {} assert result["errors"] == {}
@ -61,7 +62,7 @@ async def test_flow_user_works(hass: HomeAssistant) -> None:
{"name": device.name}, {"name": device.name},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == device.name assert result["title"] == device.name
assert result["data"] == device.get_entry_data() assert result["data"] == device.get_entry_data()
@ -93,7 +94,7 @@ async def test_flow_user_already_in_progress(hass: HomeAssistant) -> None:
{"host": device.host, "timeout": device.timeout}, {"host": device.host, "timeout": device.timeout},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress" assert result["reason"] == "already_in_progress"
@ -120,7 +121,7 @@ async def test_flow_user_mac_already_configured(hass: HomeAssistant) -> None:
{"host": device.host, "timeout": device.timeout}, {"host": device.host, "timeout": device.timeout},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert dict(mock_entry.data) == device.get_entry_data() assert dict(mock_entry.data) == device.get_entry_data()
@ -139,7 +140,7 @@ async def test_flow_user_invalid_ip_address(hass: HomeAssistant) -> None:
{"host": "0.0.0.1"}, {"host": "0.0.0.1"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {"base": "invalid_host"} assert result["errors"] == {"base": "invalid_host"}
@ -156,7 +157,7 @@ async def test_flow_user_invalid_hostname(hass: HomeAssistant) -> None:
{"host": "pancakemaster.local"}, {"host": "pancakemaster.local"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {"base": "invalid_host"} assert result["errors"] == {"base": "invalid_host"}
@ -175,7 +176,7 @@ async def test_flow_user_device_not_found(hass: HomeAssistant) -> None:
{"host": device.host}, {"host": device.host},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -195,7 +196,7 @@ async def test_flow_user_device_not_supported(hass: HomeAssistant) -> None:
{"host": device.host}, {"host": device.host},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported" assert result["reason"] == "not_supported"
@ -211,7 +212,7 @@ async def test_flow_user_network_unreachable(hass: HomeAssistant) -> None:
{"host": "192.168.1.32"}, {"host": "192.168.1.32"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -228,7 +229,7 @@ async def test_flow_user_os_error(hass: HomeAssistant) -> None:
{"host": "192.168.1.32"}, {"host": "192.168.1.32"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {"base": "unknown"} assert result["errors"] == {"base": "unknown"}
@ -249,7 +250,7 @@ async def test_flow_auth_authentication_error(hass: HomeAssistant) -> None:
{"host": device.host, "timeout": device.timeout}, {"host": device.host, "timeout": device.timeout},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reset" assert result["step_id"] == "reset"
assert result["errors"] == {"base": "invalid_auth"} assert result["errors"] == {"base": "invalid_auth"}
@ -270,7 +271,7 @@ async def test_flow_auth_network_timeout(hass: HomeAssistant) -> None:
{"host": device.host}, {"host": device.host},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "auth" assert result["step_id"] == "auth"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -291,7 +292,7 @@ async def test_flow_auth_firmware_error(hass: HomeAssistant) -> None:
{"host": device.host}, {"host": device.host},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "auth" assert result["step_id"] == "auth"
assert result["errors"] == {"base": "unknown"} assert result["errors"] == {"base": "unknown"}
@ -312,7 +313,7 @@ async def test_flow_auth_network_unreachable(hass: HomeAssistant) -> None:
{"host": device.host}, {"host": device.host},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "auth" assert result["step_id"] == "auth"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -333,7 +334,7 @@ async def test_flow_auth_os_error(hass: HomeAssistant) -> None:
{"host": device.host}, {"host": device.host},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "auth" assert result["step_id"] == "auth"
assert result["errors"] == {"base": "unknown"} assert result["errors"] == {"base": "unknown"}
@ -365,7 +366,7 @@ async def test_flow_reset_works(hass: HomeAssistant) -> None:
{"name": device.name}, {"name": device.name},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == device.name assert result["title"] == device.name
assert result["data"] == device.get_entry_data() assert result["data"] == device.get_entry_data()
@ -386,7 +387,7 @@ async def test_flow_unlock_works(hass: HomeAssistant) -> None:
{"host": device.host, "timeout": device.timeout}, {"host": device.host, "timeout": device.timeout},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "unlock" assert result["step_id"] == "unlock"
assert result["errors"] == {} assert result["errors"] == {}
@ -400,7 +401,7 @@ async def test_flow_unlock_works(hass: HomeAssistant) -> None:
{"name": device.name}, {"name": device.name},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == device.name assert result["title"] == device.name
assert result["data"] == device.get_entry_data() assert result["data"] == device.get_entry_data()
@ -430,7 +431,7 @@ async def test_flow_unlock_network_timeout(hass: HomeAssistant) -> None:
{"unlock": True}, {"unlock": True},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "unlock" assert result["step_id"] == "unlock"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -457,7 +458,7 @@ async def test_flow_unlock_firmware_error(hass: HomeAssistant) -> None:
{"unlock": True}, {"unlock": True},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "unlock" assert result["step_id"] == "unlock"
assert result["errors"] == {"base": "unknown"} assert result["errors"] == {"base": "unknown"}
@ -484,7 +485,7 @@ async def test_flow_unlock_network_unreachable(hass: HomeAssistant) -> None:
{"unlock": True}, {"unlock": True},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "unlock" assert result["step_id"] == "unlock"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -511,7 +512,7 @@ async def test_flow_unlock_os_error(hass: HomeAssistant) -> None:
{"unlock": True}, {"unlock": True},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "unlock" assert result["step_id"] == "unlock"
assert result["errors"] == {"base": "unknown"} assert result["errors"] == {"base": "unknown"}
@ -542,7 +543,7 @@ async def test_flow_do_not_unlock(hass: HomeAssistant) -> None:
{"name": device.name}, {"name": device.name},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == device.name assert result["title"] == device.name
assert result["data"] == device.get_entry_data() assert result["data"] == device.get_entry_data()
@ -561,7 +562,7 @@ async def test_flow_import_works(hass: HomeAssistant) -> None:
data={"host": device.host}, data={"host": device.host},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "finish" assert result["step_id"] == "finish"
assert result["errors"] == {} assert result["errors"] == {}
@ -570,7 +571,7 @@ async def test_flow_import_works(hass: HomeAssistant) -> None:
{"name": device.name}, {"name": device.name},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == device.name assert result["title"] == device.name
assert result["data"]["host"] == device.host assert result["data"]["host"] == device.host
assert result["data"]["mac"] == device.mac assert result["data"]["mac"] == device.mac
@ -595,7 +596,7 @@ async def test_flow_import_already_in_progress(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=data DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=data
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress" assert result["reason"] == "already_in_progress"
@ -613,7 +614,7 @@ async def test_flow_import_host_already_configured(hass: HomeAssistant) -> None:
data={"host": device.host}, data={"host": device.host},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -636,7 +637,7 @@ async def test_flow_import_mac_already_configured(hass: HomeAssistant) -> None:
data={"host": device.host}, data={"host": device.host},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert mock_entry.data["host"] == device.host assert mock_entry.data["host"] == device.host
@ -654,7 +655,7 @@ async def test_flow_import_device_not_found(hass: HomeAssistant) -> None:
data={"host": "192.168.1.32"}, data={"host": "192.168.1.32"},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -670,7 +671,7 @@ async def test_flow_import_device_not_supported(hass: HomeAssistant) -> None:
data={"host": device.host}, data={"host": device.host},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported" assert result["reason"] == "not_supported"
@ -683,7 +684,7 @@ async def test_flow_import_invalid_ip_address(hass: HomeAssistant) -> None:
data={"host": "0.0.0.1"}, data={"host": "0.0.0.1"},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_host" assert result["reason"] == "invalid_host"
@ -696,7 +697,7 @@ async def test_flow_import_invalid_hostname(hass: HomeAssistant) -> None:
data={"host": "hotdog.local"}, data={"host": "hotdog.local"},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_host" assert result["reason"] == "invalid_host"
@ -709,7 +710,7 @@ async def test_flow_import_network_unreachable(hass: HomeAssistant) -> None:
data={"host": "192.168.1.64"}, data={"host": "192.168.1.64"},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -722,7 +723,7 @@ async def test_flow_import_os_error(hass: HomeAssistant) -> None:
data={"host": "192.168.1.64"}, data={"host": "192.168.1.64"},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown" assert result["reason"] == "unknown"
@ -740,7 +741,7 @@ async def test_flow_reauth_works(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=data DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=data
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reset" assert result["step_id"] == "reset"
mock_api = device.get_mock_api() mock_api = device.get_mock_api()
@ -751,7 +752,7 @@ async def test_flow_reauth_works(hass: HomeAssistant) -> None:
{"host": device.host, "timeout": device.timeout}, {"host": device.host, "timeout": device.timeout},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert dict(mock_entry.data) == device.get_entry_data() assert dict(mock_entry.data) == device.get_entry_data()
@ -785,7 +786,7 @@ async def test_flow_reauth_invalid_host(hass: HomeAssistant) -> None:
{"host": device.host, "timeout": device.timeout}, {"host": device.host, "timeout": device.timeout},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {"base": "invalid_host"} assert result["errors"] == {"base": "invalid_host"}
@ -819,7 +820,7 @@ async def test_flow_reauth_valid_host(hass: HomeAssistant) -> None:
{"host": device.host, "timeout": device.timeout}, {"host": device.host, "timeout": device.timeout},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert mock_entry.data["host"] == device.host assert mock_entry.data["host"] == device.host
@ -846,7 +847,7 @@ async def test_dhcp_can_finish(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "finish" assert result["step_id"] == "finish"
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
@ -855,7 +856,7 @@ async def test_dhcp_can_finish(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Living Room" assert result2["title"] == "Living Room"
assert result2["data"] == { assert result2["data"] == {
"host": "1.2.3.4", "host": "1.2.3.4",
@ -880,7 +881,7 @@ async def test_dhcp_fails_to_connect(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -899,7 +900,7 @@ async def test_dhcp_unreachable(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -918,7 +919,7 @@ async def test_dhcp_connect_unknown_error(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown" assert result["reason"] == "unknown"
@ -939,7 +940,7 @@ async def test_dhcp_device_not_supported(hass: HomeAssistant) -> None:
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported" assert result["reason"] == "not_supported"
@ -964,7 +965,7 @@ async def test_dhcp_already_exists(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -989,6 +990,6 @@ async def test_dhcp_updates_host(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert mock_entry.data["host"] == "4.5.6.7" assert mock_entry.data["host"] == "4.5.6.7"

View file

@ -24,7 +24,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=None DOMAIN, context={"source": config_entries.SOURCE_USER}, data=None
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
with patch( with patch(

View file

@ -22,7 +22,7 @@ async def test_config_flow_setup_(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -31,7 +31,7 @@ async def test_config_flow_setup_(hass: HomeAssistant) -> None:
{CONF_LATITUDE: TEST_LATITUDE, CONF_LONGITUDE: TEST_LONGITUDE}, {CONF_LATITUDE: TEST_LATITUDE, CONF_LONGITUDE: TEST_LONGITUDE},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"{TEST_LATITUDE},{TEST_LONGITUDE}" assert result["title"] == f"{TEST_LATITUDE},{TEST_LONGITUDE}"
assert result["data"] == { assert result["data"] == {
CONF_LATITUDE: TEST_LATITUDE, CONF_LATITUDE: TEST_LATITUDE,
@ -55,7 +55,7 @@ async def test_config_flow_already_configured_weather(hass: HomeAssistant) -> No
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -64,7 +64,7 @@ async def test_config_flow_already_configured_weather(hass: HomeAssistant) -> No
{CONF_LATITUDE: TEST_LATITUDE, CONF_LONGITUDE: TEST_LONGITUDE}, {CONF_LATITUDE: TEST_LATITUDE, CONF_LONGITUDE: TEST_LONGITUDE},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -85,7 +85,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
result = await hass.config_entries.options.async_init(entry.entry_id) result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(

View file

@ -113,7 +113,7 @@ async def test_reauth_success(
"entry_id": config_entry.entry_id, "entry_id": config_entry.entry_id,
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm" assert result["step_id"] == "reauth_confirm"
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
@ -154,7 +154,7 @@ async def test_reauth_failure(
"entry_id": config_entry.entry_id, "entry_id": config_entry.entry_id,
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm" assert result["step_id"] == "reauth_confirm"
dav_client.return_value.principal.side_effect = DAVError dav_client.return_value.principal.side_effect = DAVError

View file

@ -55,7 +55,7 @@ async def test_single_instance(hass: HomeAssistant, source) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
"cast", context={"source": source} "cast", context={"source": source}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "single_instance_allowed" assert result["reason"] == "single_instance_allowed"
@ -64,13 +64,13 @@ async def test_user_setup(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
"cast", context={"source": config_entries.SOURCE_USER} "cast", context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
users = await hass.auth.async_get_users() users = await hass.auth.async_get_users()
assert next(user for user in users if user.name == CAST_USER_NAME) assert next(user for user in users if user.name == CAST_USER_NAME)
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["result"].data == { assert result["result"].data == {
"ignore_cec": [], "ignore_cec": [],
"known_hosts": [], "known_hosts": [],
@ -84,7 +84,7 @@ async def test_user_setup_options(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
"cast", context={"source": config_entries.SOURCE_USER} "cast", context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"known_hosts": "192.168.0.1, , 192.168.0.2 "} result["flow_id"], {"known_hosts": "192.168.0.1, , 192.168.0.2 "}
@ -92,7 +92,7 @@ async def test_user_setup_options(hass: HomeAssistant) -> None:
users = await hass.auth.async_get_users() users = await hass.auth.async_get_users()
assert next(user for user in users if user.name == CAST_USER_NAME) assert next(user for user in users if user.name == CAST_USER_NAME)
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["result"].data == { assert result["result"].data == {
"ignore_cec": [], "ignore_cec": [],
"known_hosts": ["192.168.0.1", "192.168.0.2"], "known_hosts": ["192.168.0.1", "192.168.0.2"],
@ -106,13 +106,13 @@ async def test_zeroconf_setup(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
"cast", context={"source": config_entries.SOURCE_ZEROCONF} "cast", context={"source": config_entries.SOURCE_ZEROCONF}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
users = await hass.auth.async_get_users() users = await hass.auth.async_get_users()
assert next(user for user in users if user.name == CAST_USER_NAME) assert next(user for user in users if user.name == CAST_USER_NAME)
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["result"].data == { assert result["result"].data == {
"ignore_cec": [], "ignore_cec": [],
"known_hosts": [], "known_hosts": [],
@ -132,7 +132,7 @@ async def test_zeroconf_setup_onboarding(hass: HomeAssistant) -> None:
users = await hass.auth.async_get_users() users = await hass.auth.async_get_users()
assert next(user for user in users if user.name == CAST_USER_NAME) assert next(user for user in users if user.name == CAST_USER_NAME)
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["result"].data == { assert result["result"].data == {
"ignore_cec": [], "ignore_cec": [],
"known_hosts": [], "known_hosts": [],
@ -278,7 +278,7 @@ async def test_known_hosts(hass: HomeAssistant, castbrowser_mock) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"known_hosts": "192.168.0.1, 192.168.0.2"} result["flow_id"], {"known_hosts": "192.168.0.1, 192.168.0.2"}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
await hass.async_block_till_done(wait_background_tasks=True) await hass.async_block_till_done(wait_background_tasks=True)
config_entry = hass.config_entries.async_entries("cast")[0] config_entry = hass.config_entries.async_entries("cast")[0]

View file

@ -4,6 +4,7 @@ from unittest.mock import patch
from homeassistant.components.cloud.const import DOMAIN from homeassistant.components.cloud.const import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -23,7 +24,7 @@ async def test_config_flow(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "system"} DOMAIN, context={"source": "system"}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Home Assistant Cloud" assert result["title"] == "Home Assistant Cloud"
assert result["data"] == {} assert result["data"] == {}
await hass.async_block_till_done() await hass.async_block_till_done()
@ -40,5 +41,5 @@ async def test_multiple_entries(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "system"} DOMAIN, context={"source": "system"}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "single_instance_allowed" assert result["reason"] == "single_instance_allowed"

View file

@ -16,6 +16,7 @@ from homeassistant.components.coinbase.const import (
) )
from homeassistant.const import CONF_API_KEY, CONF_API_TOKEN from homeassistant.const import CONF_API_KEY, CONF_API_TOKEN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .common import ( from .common import (
init_mock_coinbase, init_mock_coinbase,
@ -32,7 +33,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -59,7 +60,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Test User" assert result2["title"] == "Test User"
assert result2["data"] == {CONF_API_KEY: "123456", CONF_API_TOKEN: "AbCDeF"} assert result2["data"] == {CONF_API_KEY: "123456", CONF_API_TOKEN: "AbCDeF"}
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -95,7 +96,7 @@ async def test_form_invalid_auth(
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
assert "Coinbase rejected API credentials due to an unknown error" in caplog.text assert "Coinbase rejected API credentials due to an unknown error" in caplog.text
@ -117,7 +118,7 @@ async def test_form_invalid_auth(
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth_key"} assert result2["errors"] == {"base": "invalid_auth_key"}
assert "Coinbase rejected API credentials due to an invalid API key" in caplog.text assert "Coinbase rejected API credentials due to an invalid API key" in caplog.text
@ -139,7 +140,7 @@ async def test_form_invalid_auth(
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth_secret"} assert result2["errors"] == {"base": "invalid_auth_secret"}
assert ( assert (
"Coinbase rejected API credentials due to an invalid API secret" in caplog.text "Coinbase rejected API credentials due to an invalid API secret" in caplog.text
@ -164,7 +165,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -186,7 +187,7 @@ async def test_form_catch_all_exception(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
@ -219,7 +220,7 @@ async def test_option_form(hass: HomeAssistant) -> None:
CONF_EXCHANGE_PRECISION: 5, CONF_EXCHANGE_PRECISION: 5,
}, },
) )
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(mock_update_listener.mock_calls) == 1 assert len(mock_update_listener.mock_calls) == 1
@ -249,7 +250,7 @@ async def test_form_bad_account_currency(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "currency_unavailable"} assert result2["errors"] == {"base": "currency_unavailable"}
@ -277,7 +278,7 @@ async def test_form_bad_exchange_rate(hass: HomeAssistant) -> None:
CONF_EXCHANGE_PRECISION: 5, CONF_EXCHANGE_PRECISION: 5,
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "exchange_rate_unavailable"} assert result2["errors"] == {"base": "exchange_rate_unavailable"}
@ -311,5 +312,5 @@ async def test_option_catch_all_exception(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}

View file

@ -15,6 +15,7 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -48,7 +49,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
c4_account = _get_mock_c4_account() c4_account = _get_mock_c4_account()
@ -77,7 +78,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "control4_model_00AA00AA00AA" assert result2["title"] == "control4_model_00AA00AA00AA"
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: "1.1.1.1", CONF_HOST: "1.1.1.1",
@ -107,7 +108,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
@ -130,7 +131,7 @@ async def test_form_unexpected_exception(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
@ -159,7 +160,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -170,14 +171,14 @@ async def test_option_flow(hass: HomeAssistant) -> None:
result = await hass.config_entries.options.async_init(entry.entry_id) result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], result["flow_id"],
user_input={CONF_SCAN_INTERVAL: 4}, user_input={CONF_SCAN_INTERVAL: 4},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
CONF_SCAN_INTERVAL: 4, CONF_SCAN_INTERVAL: 4,
} }
@ -190,13 +191,13 @@ async def test_option_flow_defaults(hass: HomeAssistant) -> None:
result = await hass.config_entries.options.async_init(entry.entry_id) result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
CONF_SCAN_INTERVAL: DEFAULT_SCAN_INTERVAL, CONF_SCAN_INTERVAL: DEFAULT_SCAN_INTERVAL,
} }

View file

@ -6,6 +6,7 @@ from homeassistant import config_entries
from homeassistant.components.coolmaster.config_flow import AVAILABLE_MODES from homeassistant.components.coolmaster.config_flow import AVAILABLE_MODES
from homeassistant.components.coolmaster.const import DOMAIN from homeassistant.components.coolmaster.const import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
def _flow_data(): def _flow_data():
@ -21,7 +22,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
with ( with (
@ -39,7 +40,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "1.1.1.1" assert result2["title"] == "1.1.1.1"
assert result2["data"] == { assert result2["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -64,7 +65,7 @@ async def test_form_timeout(hass: HomeAssistant) -> None:
result["flow_id"], _flow_data() result["flow_id"], _flow_data()
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -82,7 +83,7 @@ async def test_form_connection_refused(hass: HomeAssistant) -> None:
result["flow_id"], _flow_data() result["flow_id"], _flow_data()
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -100,5 +101,5 @@ async def test_form_no_units(hass: HomeAssistant) -> None:
result["flow_id"], _flow_data() result["flow_id"], _flow_data()
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "no_units"} assert result2["errors"] == {"base": "no_units"}

View file

@ -92,7 +92,7 @@ async def test_config_flow_manual_host_success(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -101,7 +101,7 @@ async def test_config_flow_manual_host_success(hass: HomeAssistant) -> None:
{CONF_HOST: TEST_HOST}, {CONF_HOST: TEST_HOST},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_NAME assert result["title"] == TEST_NAME
assert result["data"] == { assert result["data"] == {
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
@ -122,7 +122,7 @@ async def test_config_flow_manual_discover_1_success(hass: HomeAssistant) -> Non
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -135,7 +135,7 @@ async def test_config_flow_manual_discover_1_success(hass: HomeAssistant) -> Non
{}, {},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_NAME assert result["title"] == TEST_NAME
assert result["data"] == { assert result["data"] == {
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
@ -156,7 +156,7 @@ async def test_config_flow_manual_discover_2_success(hass: HomeAssistant) -> Non
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -169,7 +169,7 @@ async def test_config_flow_manual_discover_2_success(hass: HomeAssistant) -> Non
{}, {},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "select" assert result["step_id"] == "select"
assert result["errors"] == {} assert result["errors"] == {}
@ -178,7 +178,7 @@ async def test_config_flow_manual_discover_2_success(hass: HomeAssistant) -> Non
{"select_host": TEST_HOST2}, {"select_host": TEST_HOST2},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_NAME assert result["title"] == TEST_NAME
assert result["data"] == { assert result["data"] == {
CONF_HOST: TEST_HOST2, CONF_HOST: TEST_HOST2,
@ -199,7 +199,7 @@ async def test_config_flow_manual_discover_error(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -212,7 +212,7 @@ async def test_config_flow_manual_discover_error(hass: HomeAssistant) -> None:
{}, {},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {"base": "discovery_error"} assert result["errors"] == {"base": "discovery_error"}
@ -226,7 +226,7 @@ async def test_config_flow_manual_host_no_serial(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -239,7 +239,7 @@ async def test_config_flow_manual_host_no_serial(hass: HomeAssistant) -> None:
{CONF_HOST: TEST_HOST}, {CONF_HOST: TEST_HOST},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_NAME assert result["title"] == TEST_NAME
assert result["data"] == { assert result["data"] == {
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
@ -259,7 +259,7 @@ async def test_config_flow_manual_host_connection_error(hass: HomeAssistant) ->
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -278,7 +278,7 @@ async def test_config_flow_manual_host_connection_error(hass: HomeAssistant) ->
{CONF_HOST: TEST_HOST}, {CONF_HOST: TEST_HOST},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -291,7 +291,7 @@ async def test_config_flow_manual_host_no_device_info(hass: HomeAssistant) -> No
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -304,7 +304,7 @@ async def test_config_flow_manual_host_no_device_info(hass: HomeAssistant) -> No
{CONF_HOST: TEST_HOST}, {CONF_HOST: TEST_HOST},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -325,7 +325,7 @@ async def test_config_flow_ssdp(hass: HomeAssistant) -> None:
), ),
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm" assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -333,7 +333,7 @@ async def test_config_flow_ssdp(hass: HomeAssistant) -> None:
{}, {},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_NAME assert result["title"] == TEST_NAME
assert result["data"] == { assert result["data"] == {
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
@ -365,7 +365,7 @@ async def test_config_flow_ssdp_not_denon(hass: HomeAssistant) -> None:
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_denonavr_manufacturer" assert result["reason"] == "not_denonavr_manufacturer"
@ -387,7 +387,7 @@ async def test_config_flow_ssdp_missing_info(hass: HomeAssistant) -> None:
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_denonavr_missing" assert result["reason"] == "not_denonavr_missing"
@ -411,7 +411,7 @@ async def test_config_flow_ssdp_ignored_model(hass: HomeAssistant) -> None:
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_denonavr_manufacturer" assert result["reason"] == "not_denonavr_manufacturer"
@ -471,7 +471,7 @@ async def test_config_flow_manual_host_no_serial_double_config(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -484,7 +484,7 @@ async def test_config_flow_manual_host_no_serial_double_config(
{CONF_HOST: TEST_HOST}, {CONF_HOST: TEST_HOST},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_NAME assert result["title"] == TEST_NAME
assert result["data"] == { assert result["data"] == {
CONF_HOST: TEST_HOST, CONF_HOST: TEST_HOST,
@ -498,7 +498,7 @@ async def test_config_flow_manual_host_no_serial_double_config(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -511,5 +511,5 @@ async def test_config_flow_manual_host_no_serial_double_config(
{CONF_HOST: TEST_HOST}, {CONF_HOST: TEST_HOST},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -111,7 +111,7 @@ async def test_zeroconf_devialet(
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=MOCK_ZEROCONF_DATA DOMAIN, context={"source": SOURCE_ZEROCONF}, data=MOCK_ZEROCONF_DATA
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
with patch( with patch(
"homeassistant.components.devialet.async_setup_entry", "homeassistant.components.devialet.async_setup_entry",
@ -123,7 +123,7 @@ async def test_zeroconf_devialet(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Livingroom" assert result2["title"] == "Livingroom"
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: HOST, CONF_HOST: HOST,
@ -140,7 +140,7 @@ async def test_async_step_confirm(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=MOCK_ZEROCONF_DATA DOMAIN, context={"source": SOURCE_ZEROCONF}, data=MOCK_ZEROCONF_DATA
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm" assert result["step_id"] == "confirm"
aioclient_mock.get( aioclient_mock.get(

View file

@ -95,7 +95,7 @@ async def test_form_advanced_options(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "devolo Home Control" assert result2["title"] == "devolo Home Control"
assert result2["data"] == { assert result2["data"] == {
"username": "test-username", "username": "test-username",
@ -286,7 +286,7 @@ async def _setup(hass: HomeAssistant, result: FlowResult) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "devolo Home Control" assert result2["title"] == "devolo Home Control"
assert result2["data"] == { assert result2["data"] == {
"username": "test-username", "username": "test-username",

View file

@ -32,7 +32,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["data_schema"] == DATA_SCHEMA assert result["data_schema"] == DATA_SCHEMA
assert result["errors"] == {} assert result["errors"] == {}

View file

@ -72,7 +72,7 @@ async def test_user_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "1.2.3.4" assert result2["title"] == "1.2.3.4"
assert result2["data"] == { assert result2["data"] == {
"host": "1.2.3.4", "host": "1.2.3.4",
@ -100,7 +100,7 @@ async def test_form_zeroconf_wrong_oui(hass: HomeAssistant) -> None:
type="mock_type", type="mock_type",
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_doorbird_device" assert result["reason"] == "not_doorbird_device"
@ -120,7 +120,7 @@ async def test_form_zeroconf_link_local_ignored(hass: HomeAssistant) -> None:
type="mock_type", type="mock_type",
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "link_local_address" assert result["reason"] == "link_local_address"
@ -147,7 +147,7 @@ async def test_form_zeroconf_ipv4_address(hass: HomeAssistant) -> None:
type="mock_type", type="mock_type",
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert config_entry.data[CONF_HOST] == "4.4.4.4" assert config_entry.data[CONF_HOST] == "4.4.4.4"
@ -168,7 +168,7 @@ async def test_form_zeroconf_non_ipv4_ignored(hass: HomeAssistant) -> None:
type="mock_type", type="mock_type",
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_ipv4_address" assert result["reason"] == "not_ipv4_address"
@ -219,7 +219,7 @@ async def test_form_zeroconf_correct_oui(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "1.2.3.4" assert result2["title"] == "1.2.3.4"
assert result2["data"] == { assert result2["data"] == {
"host": "1.2.3.4", "host": "1.2.3.4",
@ -307,7 +307,7 @@ async def test_form_user_invalid_auth(hass: HomeAssistant) -> None:
VALID_CONFIG, VALID_CONFIG,
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}

View file

@ -24,7 +24,7 @@ async def test_mqtt_setup(hass: HomeAssistant, mqtt_mock: MqttMockHAClient) -> N
data=discovery_info, data=discovery_info,
) )
assert result is not None assert result is not None
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm" assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -61,7 +61,7 @@ async def test_duplicate(hass: HomeAssistant, mqtt_mock: MqttMockHAClient) -> No
data=discovery_info, data=discovery_info,
) )
assert result is not None assert result is not None
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm" assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -78,7 +78,7 @@ async def test_duplicate(hass: HomeAssistant, mqtt_mock: MqttMockHAClient) -> No
data=discovery_info, data=discovery_info,
) )
assert result is not None assert result is not None
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_discovery_info" assert result["reason"] == "invalid_discovery_info"
@ -100,7 +100,7 @@ async def test_mqtt_setup_incomplete_payload(
data=discovery_info, data=discovery_info,
) )
assert result is not None assert result is not None
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_discovery_info" assert result["reason"] == "invalid_discovery_info"
@ -122,7 +122,7 @@ async def test_mqtt_setup_bad_json(
data=discovery_info, data=discovery_info,
) )
assert result is not None assert result is not None
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_discovery_info" assert result["reason"] == "invalid_discovery_info"
@ -144,7 +144,7 @@ async def test_mqtt_setup_bad_topic(
data=discovery_info, data=discovery_info,
) )
assert result is not None assert result is not None
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_discovery_info" assert result["reason"] == "invalid_discovery_info"
@ -166,7 +166,7 @@ async def test_mqtt_setup_no_payload(
data=discovery_info, data=discovery_info,
) )
assert result is not None assert result is not None
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_discovery_info" assert result["reason"] == "invalid_discovery_info"
@ -175,5 +175,5 @@ async def test_user_setup(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
"drop_connect", context={"source": config_entries.SOURCE_USER} "drop_connect", context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported" assert result["reason"] == "not_supported"

View file

@ -39,7 +39,7 @@ async def test_setup_network(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] is None assert result["errors"] is None
@ -48,7 +48,7 @@ async def test_setup_network(
{"type": "Network"}, {"type": "Network"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "setup_network" assert result["step_id"] == "setup_network"
assert result["errors"] == {} assert result["errors"] == {}
@ -70,7 +70,7 @@ async def test_setup_network(
"protocol": "dsmr_protocol", "protocol": "dsmr_protocol",
} }
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "10.10.0.1:1234" assert result["title"] == "10.10.0.1:1234"
assert result["data"] == {**entry_data, **SERIAL_DATA} assert result["data"] == {**entry_data, **SERIAL_DATA}
@ -87,7 +87,7 @@ async def test_setup_network_rfxtrx(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] is None assert result["errors"] is None
@ -96,7 +96,7 @@ async def test_setup_network_rfxtrx(
{"type": "Network"}, {"type": "Network"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "setup_network" assert result["step_id"] == "setup_network"
assert result["errors"] == {} assert result["errors"] == {}
@ -121,7 +121,7 @@ async def test_setup_network_rfxtrx(
"protocol": "rfxtrx_dsmr_protocol", "protocol": "rfxtrx_dsmr_protocol",
} }
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "10.10.0.1:1234" assert result["title"] == "10.10.0.1:1234"
assert result["data"] == {**entry_data, **SERIAL_DATA} assert result["data"] == {**entry_data, **SERIAL_DATA}
@ -237,7 +237,7 @@ async def test_setup_serial_rfxtrx(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] is None assert result["errors"] is None
@ -246,7 +246,7 @@ async def test_setup_serial_rfxtrx(
{"type": "Serial"}, {"type": "Serial"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "setup_serial" assert result["step_id"] == "setup_serial"
assert result["errors"] == {} assert result["errors"] == {}
@ -266,7 +266,7 @@ async def test_setup_serial_rfxtrx(
"protocol": "rfxtrx_dsmr_protocol", "protocol": "rfxtrx_dsmr_protocol",
} }
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == port.device assert result["title"] == port.device
assert result["data"] == {**entry_data, **SERIAL_DATA} assert result["data"] == {**entry_data, **SERIAL_DATA}
@ -280,7 +280,7 @@ async def test_setup_serial_manual(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] is None assert result["errors"] is None
@ -289,7 +289,7 @@ async def test_setup_serial_manual(
{"type": "Serial"}, {"type": "Serial"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "setup_serial" assert result["step_id"] == "setup_serial"
assert result["errors"] == {} assert result["errors"] == {}
@ -298,7 +298,7 @@ async def test_setup_serial_manual(
{"port": "Enter Manually", "dsmr_version": "2.2"}, {"port": "Enter Manually", "dsmr_version": "2.2"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "setup_serial_manual_path" assert result["step_id"] == "setup_serial_manual_path"
assert result["errors"] is None assert result["errors"] is None
@ -314,7 +314,7 @@ async def test_setup_serial_manual(
"protocol": "dsmr_protocol", "protocol": "dsmr_protocol",
} }
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "/dev/ttyUSB0" assert result["title"] == "/dev/ttyUSB0"
assert result["data"] == {**entry_data, **SERIAL_DATA} assert result["data"] == {**entry_data, **SERIAL_DATA}
@ -338,7 +338,7 @@ async def test_setup_serial_fail(
side_effect=chain([serial.SerialException], repeat(DEFAULT)), side_effect=chain([serial.SerialException], repeat(DEFAULT)),
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] is None assert result["errors"] is None
@ -347,7 +347,7 @@ async def test_setup_serial_fail(
{"type": "Serial"}, {"type": "Serial"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "setup_serial" assert result["step_id"] == "setup_serial"
assert result["errors"] == {} assert result["errors"] == {}
@ -360,7 +360,7 @@ async def test_setup_serial_fail(
{"port": port.device, "dsmr_version": "2.2"}, {"port": port.device, "dsmr_version": "2.2"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "setup_serial" assert result["step_id"] == "setup_serial"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -398,7 +398,7 @@ async def test_setup_serial_timeout(
) )
rfxtrx_protocol.wait_closed = first_timeout_wait_closed rfxtrx_protocol.wait_closed = first_timeout_wait_closed
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] is None assert result["errors"] is None
@ -407,7 +407,7 @@ async def test_setup_serial_timeout(
{"type": "Serial"}, {"type": "Serial"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "setup_serial" assert result["step_id"] == "setup_serial"
assert result["errors"] == {} assert result["errors"] == {}
@ -416,7 +416,7 @@ async def test_setup_serial_timeout(
result["flow_id"], {"port": port.device, "dsmr_version": "2.2"} result["flow_id"], {"port": port.device, "dsmr_version": "2.2"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "setup_serial" assert result["step_id"] == "setup_serial"
assert result["errors"] == {"base": "cannot_communicate"} assert result["errors"] == {"base": "cannot_communicate"}
@ -442,7 +442,7 @@ async def test_setup_serial_wrong_telegram(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] is None assert result["errors"] is None
@ -451,7 +451,7 @@ async def test_setup_serial_wrong_telegram(
{"type": "Serial"}, {"type": "Serial"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "setup_serial" assert result["step_id"] == "setup_serial"
assert result["errors"] == {} assert result["errors"] == {}
@ -463,7 +463,7 @@ async def test_setup_serial_wrong_telegram(
{"port": port.device, "dsmr_version": "2.2"}, {"port": port.device, "dsmr_version": "2.2"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "setup_serial" assert result["step_id"] == "setup_serial"
assert result["errors"] == {"base": "cannot_communicate"} assert result["errors"] == {"base": "cannot_communicate"}
@ -485,7 +485,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
result = await hass.config_entries.options.async_init(entry.entry_id) result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(

View file

@ -8,6 +8,7 @@ from homeassistant import config_entries
from homeassistant.components import dynalite from homeassistant.components import dynalite
from homeassistant.const import CONF_PORT from homeassistant.const import CONF_PORT
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers.issue_registry import ( from homeassistant.helpers.issue_registry import (
IssueSeverity, IssueSeverity,
async_get as async_get_issue_registry, async_get as async_get_issue_registry,
@ -86,7 +87,7 @@ async def test_existing(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_IMPORT}, context={"source": config_entries.SOURCE_IMPORT},
data={dynalite.CONF_HOST: host}, data={dynalite.CONF_HOST: host},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -116,7 +117,7 @@ async def test_existing_update(hass: HomeAssistant) -> None:
await hass.async_block_till_done() await hass.async_block_till_done()
assert mock_dyn_dev().configure.call_count == 2 assert mock_dyn_dev().configure.call_count == 2
assert mock_dyn_dev().configure.mock_calls[1][1][0]["port"] == port2 assert mock_dyn_dev().configure.mock_calls[1][1][0]["port"] == port2
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -136,7 +137,7 @@ async def test_two_entries(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_IMPORT}, context={"source": config_entries.SOURCE_IMPORT},
data={dynalite.CONF_HOST: host2}, data={dynalite.CONF_HOST: host2},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["result"].state == config_entries.ConfigEntryState.LOADED assert result["result"].state == config_entries.ConfigEntryState.LOADED
@ -148,7 +149,7 @@ async def test_setup_user(hass):
dynalite.DOMAIN, context={"source": config_entries.SOURCE_USER} dynalite.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] is None assert result["errors"] is None
@ -161,7 +162,7 @@ async def test_setup_user(hass):
{"host": host, "port": port}, {"host": host, "port": port},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["result"].state == config_entries.ConfigEntryState.LOADED assert result["result"].state == config_entries.ConfigEntryState.LOADED
assert result["title"] == host assert result["title"] == host
assert result["data"] == { assert result["data"] == {
@ -188,5 +189,5 @@ async def test_setup_user_existing_host(hass):
{"host": host, "port": 1234}, {"host": host, "port": 1234},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -8,6 +8,7 @@ from voluptuous.error import Invalid
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.eafm import const from homeassistant.components.eafm import const
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
async def test_flow_no_discovered_stations( async def test_flow_no_discovered_stations(
@ -18,7 +19,7 @@ async def test_flow_no_discovered_stations(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
const.DOMAIN, context={"source": config_entries.SOURCE_USER} const.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_stations" assert result["reason"] == "no_stations"
@ -31,7 +32,7 @@ async def test_flow_invalid_station(hass: HomeAssistant, mock_get_stations) -> N
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
const.DOMAIN, context={"source": config_entries.SOURCE_USER} const.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
with pytest.raises(Invalid): with pytest.raises(Invalid):
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -53,14 +54,14 @@ async def test_flow_works(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
const.DOMAIN, context={"source": config_entries.SOURCE_USER} const.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
with patch("homeassistant.components.eafm.async_setup_entry", return_value=True): with patch("homeassistant.components.eafm.async_setup_entry", return_value=True):
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"station": "My station"} result["flow_id"], user_input={"station": "My station"}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "My station" assert result["title"] == "My station"
assert result["data"] == { assert result["data"] == {
"station": "L12345", "station": "L12345",

View file

@ -66,7 +66,7 @@ async def test_form_user_with_secure_elk_no_discovery(hass: HomeAssistant) -> No
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
assert result["step_id"] == "manual_connection" assert result["step_id"] == "manual_connection"
@ -95,7 +95,7 @@ async def test_form_user_with_secure_elk_no_discovery(hass: HomeAssistant) -> No
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "ElkM1" assert result2["title"] == "ElkM1"
assert result2["data"] == { assert result2["data"] == {
"auto_configure": True, "auto_configure": True,
@ -123,7 +123,7 @@ async def test_form_user_with_insecure_elk_skip_discovery(hass: HomeAssistant) -
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
assert result["step_id"] == "manual_connection" assert result["step_id"] == "manual_connection"
@ -152,7 +152,7 @@ async def test_form_user_with_insecure_elk_skip_discovery(hass: HomeAssistant) -
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "ElkM1" assert result2["title"] == "ElkM1"
assert result2["data"] == { assert result2["data"] == {
"auto_configure": True, "auto_configure": True,
@ -180,7 +180,7 @@ async def test_form_user_with_insecure_elk_no_discovery(hass: HomeAssistant) ->
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
assert result["step_id"] == "manual_connection" assert result["step_id"] == "manual_connection"
@ -209,7 +209,7 @@ async def test_form_user_with_insecure_elk_no_discovery(hass: HomeAssistant) ->
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "ElkM1" assert result2["title"] == "ElkM1"
assert result2["data"] == { assert result2["data"] == {
"auto_configure": True, "auto_configure": True,
@ -237,7 +237,7 @@ async def test_form_user_with_insecure_elk_times_out(hass: HomeAssistant) -> Non
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
assert result["step_id"] == "manual_connection" assert result["step_id"] == "manual_connection"
@ -285,7 +285,7 @@ async def test_form_user_with_secure_elk_no_discovery_ip_already_configured(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
assert result["step_id"] == "manual_connection" assert result["step_id"] == "manual_connection"
@ -317,7 +317,7 @@ async def test_form_user_with_secure_elk_with_discovery(hass: HomeAssistant) ->
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -350,7 +350,7 @@ async def test_form_user_with_secure_elk_with_discovery(hass: HomeAssistant) ->
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "ElkM1 ddeeff" assert result3["title"] == "ElkM1 ddeeff"
assert result3["data"] == { assert result3["data"] == {
"auto_configure": True, "auto_configure": True,
@ -375,7 +375,7 @@ async def test_form_user_with_secure_elk_with_discovery_pick_manual(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -411,7 +411,7 @@ async def test_form_user_with_secure_elk_with_discovery_pick_manual(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "ElkM1" assert result3["title"] == "ElkM1"
assert result3["data"] == { assert result3["data"] == {
"auto_configure": True, "auto_configure": True,
@ -436,7 +436,7 @@ async def test_form_user_with_secure_elk_with_discovery_pick_manual_direct_disco
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -472,7 +472,7 @@ async def test_form_user_with_secure_elk_with_discovery_pick_manual_direct_disco
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "ElkM1 ddeeff" assert result3["title"] == "ElkM1 ddeeff"
assert result3["data"] == { assert result3["data"] == {
"auto_configure": True, "auto_configure": True,
@ -495,7 +495,7 @@ async def test_form_user_with_tls_elk_no_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
assert result["step_id"] == "manual_connection" assert result["step_id"] == "manual_connection"
@ -524,7 +524,7 @@ async def test_form_user_with_tls_elk_no_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "ElkM1" assert result2["title"] == "ElkM1"
assert result2["data"] == { assert result2["data"] == {
"auto_configure": True, "auto_configure": True,
@ -546,7 +546,7 @@ async def test_form_user_with_non_secure_elk_no_discovery(hass: HomeAssistant) -
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
assert result["step_id"] == "manual_connection" assert result["step_id"] == "manual_connection"
@ -573,7 +573,7 @@ async def test_form_user_with_non_secure_elk_no_discovery(hass: HomeAssistant) -
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "guest_house" assert result2["title"] == "guest_house"
assert result2["data"] == { assert result2["data"] == {
"auto_configure": True, "auto_configure": True,
@ -595,7 +595,7 @@ async def test_form_user_with_serial_elk_no_discovery(hass: HomeAssistant) -> No
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
assert result["step_id"] == "manual_connection" assert result["step_id"] == "manual_connection"
@ -622,7 +622,7 @@ async def test_form_user_with_serial_elk_no_discovery(hass: HomeAssistant) -> No
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "ElkM1" assert result2["title"] == "ElkM1"
assert result2["data"] == { assert result2["data"] == {
"auto_configure": True, "auto_configure": True,
@ -667,7 +667,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -703,7 +703,7 @@ async def test_unknown_exception(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
@ -730,7 +730,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {CONF_PASSWORD: "invalid_auth"} assert result2["errors"] == {CONF_PASSWORD: "invalid_auth"}
@ -757,7 +757,7 @@ async def test_form_invalid_auth_no_password(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {CONF_PASSWORD: "invalid_auth"} assert result2["errors"] == {CONF_PASSWORD: "invalid_auth"}
@ -807,7 +807,7 @@ async def test_form_import(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "ohana" assert result["title"] == "ohana"
assert result["data"] == { assert result["data"] == {
@ -877,7 +877,7 @@ async def test_form_import_device_discovered(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "ohana" assert result["title"] == "ohana"
assert result["result"].unique_id == MOCK_MAC assert result["result"].unique_id == MOCK_MAC
assert result["data"] == { assert result["data"] == {
@ -929,7 +929,7 @@ async def test_form_import_non_secure_device_discovered(hass: HomeAssistant) ->
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "ohana" assert result["title"] == "ohana"
assert result["result"].unique_id == MOCK_MAC assert result["result"].unique_id == MOCK_MAC
assert result["data"] == { assert result["data"] == {
@ -973,7 +973,7 @@ async def test_form_import_non_secure_non_stanadard_port_device_discovered(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "ohana" assert result["title"] == "ohana"
assert result["result"].unique_id == MOCK_MAC assert result["result"].unique_id == MOCK_MAC
assert result["data"] == { assert result["data"] == {
@ -1007,7 +1007,7 @@ async def test_form_import_non_secure_device_discovered_invalid_auth(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_auth" assert result["reason"] == "invalid_auth"
@ -1189,7 +1189,7 @@ async def test_discovered_by_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "ElkM1 ddeeff" assert result2["title"] == "ElkM1 ddeeff"
assert result2["data"] == { assert result2["data"] == {
"auto_configure": True, "auto_configure": True,
@ -1239,7 +1239,7 @@ async def test_discovered_by_discovery_non_standard_port(hass: HomeAssistant) ->
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "ElkM1 ddeeff" assert result2["title"] == "ElkM1 ddeeff"
assert result2["data"] == { assert result2["data"] == {
"auto_configure": True, "auto_configure": True,
@ -1310,7 +1310,7 @@ async def test_discovered_by_dhcp_udp_responds(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "ElkM1 ddeeff" assert result2["title"] == "ElkM1 ddeeff"
assert result2["data"] == { assert result2["data"] == {
"auto_configure": True, "auto_configure": True,
@ -1359,7 +1359,7 @@ async def test_discovered_by_dhcp_udp_responds_with_nonsecure_port(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "ElkM1 ddeeff" assert result2["title"] == "ElkM1 ddeeff"
assert result2["data"] == { assert result2["data"] == {
"auto_configure": True, "auto_configure": True,
@ -1412,7 +1412,7 @@ async def test_discovered_by_dhcp_udp_responds_existing_config_entry(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "ElkM1 ddeeff" assert result2["title"] == "ElkM1 ddeeff"
assert result2["data"] == { assert result2["data"] == {
"auto_configure": True, "auto_configure": True,
@ -1450,7 +1450,7 @@ async def test_multiple_instances_with_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert not result["errors"] assert not result["errors"]
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -1483,7 +1483,7 @@ async def test_multiple_instances_with_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "ElkM1 ddeeff" assert result3["title"] == "ElkM1 ddeeff"
assert result3["data"] == { assert result3["data"] == {
"auto_configure": True, "auto_configure": True,
@ -1502,7 +1502,7 @@ async def test_multiple_instances_with_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert not result["errors"] assert not result["errors"]
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -1532,7 +1532,7 @@ async def test_multiple_instances_with_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "ElkM1 ddeefe" assert result3["title"] == "ElkM1 ddeefe"
assert result3["data"] == { assert result3["data"] == {
"auto_configure": True, "auto_configure": True,
@ -1551,7 +1551,7 @@ async def test_multiple_instances_with_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
assert result["step_id"] == "manual_connection" assert result["step_id"] == "manual_connection"
@ -1575,7 +1575,7 @@ async def test_multiple_instances_with_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "guest_house" assert result2["title"] == "guest_house"
assert result2["data"] == { assert result2["data"] == {
"auto_configure": True, "auto_configure": True,
@ -1599,7 +1599,7 @@ async def test_multiple_instances_with_tls_v12(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert not result["errors"] assert not result["errors"]
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -1612,7 +1612,7 @@ async def test_multiple_instances_with_tls_v12(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert not result["errors"] assert not result["errors"]
assert result2["step_id"] == "discovered_connection" assert result2["step_id"] == "discovered_connection"
with ( with (
@ -1636,7 +1636,7 @@ async def test_multiple_instances_with_tls_v12(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "ElkM1 ddeeff" assert result3["title"] == "ElkM1 ddeeff"
assert result3["data"] == { assert result3["data"] == {
"auto_configure": True, "auto_configure": True,
@ -1655,7 +1655,7 @@ async def test_multiple_instances_with_tls_v12(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert not result["errors"] assert not result["errors"]
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -1686,7 +1686,7 @@ async def test_multiple_instances_with_tls_v12(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "ElkM1 ddeefe" assert result3["title"] == "ElkM1 ddeefe"
assert result3["data"] == { assert result3["data"] == {
"auto_configure": True, "auto_configure": True,
@ -1705,7 +1705,7 @@ async def test_multiple_instances_with_tls_v12(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
assert result["step_id"] == "manual_connection" assert result["step_id"] == "manual_connection"
@ -1731,7 +1731,7 @@ async def test_multiple_instances_with_tls_v12(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "guest_house" assert result2["title"] == "guest_house"
assert result2["data"] == { assert result2["data"] == {
"auto_configure": True, "auto_configure": True,

View file

@ -10,6 +10,7 @@ from homeassistant.components import dhcp
from homeassistant.components.emonitor.const import DOMAIN from homeassistant.components.emonitor.const import DOMAIN
from homeassistant.const import CONF_HOST from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -32,7 +33,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -53,7 +54,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Emonitor DDEEFF" assert result2["title"] == "Emonitor DDEEFF"
assert result2["data"] == { assert result2["data"] == {
"host": "1.2.3.4", "host": "1.2.3.4",
@ -78,7 +79,7 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
@ -99,7 +100,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {CONF_HOST: "cannot_connect"} assert result2["errors"] == {CONF_HOST: "cannot_connect"}
@ -117,7 +118,7 @@ async def test_dhcp_can_confirm(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm" assert result["step_id"] == "confirm"
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
"host": "1.2.3.4", "host": "1.2.3.4",
@ -134,7 +135,7 @@ async def test_dhcp_can_confirm(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Emonitor DDEEFF" assert result2["title"] == "Emonitor DDEEFF"
assert result2["data"] == { assert result2["data"] == {
"host": "1.2.3.4", "host": "1.2.3.4",
@ -156,7 +157,7 @@ async def test_dhcp_fails_to_connect(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -181,7 +182,7 @@ async def test_dhcp_already_exists(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -198,7 +199,7 @@ async def test_user_unique_id_already_exists(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -219,5 +220,5 @@ async def test_user_unique_id_already_exists(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"

View file

@ -3,6 +3,7 @@
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.emulated_roku import config_flow from homeassistant.components.emulated_roku import config_flow
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -15,7 +16,7 @@ async def test_flow_works(hass: HomeAssistant, mock_get_source_ip) -> None:
data={"name": "Emulated Roku Test", "listen_port": 8060}, data={"name": "Emulated Roku Test", "listen_port": 8060},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Emulated Roku Test" assert result["title"] == "Emulated Roku Test"
assert result["data"] == {"name": "Emulated Roku Test", "listen_port": 8060} assert result["data"] == {"name": "Emulated Roku Test", "listen_port": 8060}
@ -34,5 +35,5 @@ async def test_flow_already_registered_entry(
data={"name": "Emulated Roku Test", "listen_port": 8062}, data={"name": "Emulated Roku Test", "listen_port": 8062},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -11,6 +11,7 @@ from homeassistant import config_entries
from homeassistant.components import zeroconf from homeassistant.components import zeroconf
from homeassistant.components.enphase_envoy.const import DOMAIN, PLATFORMS from homeassistant.components.enphase_envoy.const import DOMAIN, PLATFORMS
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
async def test_form(hass: HomeAssistant, config, setup_enphase_envoy) -> None: async def test_form(hass: HomeAssistant, config, setup_enphase_envoy) -> None:
@ -18,7 +19,7 @@ async def test_form(hass: HomeAssistant, config, setup_enphase_envoy) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
@ -30,7 +31,7 @@ async def test_form(hass: HomeAssistant, config, setup_enphase_envoy) -> None:
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Envoy 1234" assert result2["title"] == "Envoy 1234"
assert result2["data"] == { assert result2["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -48,7 +49,7 @@ async def test_user_no_serial_number(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
@ -60,7 +61,7 @@ async def test_user_no_serial_number(
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Envoy" assert result2["title"] == "Envoy"
assert result2["data"] == { assert result2["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -78,7 +79,7 @@ async def test_user_fetching_serial_fails(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
@ -90,7 +91,7 @@ async def test_user_fetching_serial_fails(
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Envoy" assert result2["title"] == "Envoy"
assert result2["data"] == { assert result2["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -120,7 +121,7 @@ async def test_form_invalid_auth(hass: HomeAssistant, setup_enphase_envoy) -> No
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
@ -142,7 +143,7 @@ async def test_form_cannot_connect(hass: HomeAssistant, setup_enphase_envoy) ->
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -164,7 +165,7 @@ async def test_form_unknown_error(hass: HomeAssistant, setup_enphase_envoy) -> N
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
@ -193,7 +194,7 @@ async def test_zeroconf_pre_token_firmware(
type="mock_type", type="mock_type",
), ),
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert _get_schema_default(result["data_schema"].schema, "username") == "installer" assert _get_schema_default(result["data_schema"].schema, "username") == "installer"
@ -207,7 +208,7 @@ async def test_zeroconf_pre_token_firmware(
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Envoy 1234" assert result2["title"] == "Envoy 1234"
assert result2["result"].unique_id == "1234" assert result2["result"].unique_id == "1234"
assert result2["data"] == { assert result2["data"] == {
@ -235,7 +236,7 @@ async def test_zeroconf_token_firmware(
type="mock_type", type="mock_type",
), ),
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert _get_schema_default(result["data_schema"].schema, "username") == "" assert _get_schema_default(result["data_schema"].schema, "username") == ""
@ -248,7 +249,7 @@ async def test_zeroconf_token_firmware(
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Envoy 1234" assert result2["title"] == "Envoy 1234"
assert result2["result"].unique_id == "1234" assert result2["result"].unique_id == "1234"
assert result2["data"] == { assert result2["data"] == {
@ -278,7 +279,7 @@ async def test_form_host_already_exists(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
# existing config # existing config
@ -295,7 +296,7 @@ async def test_form_host_already_exists(
"password": "wrong-password", "password": "wrong-password",
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
# still original config after failure # still original config after failure
@ -313,7 +314,7 @@ async def test_form_host_already_exists(
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "abort" assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "reauth_successful" assert result3["reason"] == "reauth_successful"
# updated config with new ip and changed pw # updated config with new ip and changed pw
@ -340,7 +341,7 @@ async def test_zeroconf_serial_already_exists(
), ),
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert config_entry.data["host"] == "4.4.4.4" assert config_entry.data["host"] == "4.4.4.4"
@ -364,7 +365,7 @@ async def test_zeroconf_serial_already_exists_ignores_ipv6(
), ),
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_ipv4_address" assert result["reason"] == "not_ipv4_address"
assert config_entry.data["host"] == "1.1.1.1" assert config_entry.data["host"] == "1.1.1.1"
@ -389,7 +390,7 @@ async def test_zeroconf_host_already_exists(
), ),
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert config_entry.unique_id == "1234" assert config_entry.unique_id == "1234"
@ -414,7 +415,7 @@ async def test_reauth(hass: HomeAssistant, config_entry, setup_enphase_envoy) ->
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "reauth_successful" assert result2["reason"] == "reauth_successful"

View file

@ -123,7 +123,7 @@ async def test_exception_handling(hass: HomeAssistant, error) -> None:
{}, {},
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": base_error} assert result["errors"] == {"base": base_error}

View file

@ -8,6 +8,7 @@ from homeassistant import config_entries
from homeassistant.components.epson.const import DOMAIN from homeassistant.components.epson.const import DOMAIN
from homeassistant.const import CONF_HOST, CONF_NAME, STATE_UNAVAILABLE from homeassistant.const import CONF_HOST, CONF_NAME, STATE_UNAVAILABLE
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
async def test_form(hass: HomeAssistant) -> None: async def test_form(hass: HomeAssistant) -> None:
@ -17,7 +18,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
assert result["step_id"] == config_entries.SOURCE_USER assert result["step_id"] == config_entries.SOURCE_USER
with ( with (
@ -40,7 +41,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "test-epson" assert result2["title"] == "test-epson"
assert result2["data"] == {CONF_HOST: "1.1.1.1"} assert result2["data"] == {CONF_HOST: "1.1.1.1"}
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -61,7 +62,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
{CONF_HOST: "1.1.1.1", CONF_NAME: "test-epson"}, {CONF_HOST: "1.1.1.1", CONF_NAME: "test-epson"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -80,5 +81,5 @@ async def test_form_powered_off(hass: HomeAssistant) -> None:
{CONF_HOST: "1.1.1.1", CONF_NAME: "test-epson"}, {CONF_HOST: "1.1.1.1", CONF_NAME: "test-epson"},
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "powered_off"} assert result2["errors"] == {"base": "powered_off"}

View file

@ -26,7 +26,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -44,7 +44,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "test" assert result2["title"] == "test"
assert result2["data"] == { assert result2["data"] == {
"id": "test", "id": "test",
@ -80,7 +80,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -98,5 +98,5 @@ async def test_form_unexpected_exception(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}

View file

@ -8,6 +8,7 @@ from homeassistant import config_entries
from homeassistant.components.firmata.const import CONF_SERIAL_PORT, DOMAIN from homeassistant.components.firmata.const import CONF_SERIAL_PORT, DOMAIN
from homeassistant.const import CONF_NAME from homeassistant.const import CONF_NAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
async def test_import_cannot_connect_pymata(hass: HomeAssistant) -> None: async def test_import_cannot_connect_pymata(hass: HomeAssistant) -> None:
@ -23,7 +24,7 @@ async def test_import_cannot_connect_pymata(hass: HomeAssistant) -> None:
data={CONF_SERIAL_PORT: "/dev/nonExistent"}, data={CONF_SERIAL_PORT: "/dev/nonExistent"},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -40,7 +41,7 @@ async def test_import_cannot_connect_serial(hass: HomeAssistant) -> None:
data={CONF_SERIAL_PORT: "/dev/nonExistent"}, data={CONF_SERIAL_PORT: "/dev/nonExistent"},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -57,7 +58,7 @@ async def test_import_cannot_connect_serial_timeout(hass: HomeAssistant) -> None
data={CONF_SERIAL_PORT: "/dev/nonExistent"}, data={CONF_SERIAL_PORT: "/dev/nonExistent"},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -79,7 +80,7 @@ async def test_import(hass: HomeAssistant) -> None:
data={CONF_SERIAL_PORT: "/dev/nonExistent"}, data={CONF_SERIAL_PORT: "/dev/nonExistent"},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "serial-/dev/nonExistent" assert result["title"] == "serial-/dev/nonExistent"
assert result["data"] == { assert result["data"] == {
CONF_NAME: "serial-/dev/nonExistent", CONF_NAME: "serial-/dev/nonExistent",

View file

@ -480,7 +480,7 @@ async def test_reauth_flow(
"entry_id": config_entry.entry_id, "entry_id": config_entry.entry_id,
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm" assert result["step_id"] == "reauth_confirm"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(

View file

@ -29,7 +29,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (

View file

@ -47,7 +47,7 @@ async def test_invalid_credential(hass: HomeAssistant, mock_setup) -> None:
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "invalid_auth"} assert result["errors"] == {"base": "invalid_auth"}
@ -129,7 +129,7 @@ async def test_no_flip_id(hass: HomeAssistant, mock_setup) -> None:
) )
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "no_flipr_id_found"} assert result["errors"] == {"base": "no_flipr_id_found"}
assert len(mock_flipr_client.mock_calls) == 1 assert len(mock_flipr_client.mock_calls) == 1
@ -148,7 +148,7 @@ async def test_http_errors(hass: HomeAssistant, mock_setup) -> None:
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
with patch( with patch(
@ -165,5 +165,5 @@ async def test_http_errors(hass: HomeAssistant, mock_setup) -> None:
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "unknown"} assert result["errors"] == {"base": "unknown"}

View file

@ -9,6 +9,7 @@ from homeassistant import config_entries
from homeassistant.components.flo.const import DOMAIN from homeassistant.components.flo.const import DOMAIN
from homeassistant.const import CONTENT_TYPE_JSON from homeassistant.const import CONTENT_TYPE_JSON
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .common import TEST_EMAIL_ADDRESS, TEST_PASSWORD, TEST_TOKEN, TEST_USER_ID from .common import TEST_EMAIL_ADDRESS, TEST_PASSWORD, TEST_TOKEN, TEST_USER_ID
@ -21,7 +22,7 @@ async def test_form(hass: HomeAssistant, aioclient_mock_fixture) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with patch( with patch(
@ -31,7 +32,7 @@ async def test_form(hass: HomeAssistant, aioclient_mock_fixture) -> None:
result["flow_id"], {"username": TEST_USER_ID, "password": TEST_PASSWORD} result["flow_id"], {"username": TEST_USER_ID, "password": TEST_PASSWORD}
) )
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == TEST_USER_ID assert result2["title"] == TEST_USER_ID
assert result2["data"] == {"username": TEST_USER_ID, "password": TEST_PASSWORD} assert result2["data"] == {"username": TEST_USER_ID, "password": TEST_PASSWORD}
await hass.async_block_till_done() await hass.async_block_till_done()
@ -68,5 +69,5 @@ async def test_form_cannot_connect(
result["flow_id"], {"username": "test-username", "password": "test-password"} result["flow_id"], {"username": "test-username", "password": "test-password"}
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}

View file

@ -13,6 +13,7 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -29,7 +30,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
mock_flume_device_list = _get_mocked_flume_device_list() mock_flume_device_list = _get_mocked_flume_device_list()
@ -59,7 +60,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "test-username" assert result2["title"] == "test-username"
assert result2["data"] == { assert result2["data"] == {
CONF_USERNAME: "test-username", CONF_USERNAME: "test-username",
@ -96,7 +97,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"password": "invalid_auth"} assert result2["errors"] == {"password": "invalid_auth"}
@ -125,7 +126,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -147,7 +148,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_REAUTH, "unique_id": "test@test.org"}, context={"source": config_entries.SOURCE_REAUTH, "unique_id": "test@test.org"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm" assert result["step_id"] == "reauth_confirm"
with ( with (
@ -167,7 +168,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"password": "invalid_auth"} assert result2["errors"] == {"password": "invalid_auth"}
with ( with (
@ -187,7 +188,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
}, },
) )
assert result3["type"] == "form" assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {"base": "cannot_connect"} assert result3["errors"] == {"base": "cannot_connect"}
mock_flume_device_list = _get_mocked_flume_device_list() mock_flume_device_list = _get_mocked_flume_device_list()
@ -214,5 +215,5 @@ async def test_reauth(hass: HomeAssistant) -> None:
) )
assert mock_setup_entry.called assert mock_setup_entry.called
assert result4["type"] == "abort" assert result4["type"] is FlowResultType.ABORT
assert result4["reason"] == "reauth_successful" assert result4["reason"] == "reauth_successful"

View file

@ -55,13 +55,13 @@ async def test_discovery(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "pick_device" assert result2["step_id"] == "pick_device"
assert not result2["errors"] assert not result2["errors"]
@ -69,13 +69,13 @@ async def test_discovery(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "pick_device" assert result2["step_id"] == "pick_device"
assert not result2["errors"] assert not result2["errors"]
@ -91,7 +91,7 @@ async def test_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == DEFAULT_ENTRY_TITLE assert result3["title"] == DEFAULT_ENTRY_TITLE
assert result3["data"] == { assert result3["data"] == {
CONF_MINOR_VERSION: 4, CONF_MINOR_VERSION: 4,
@ -111,7 +111,7 @@ async def test_discovery(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -119,7 +119,7 @@ async def test_discovery(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "no_devices_found" assert result2["reason"] == "no_devices_found"
@ -130,13 +130,13 @@ async def test_discovery_legacy(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "pick_device" assert result2["step_id"] == "pick_device"
assert not result2["errors"] assert not result2["errors"]
@ -144,13 +144,13 @@ async def test_discovery_legacy(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "pick_device" assert result2["step_id"] == "pick_device"
assert not result2["errors"] assert not result2["errors"]
@ -166,7 +166,7 @@ async def test_discovery_legacy(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == DEFAULT_ENTRY_TITLE assert result3["title"] == DEFAULT_ENTRY_TITLE
assert result3["data"] == { assert result3["data"] == {
CONF_MINOR_VERSION: 4, CONF_MINOR_VERSION: 4,
@ -186,7 +186,7 @@ async def test_discovery_legacy(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -194,7 +194,7 @@ async def test_discovery_legacy(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "no_devices_found" assert result2["reason"] == "no_devices_found"
@ -212,7 +212,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -220,7 +220,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "pick_device" assert result2["step_id"] == "pick_device"
assert not result2["errors"] assert not result2["errors"]
@ -229,7 +229,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -237,7 +237,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "pick_device" assert result2["step_id"] == "pick_device"
assert not result2["errors"] assert not result2["errors"]
@ -249,7 +249,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result3 = await hass.config_entries.flow.async_configure( result3 = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_DEVICE: MAC_ADDRESS} result["flow_id"], {CONF_DEVICE: MAC_ADDRESS}
) )
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == DEFAULT_ENTRY_TITLE assert result3["title"] == DEFAULT_ENTRY_TITLE
assert result3["data"] == { assert result3["data"] == {
CONF_MINOR_VERSION: 4, CONF_MINOR_VERSION: 4,
@ -270,7 +270,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -278,7 +278,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "no_devices_found" assert result2["reason"] == "no_devices_found"
@ -292,7 +292,7 @@ async def test_discovery_no_device(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "no_devices_found" assert result2["reason"] == "no_devices_found"
@ -301,7 +301,7 @@ async def test_manual_working_discovery(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -312,7 +312,7 @@ async def test_manual_working_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "user" assert result2["step_id"] == "user"
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -327,7 +327,7 @@ async def test_manual_working_discovery(hass: HomeAssistant) -> None:
result["flow_id"], {CONF_HOST: IP_ADDRESS} result["flow_id"], {CONF_HOST: IP_ADDRESS}
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result4["type"] == "create_entry" assert result4["type"] is FlowResultType.CREATE_ENTRY
assert result4["title"] == DEFAULT_ENTRY_TITLE assert result4["title"] == DEFAULT_ENTRY_TITLE
assert result4["data"] == { assert result4["data"] == {
CONF_MINOR_VERSION: 4, CONF_MINOR_VERSION: 4,
@ -351,7 +351,7 @@ async def test_manual_working_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"
@ -360,7 +360,7 @@ async def test_manual_no_discovery_data(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -375,7 +375,7 @@ async def test_manual_no_discovery_data(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
CONF_HOST: IP_ADDRESS, CONF_HOST: IP_ADDRESS,
CONF_MODEL_NUM: MODEL_NUM, CONF_MODEL_NUM: MODEL_NUM,
@ -446,7 +446,7 @@ async def test_discovered_by_discovery(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == { assert result2["data"] == {
CONF_MINOR_VERSION: 4, CONF_MINOR_VERSION: 4,
CONF_HOST: IP_ADDRESS, CONF_HOST: IP_ADDRESS,
@ -485,7 +485,7 @@ async def test_discovered_by_dhcp_udp_responds(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == { assert result2["data"] == {
CONF_MINOR_VERSION: 4, CONF_MINOR_VERSION: 4,
CONF_HOST: IP_ADDRESS, CONF_HOST: IP_ADDRESS,
@ -524,7 +524,7 @@ async def test_discovered_by_dhcp_no_udp_response(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: IP_ADDRESS, CONF_HOST: IP_ADDRESS,
CONF_MODEL_NUM: MODEL_NUM, CONF_MODEL_NUM: MODEL_NUM,
@ -559,7 +559,7 @@ async def test_discovered_by_dhcp_partial_udp_response_fallback_tcp(
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: IP_ADDRESS, CONF_HOST: IP_ADDRESS,
CONF_MODEL_NUM: MODEL_NUM, CONF_MODEL_NUM: MODEL_NUM,
@ -703,7 +703,7 @@ async def test_options(hass: HomeAssistant) -> None:
await hass.async_block_till_done() await hass.async_block_till_done()
result = await hass.config_entries.options.async_init(config_entry.entry_id) result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
user_input = { user_input = {
@ -716,7 +716,7 @@ async def test_options(hass: HomeAssistant) -> None:
result["flow_id"], user_input result["flow_id"], user_input
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == user_input assert result2["data"] == user_input
assert result2["data"] == config_entry.options assert result2["data"] == config_entry.options
assert hass.states.get("light.bulb_rgbcw_ddeeff") is not None assert hass.states.get("light.bulb_rgbcw_ddeeff") is not None

View file

@ -40,7 +40,7 @@ async def test_user_flow(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == USERNAME assert result2["title"] == USERNAME
assert result2["data"] == {CONF_USERNAME: USERNAME, CONF_PASSWORD: PASSWORD} assert result2["data"] == {CONF_USERNAME: USERNAME, CONF_PASSWORD: PASSWORD}
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1

View file

@ -127,7 +127,7 @@ async def test_form_only_stillimage(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
data = TESTDATA.copy() data = TESTDATA.copy()
@ -501,7 +501,7 @@ async def test_form_image_http_exceptions(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == expected_message assert result2["errors"] == expected_message
@ -518,7 +518,7 @@ async def test_form_stream_invalidimage(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"still_image_url": "invalid_still_image"} assert result2["errors"] == {"still_image_url": "invalid_still_image"}
@ -535,7 +535,7 @@ async def test_form_stream_invalidimage2(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"still_image_url": "unable_still_load_no_image"} assert result2["errors"] == {"still_image_url": "unable_still_load_no_image"}
@ -552,7 +552,7 @@ async def test_form_stream_invalidimage3(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"still_image_url": "invalid_still_image"} assert result2["errors"] == {"still_image_url": "invalid_still_image"}
@ -571,7 +571,7 @@ async def test_form_stream_timeout(hass: HomeAssistant, fakeimg_png, user_flow)
user_flow["flow_id"], user_flow["flow_id"],
TESTDATA, TESTDATA,
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"stream_source": "timeout"} assert result2["errors"] == {"stream_source": "timeout"}
@ -588,7 +588,7 @@ async def test_form_stream_worker_error(
user_flow["flow_id"], user_flow["flow_id"],
TESTDATA, TESTDATA,
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"stream_source": "Some message"} assert result2["errors"] == {"stream_source": "Some message"}
@ -606,7 +606,7 @@ async def test_form_stream_permission_error(
user_flow["flow_id"], user_flow["flow_id"],
TESTDATA, TESTDATA,
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"stream_source": "stream_not_permitted"} assert result2["errors"] == {"stream_source": "stream_not_permitted"}
@ -623,7 +623,7 @@ async def test_form_no_route_to_host(
user_flow["flow_id"], user_flow["flow_id"],
TESTDATA, TESTDATA,
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"stream_source": "stream_no_route_to_host"} assert result2["errors"] == {"stream_source": "stream_no_route_to_host"}
@ -640,7 +640,7 @@ async def test_form_stream_io_error(
user_flow["flow_id"], user_flow["flow_id"],
TESTDATA, TESTDATA,
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"stream_source": "stream_io_error"} assert result2["errors"] == {"stream_source": "stream_io_error"}

View file

@ -276,7 +276,7 @@ async def test_options_flow(
result = await hass.config_entries.options.async_init(mock_config_entry.entry_id) result = await hass.config_entries.options.async_init(mock_config_entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(

View file

@ -151,7 +151,7 @@ async def test_full_flow_application_creds(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result.get("type") == "progress" assert result.get("type") is FlowResultType.SHOW_PROGRESS
assert result.get("step_id") == "auth" assert result.get("step_id") == "auth"
assert "description_placeholders" in result assert "description_placeholders" in result
assert "url" in result["description_placeholders"] assert "url" in result["description_placeholders"]
@ -167,7 +167,7 @@ async def test_full_flow_application_creds(
flow_id=result["flow_id"] flow_id=result["flow_id"]
) )
assert result.get("type") == "create_entry" assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == EMAIL_ADDRESS assert result.get("title") == EMAIL_ADDRESS
assert "data" in result assert "data" in result
data = result["data"] data = result["data"]
@ -213,7 +213,7 @@ async def test_code_error(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "oauth_error" assert result.get("reason") == "oauth_error"
@ -233,7 +233,7 @@ async def test_timeout_error(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "timeout_connect" assert result.get("reason") == "timeout_connect"
@ -252,7 +252,7 @@ async def test_expired_after_exchange(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result.get("type") == "progress" assert result.get("type") is FlowResultType.SHOW_PROGRESS
assert result.get("step_id") == "auth" assert result.get("step_id") == "auth"
assert "description_placeholders" in result assert "description_placeholders" in result
assert "url" in result["description_placeholders"] assert "url" in result["description_placeholders"]
@ -267,7 +267,7 @@ async def test_expired_after_exchange(
await hass.async_block_till_done() await hass.async_block_till_done()
result = await hass.config_entries.flow.async_configure(flow_id=result["flow_id"]) result = await hass.config_entries.flow.async_configure(flow_id=result["flow_id"])
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "code_expired" assert result.get("reason") == "code_expired"
@ -287,7 +287,7 @@ async def test_exchange_error(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result.get("type") == "progress" assert result.get("type") is FlowResultType.SHOW_PROGRESS
assert result.get("step_id") == "auth" assert result.get("step_id") == "auth"
assert "description_placeholders" in result assert "description_placeholders" in result
assert "url" in result["description_placeholders"] assert "url" in result["description_placeholders"]
@ -309,7 +309,7 @@ async def test_exchange_error(
# Status has not updated, will retry # Status has not updated, will retry
result = await hass.config_entries.flow.async_configure(flow_id=result["flow_id"]) result = await hass.config_entries.flow.async_configure(flow_id=result["flow_id"])
assert result.get("type") == "progress" assert result.get("type") is FlowResultType.SHOW_PROGRESS
assert result.get("step_id") == "auth" assert result.get("step_id") == "auth"
# Run another tick, which attempts credential exchange again # Run another tick, which attempts credential exchange again
@ -323,7 +323,7 @@ async def test_exchange_error(
flow_id=result["flow_id"] flow_id=result["flow_id"]
) )
assert result.get("type") == "create_entry" assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == EMAIL_ADDRESS assert result.get("title") == EMAIL_ADDRESS
assert "data" in result assert "data" in result
data = result["data"] data = result["data"]
@ -373,7 +373,7 @@ async def test_duplicate_config_entries(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result.get("type") == "progress" assert result.get("type") is FlowResultType.SHOW_PROGRESS
assert result.get("step_id") == "auth" assert result.get("step_id") == "auth"
assert "description_placeholders" in result assert "description_placeholders" in result
assert "url" in result["description_placeholders"] assert "url" in result["description_placeholders"]
@ -383,7 +383,7 @@ async def test_duplicate_config_entries(
await fire_alarm(hass, now + CODE_CHECK_ALARM_TIMEDELTA) await fire_alarm(hass, now + CODE_CHECK_ALARM_TIMEDELTA)
await hass.async_block_till_done() await hass.async_block_till_done()
result = await hass.config_entries.flow.async_configure(flow_id=result["flow_id"]) result = await hass.config_entries.flow.async_configure(flow_id=result["flow_id"])
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured" assert result.get("reason") == "already_configured"
@ -415,7 +415,7 @@ async def test_multiple_config_entries(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result.get("type") == "progress" assert result.get("type") is FlowResultType.SHOW_PROGRESS
assert result.get("step_id") == "auth" assert result.get("step_id") == "auth"
assert "description_placeholders" in result assert "description_placeholders" in result
assert "url" in result["description_placeholders"] assert "url" in result["description_placeholders"]
@ -430,7 +430,7 @@ async def test_multiple_config_entries(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
flow_id=result["flow_id"] flow_id=result["flow_id"]
) )
assert result.get("type") == "create_entry" assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == "another-email@example.com" assert result.get("title") == "another-email@example.com"
assert len(mock_setup.mock_calls) == 1 assert len(mock_setup.mock_calls) == 1
@ -445,7 +445,7 @@ async def test_missing_configuration(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "missing_credentials" assert result.get("reason") == "missing_credentials"
@ -471,7 +471,7 @@ async def test_wrong_configuration(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "oauth_error" assert result.get("reason") == "oauth_error"
@ -506,14 +506,14 @@ async def test_reauth_flow(
}, },
data=config_entry.data, data=config_entry.data,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm" assert result["step_id"] == "reauth_confirm"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
flow_id=result["flow_id"], flow_id=result["flow_id"],
user_input={}, user_input={},
) )
assert result.get("type") == "progress" assert result.get("type") is FlowResultType.SHOW_PROGRESS
assert result.get("step_id") == "auth" assert result.get("step_id") == "auth"
assert "description_placeholders" in result assert "description_placeholders" in result
assert "url" in result["description_placeholders"] assert "url" in result["description_placeholders"]
@ -529,7 +529,7 @@ async def test_reauth_flow(
flow_id=result["flow_id"] flow_id=result["flow_id"]
) )
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "reauth_successful" assert result.get("reason") == "reauth_successful"
entries = hass.config_entries.async_entries(DOMAIN) entries = hass.config_entries.async_entries(DOMAIN)
@ -576,7 +576,7 @@ async def test_calendar_lookup_failure(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result.get("type") == "progress" assert result.get("type") is FlowResultType.SHOW_PROGRESS
assert result.get("step_id") == "auth" assert result.get("step_id") == "auth"
assert "description_placeholders" in result assert "description_placeholders" in result
assert "url" in result["description_placeholders"] assert "url" in result["description_placeholders"]
@ -590,7 +590,7 @@ async def test_calendar_lookup_failure(
flow_id=result["flow_id"] flow_id=result["flow_id"]
) )
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == reason assert result.get("reason") == reason
@ -611,7 +611,7 @@ async def test_options_flow_triggers_reauth(
assert config_entry.options == {} # Default is read_write assert config_entry.options == {} # Default is read_write
result = await hass.config_entries.options.async_init(config_entry.entry_id) result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
data_schema = result["data_schema"].schema data_schema = result["data_schema"].schema
assert set(data_schema) == {"calendar_access"} assert set(data_schema) == {"calendar_access"}
@ -622,7 +622,7 @@ async def test_options_flow_triggers_reauth(
"calendar_access": "read_only", "calendar_access": "read_only",
}, },
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {"calendar_access": "read_only"} assert config_entry.options == {"calendar_access": "read_only"}
@ -643,7 +643,7 @@ async def test_options_flow_no_changes(
assert config_entry.options == {} # Default is read_write assert config_entry.options == {} # Default is read_write
result = await hass.config_entries.options.async_init(config_entry.entry_id) result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -652,7 +652,7 @@ async def test_options_flow_no_changes(
"calendar_access": "read_write", "calendar_access": "read_write",
}, },
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {"calendar_access": "read_write"} assert config_entry.options == {"calendar_access": "read_write"}
@ -687,7 +687,7 @@ async def test_web_auth_compatibility(
"redirect_uri": "https://example.com/auth/external/callback", "redirect_uri": "https://example.com/auth/external/callback",
}, },
) )
assert result["type"] == "external" assert result["type"] is FlowResultType.EXTERNAL_STEP
assert result["url"] == ( assert result["url"] == (
f"{OAUTH2_AUTHORIZE}?response_type=code&client_id={CLIENT_ID}" f"{OAUTH2_AUTHORIZE}?response_type=code&client_id={CLIENT_ID}"
"&redirect_uri=https://example.com/auth/external/callback" "&redirect_uri=https://example.com/auth/external/callback"
@ -770,7 +770,7 @@ async def test_web_reauth_flow(
}, },
data=config_entry.data, data=config_entry.data,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm" assert result["step_id"] == "reauth_confirm"
with patch( with patch(
@ -791,7 +791,7 @@ async def test_web_reauth_flow(
"redirect_uri": "https://example.com/auth/external/callback", "redirect_uri": "https://example.com/auth/external/callback",
}, },
) )
assert result.get("type") == "external" assert result.get("type") is FlowResultType.EXTERNAL_STEP
assert result["url"] == ( assert result["url"] == (
f"{OAUTH2_AUTHORIZE}?response_type=code&client_id={CLIENT_ID}" f"{OAUTH2_AUTHORIZE}?response_type=code&client_id={CLIENT_ID}"
"&redirect_uri=https://example.com/auth/external/callback" "&redirect_uri=https://example.com/auth/external/callback"

View file

@ -5,6 +5,7 @@ from unittest.mock import patch
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.google_assistant_sdk.const import DOMAIN from homeassistant.components.google_assistant_sdk.const import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers import config_entry_oauth2_flow from homeassistant.helpers import config_entry_oauth2_flow
from .conftest import CLIENT_ID, ComponentSetup from .conftest import CLIENT_ID, ComponentSetup
@ -68,7 +69,7 @@ async def test_full_flow(
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert len(mock_setup.mock_calls) == 1 assert len(mock_setup.mock_calls) == 1
assert result.get("type") == "create_entry" assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == TITLE assert result.get("title") == TITLE
assert "result" in result assert "result" in result
assert result.get("result").unique_id is None assert result.get("result").unique_id is None
@ -144,7 +145,7 @@ async def test_reauth(
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert len(mock_setup.mock_calls) == 1 assert len(mock_setup.mock_calls) == 1
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "reauth_successful" assert result.get("reason") == "reauth_successful"
assert config_entry.unique_id is None assert config_entry.unique_id is None
@ -206,7 +207,7 @@ async def test_single_instance_allowed(
) )
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "single_instance_allowed" assert result.get("reason") == "single_instance_allowed"
@ -221,7 +222,7 @@ async def test_options_flow(
# Trigger options flow, first time # Trigger options flow, first time
result = await hass.config_entries.options.async_init(config_entry.entry_id) result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
data_schema = result["data_schema"].schema data_schema = result["data_schema"].schema
assert set(data_schema) == {"language_code"} assert set(data_schema) == {"language_code"}
@ -230,12 +231,12 @@ async def test_options_flow(
result["flow_id"], result["flow_id"],
user_input={"language_code": "es-ES"}, user_input={"language_code": "es-ES"},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {"language_code": "es-ES"} assert config_entry.options == {"language_code": "es-ES"}
# Retrigger options flow, not change language # Retrigger options flow, not change language
result = await hass.config_entries.options.async_init(config_entry.entry_id) result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
data_schema = result["data_schema"].schema data_schema = result["data_schema"].schema
assert set(data_schema) == {"language_code"} assert set(data_schema) == {"language_code"}
@ -244,12 +245,12 @@ async def test_options_flow(
result["flow_id"], result["flow_id"],
user_input={"language_code": "es-ES"}, user_input={"language_code": "es-ES"},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {"language_code": "es-ES"} assert config_entry.options == {"language_code": "es-ES"}
# Retrigger options flow, change language # Retrigger options flow, change language
result = await hass.config_entries.options.async_init(config_entry.entry_id) result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
data_schema = result["data_schema"].schema data_schema = result["data_schema"].schema
assert set(data_schema) == {"language_code"} assert set(data_schema) == {"language_code"}
@ -258,5 +259,5 @@ async def test_options_flow(
result["flow_id"], result["flow_id"],
user_input={"language_code": "en-US"}, user_input={"language_code": "en-US"},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {"language_code": "en-US"} assert config_entry.options == {"language_code": "en-US"}

View file

@ -8,6 +8,7 @@ import pytest
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.google_mail.const import DOMAIN from homeassistant.components.google_mail.const import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers import config_entry_oauth2_flow from homeassistant.helpers import config_entry_oauth2_flow
from .conftest import CLIENT_ID, GOOGLE_AUTH_URI, GOOGLE_TOKEN_URI, SCOPES, TITLE from .conftest import CLIENT_ID, GOOGLE_AUTH_URI, GOOGLE_TOKEN_URI, SCOPES, TITLE
@ -63,7 +64,7 @@ async def test_full_flow(
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert len(mock_setup.mock_calls) == 1 assert len(mock_setup.mock_calls) == 1
assert result.get("type") == "create_entry" assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == TITLE assert result.get("title") == TITLE
assert "result" in result assert "result" in result
assert result.get("result").unique_id == TITLE assert result.get("result").unique_id == TITLE
@ -160,7 +161,7 @@ async def test_reauth(
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result["reason"] == abort_reason assert result["reason"] == abort_reason
assert result["description_placeholders"] == placeholders assert result["description_placeholders"] == placeholders
assert len(mock_setup.mock_calls) == calls assert len(mock_setup.mock_calls) == calls
@ -212,5 +213,5 @@ async def test_already_configured(
), ),
): ):
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured" assert result.get("reason") == "already_configured"

View file

@ -13,6 +13,7 @@ from homeassistant.components.application_credentials import (
) )
from homeassistant.components.google_sheets.const import DOMAIN from homeassistant.components.google_sheets.const import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers import config_entry_oauth2_flow from homeassistant.helpers import config_entry_oauth2_flow
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -104,7 +105,7 @@ async def test_full_flow(
assert len(mock_setup.mock_calls) == 1 assert len(mock_setup.mock_calls) == 1
assert len(mock_client.mock_calls) == 2 assert len(mock_client.mock_calls) == 2
assert result.get("type") == "create_entry" assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == TITLE assert result.get("title") == TITLE
assert "result" in result assert "result" in result
assert result.get("result").unique_id == SHEET_ID assert result.get("result").unique_id == SHEET_ID
@ -163,7 +164,7 @@ async def test_create_sheet_error(
) )
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "create_spreadsheet_failure" assert result.get("reason") == "create_spreadsheet_failure"
@ -238,7 +239,7 @@ async def test_reauth(
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert len(mock_setup.mock_calls) == 1 assert len(mock_setup.mock_calls) == 1
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "reauth_successful" assert result.get("reason") == "reauth_successful"
assert config_entry.unique_id == SHEET_ID assert config_entry.unique_id == SHEET_ID
@ -313,7 +314,7 @@ async def test_reauth_abort(
) )
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "open_spreadsheet_failure" assert result.get("reason") == "open_spreadsheet_failure"
@ -376,5 +377,5 @@ async def test_already_configured(
) )
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured" assert result.get("reason") == "already_configured"

View file

@ -93,7 +93,7 @@ async def test_no_plants_on_account(hass: HomeAssistant) -> None:
result["flow_id"], user_input result["flow_id"], user_input
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_plants" assert result["reason"] == "no_plants"
@ -180,5 +180,5 @@ async def test_existing_plant_configured(hass: HomeAssistant) -> None:
result["flow_id"], user_input result["flow_id"], user_input
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -129,7 +129,7 @@ async def test_step_zeroconf_already_in_progress(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=zeroconf_data DOMAIN, context={"source": SOURCE_ZEROCONF}, data=zeroconf_data
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress" assert result["reason"] == "already_in_progress"
@ -176,7 +176,7 @@ async def test_step_dhcp_already_in_progress(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_DHCP}, data=dhcp_data DOMAIN, context={"source": SOURCE_DHCP}, data=dhcp_data
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress" assert result["reason"] == "already_in_progress"

View file

@ -7,6 +7,7 @@ from aiohttp import ClientResponseError
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.habitica.const import DEFAULT_URL, DOMAIN from homeassistant.components.habitica.const import DEFAULT_URL, DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -17,7 +18,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
mock_obj = MagicMock() mock_obj = MagicMock()
@ -42,7 +43,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Default username" assert result2["title"] == "Default username"
assert result2["data"] == { assert result2["data"] == {
"url": DEFAULT_URL, "url": DEFAULT_URL,
@ -75,7 +76,7 @@ async def test_form_invalid_credentials(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_credentials"} assert result2["errors"] == {"base": "invalid_credentials"}
@ -101,7 +102,7 @@ async def test_form_unexpected_exception(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
@ -117,7 +118,7 @@ async def test_manual_flow_config_exist(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_IMPORT} DOMAIN, context={"source": config_entries.SOURCE_IMPORT}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
mock_obj = MagicMock() mock_obj = MagicMock()
@ -136,5 +137,5 @@ async def test_manual_flow_config_exist(hass: HomeAssistant) -> None:
}, },
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -29,7 +29,7 @@ async def test_user_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
harmonyapi = _get_mock_harmonyapi(connect=True) harmonyapi = _get_mock_harmonyapi(connect=True)
@ -49,7 +49,7 @@ async def test_user_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "friend" assert result2["title"] == "friend"
assert result2["data"] == {"host": "1.2.3.4", "name": "friend"} assert result2["data"] == {"host": "1.2.3.4", "name": "friend"}
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -74,7 +74,7 @@ async def test_form_ssdp(hass: HomeAssistant) -> None:
}, },
), ),
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
assert result["errors"] == {} assert result["errors"] == {}
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
@ -104,7 +104,7 @@ async def test_form_ssdp(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Harmony Hub" assert result2["title"] == "Harmony Hub"
assert result2["data"] == {"host": "192.168.1.12", "name": "Harmony Hub"} assert result2["data"] == {"host": "192.168.1.12", "name": "Harmony Hub"}
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -129,7 +129,7 @@ async def test_form_ssdp_fails_to_get_remote_id(hass: HomeAssistant) -> None:
}, },
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -168,7 +168,7 @@ async def test_form_ssdp_aborts_before_checking_remoteid_if_host_known(
}, },
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
async def test_form_cannot_connect(hass: HomeAssistant) -> None: async def test_form_cannot_connect(hass: HomeAssistant) -> None:
@ -191,7 +191,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}

View file

@ -4,6 +4,7 @@ from unittest.mock import patch
from homeassistant.components.hassio import DOMAIN from homeassistant.components.hassio import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
async def test_config_flow(hass: HomeAssistant) -> None: async def test_config_flow(hass: HomeAssistant) -> None:
@ -21,7 +22,7 @@ async def test_config_flow(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "system"} DOMAIN, context={"source": "system"}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Supervisor" assert result["title"] == "Supervisor"
assert result["data"] == {} assert result["data"] == {}
await hass.async_block_till_done() await hass.async_block_till_done()
@ -36,5 +37,5 @@ async def test_multiple_entries(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "system"} DOMAIN, context={"source": "system"}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -266,7 +266,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
@ -289,7 +289,7 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}

View file

@ -6,6 +6,7 @@ from unittest.mock import patch
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.hlk_sw16.const import DOMAIN from homeassistant.components.hlk_sw16.const import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
class MockSW16Client: class MockSW16Client:
@ -54,7 +55,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
conf = { conf = {
@ -83,7 +84,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "127.0.0.1:8080" assert result2["title"] == "127.0.0.1:8080"
assert result2["data"] == { assert result2["data"] == {
"host": "127.0.0.1", "host": "127.0.0.1",
@ -101,7 +102,7 @@ async def test_form(hass: HomeAssistant) -> None:
result3 = await hass.config_entries.flow.async_init( result3 = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result3["type"] == "form" assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {} assert result3["errors"] == {}
result4 = await hass.config_entries.flow.async_configure( result4 = await hass.config_entries.flow.async_configure(
@ -109,7 +110,7 @@ async def test_form(hass: HomeAssistant) -> None:
conf, conf,
) )
assert result4["type"] == "abort" assert result4["type"] is FlowResultType.ABORT
assert result4["reason"] == "already_configured" assert result4["reason"] == "already_configured"
@ -119,7 +120,7 @@ async def test_import(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_IMPORT} DOMAIN, context={"source": config_entries.SOURCE_IMPORT}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
conf = { conf = {
@ -148,7 +149,7 @@ async def test_import(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "127.0.0.1:8080" assert result2["title"] == "127.0.0.1:8080"
assert result2["data"] == { assert result2["data"] == {
"host": "127.0.0.1", "host": "127.0.0.1",
@ -180,7 +181,7 @@ async def test_form_invalid_data(hass: HomeAssistant) -> None:
conf, conf,
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -205,5 +206,5 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
conf, conf,
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}

View file

@ -51,7 +51,7 @@ async def test_setup_in_bridge_mode(hass: HomeAssistant, mock_get_source_ip) ->
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
@ -113,7 +113,7 @@ async def test_setup_in_bridge_mode_name_taken(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
@ -199,7 +199,7 @@ async def test_setup_creates_entries_for_accessory_mode_devices(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
@ -1290,7 +1290,7 @@ async def test_converting_bridge_to_accessory_mode(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(

View file

@ -243,7 +243,7 @@ async def test_discovery_works(
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
data=discovery_info, data=discovery_info,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair" assert result["step_id"] == "pair"
assert get_flow_context(hass, result) == { assert get_flow_context(hass, result) == {
"source": config_entries.SOURCE_ZEROCONF, "source": config_entries.SOURCE_ZEROCONF,
@ -253,14 +253,14 @@ async def test_discovery_works(
# User initiates pairing - device enters pairing mode and displays code # User initiates pairing - device enters pairing mode and displays code
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair" assert result["step_id"] == "pair"
# Pairing doesn't error error and pairing results # Pairing doesn't error error and pairing results
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"pairing_code": "111-22-333"} result["flow_id"], user_input={"pairing_code": "111-22-333"}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Koogeek-LS1-20833F" assert result["title"] == "Koogeek-LS1-20833F"
assert result["data"] == {} assert result["data"] == {}
@ -276,7 +276,7 @@ async def test_abort_duplicate_flow(hass: HomeAssistant, controller) -> None:
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
data=discovery_info, data=discovery_info,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair" assert result["step_id"] == "pair"
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
@ -284,7 +284,7 @@ async def test_abort_duplicate_flow(hass: HomeAssistant, controller) -> None:
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
data=discovery_info, data=discovery_info,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress" assert result["reason"] == "already_in_progress"
@ -300,7 +300,7 @@ async def test_pair_already_paired_1(hass: HomeAssistant, controller) -> None:
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
data=discovery_info, data=discovery_info,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_paired" assert result["reason"] == "already_paired"
@ -317,7 +317,7 @@ async def test_unknown_domain_type(hass: HomeAssistant, controller) -> None:
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
data=discovery_info, data=discovery_info,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "ignored_model" assert result["reason"] == "ignored_model"
@ -335,7 +335,7 @@ async def test_id_missing(hass: HomeAssistant, controller) -> None:
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
data=discovery_info, data=discovery_info,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_properties" assert result["reason"] == "invalid_properties"
@ -352,7 +352,7 @@ async def test_discovery_ignored_model(hass: HomeAssistant, controller) -> None:
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
data=discovery_info, data=discovery_info,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "ignored_model" assert result["reason"] == "ignored_model"
@ -380,7 +380,7 @@ async def test_discovery_ignored_hk_bridge(
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
data=discovery_info, data=discovery_info,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "ignored_model" assert result["reason"] == "ignored_model"
@ -408,7 +408,7 @@ async def test_discovery_does_not_ignore_non_homekit(
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
data=discovery_info, data=discovery_info,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
async def test_discovery_broken_pairing_flag(hass: HomeAssistant, controller) -> None: async def test_discovery_broken_pairing_flag(hass: HomeAssistant, controller) -> None:
@ -483,7 +483,7 @@ async def test_discovery_invalid_config_entry(hass: HomeAssistant, controller) -
assert config_entry_count == 0 assert config_entry_count == 0
# And new config flow should continue allowing user to set up a new pairing # And new config flow should continue allowing user to set up a new pairing
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
async def test_discovery_ignored_config_entry(hass: HomeAssistant, controller) -> None: async def test_discovery_ignored_config_entry(hass: HomeAssistant, controller) -> None:
@ -549,7 +549,7 @@ async def test_discovery_already_configured(hass: HomeAssistant, controller) ->
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
data=discovery_info, data=discovery_info,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert entry.data["AccessoryIP"] == discovery_info.host assert entry.data["AccessoryIP"] == discovery_info.host
assert entry.data["AccessoryPort"] == discovery_info.port assert entry.data["AccessoryPort"] == discovery_info.port
@ -587,7 +587,7 @@ async def test_discovery_already_configured_update_csharp(
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
data=discovery_info, data=discovery_info,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
await hass.async_block_till_done() await hass.async_block_till_done()
@ -615,7 +615,7 @@ async def test_pair_abort_errors_on_start(
test_exc = exception("error") test_exc = exception("error")
with patch.object(device, "async_start_pairing", side_effect=test_exc): with patch.object(device, "async_start_pairing", side_effect=test_exc):
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == expected assert result["reason"] == expected
@ -640,7 +640,7 @@ async def test_pair_try_later_errors_on_start(
with patch.object(device, "async_start_pairing", side_effect=test_exc): with patch.object(device, "async_start_pairing", side_effect=test_exc):
result2 = await hass.config_entries.flow.async_configure(result["flow_id"]) result2 = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result2["step_id"] == expected assert result2["step_id"] == expected
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
# Device is rebooted or placed into pairing mode as they have been instructed # Device is rebooted or placed into pairing mode as they have been instructed
@ -654,7 +654,7 @@ async def test_pair_try_later_errors_on_start(
result3["flow_id"], user_input={"pairing_code": "111-22-333"} result3["flow_id"], user_input={"pairing_code": "111-22-333"}
) )
assert result4["type"] == "create_entry" assert result4["type"] is FlowResultType.CREATE_ENTRY
assert result4["title"] == "Koogeek-LS1-20833F" assert result4["title"] == "Koogeek-LS1-20833F"
@ -686,7 +686,7 @@ async def test_pair_form_errors_on_start(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"pairing_code": "111-22-333"} result["flow_id"], user_input={"pairing_code": "111-22-333"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"]["pairing_code"] == expected assert result["errors"]["pairing_code"] == expected
assert get_flow_context(hass, result) == { assert get_flow_context(hass, result) == {
@ -697,7 +697,7 @@ async def test_pair_form_errors_on_start(
# User gets back the form # User gets back the form
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
# User re-tries entering pairing code # User re-tries entering pairing code
@ -705,7 +705,7 @@ async def test_pair_form_errors_on_start(
result["flow_id"], user_input={"pairing_code": "111-22-333"} result["flow_id"], user_input={"pairing_code": "111-22-333"}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Koogeek-LS1-20833F" assert result["title"] == "Koogeek-LS1-20833F"
@ -736,7 +736,7 @@ async def test_pair_abort_errors_on_finish(
with patch.object(device, "async_start_pairing", return_value=finish_pairing): with patch.object(device, "async_start_pairing", return_value=finish_pairing):
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert get_flow_context(hass, result) == { assert get_flow_context(hass, result) == {
"title_placeholders": {"name": "TestDevice", "category": "Outlet"}, "title_placeholders": {"name": "TestDevice", "category": "Outlet"},
"unique_id": "00:00:00:00:00:00", "unique_id": "00:00:00:00:00:00",
@ -747,7 +747,7 @@ async def test_pair_abort_errors_on_finish(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"pairing_code": "111-22-333"} result["flow_id"], user_input={"pairing_code": "111-22-333"}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == expected assert result["reason"] == expected
@ -778,7 +778,7 @@ async def test_pair_form_errors_on_finish(
with patch.object(device, "async_start_pairing", return_value=finish_pairing): with patch.object(device, "async_start_pairing", return_value=finish_pairing):
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert get_flow_context(hass, result) == { assert get_flow_context(hass, result) == {
"title_placeholders": {"name": "TestDevice", "category": "Outlet"}, "title_placeholders": {"name": "TestDevice", "category": "Outlet"},
"unique_id": "00:00:00:00:00:00", "unique_id": "00:00:00:00:00:00",
@ -789,7 +789,7 @@ async def test_pair_form_errors_on_finish(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"pairing_code": "111-22-333"} result["flow_id"], user_input={"pairing_code": "111-22-333"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"]["pairing_code"] == expected assert result["errors"]["pairing_code"] == expected
assert get_flow_context(hass, result) == { assert get_flow_context(hass, result) == {
@ -826,7 +826,7 @@ async def test_pair_unknown_errors(hass: HomeAssistant, controller) -> None:
with patch.object(device, "async_start_pairing", return_value=finish_pairing): with patch.object(device, "async_start_pairing", return_value=finish_pairing):
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert get_flow_context(hass, result) == { assert get_flow_context(hass, result) == {
"title_placeholders": {"name": "TestDevice", "category": "Outlet"}, "title_placeholders": {"name": "TestDevice", "category": "Outlet"},
"unique_id": "00:00:00:00:00:00", "unique_id": "00:00:00:00:00:00",
@ -837,7 +837,7 @@ async def test_pair_unknown_errors(hass: HomeAssistant, controller) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"pairing_code": "111-22-333"} result["flow_id"], user_input={"pairing_code": "111-22-333"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"]["pairing_code"] == "pairing_failed" assert result["errors"]["pairing_code"] == "pairing_failed"
assert ( assert (
result["description_placeholders"]["error"] == "The bluetooth connection failed" result["description_placeholders"]["error"] == "The bluetooth connection failed"
@ -860,7 +860,7 @@ async def test_user_works(hass: HomeAssistant, controller) -> None:
"homekit_controller", context={"source": config_entries.SOURCE_USER} "homekit_controller", context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert get_flow_context(hass, result) == { assert get_flow_context(hass, result) == {
"source": config_entries.SOURCE_USER, "source": config_entries.SOURCE_USER,
@ -869,7 +869,7 @@ async def test_user_works(hass: HomeAssistant, controller) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"device": "TestDevice"} result["flow_id"], user_input={"device": "TestDevice"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair" assert result["step_id"] == "pair"
assert get_flow_context(hass, result) == { assert get_flow_context(hass, result) == {
@ -881,7 +881,7 @@ async def test_user_works(hass: HomeAssistant, controller) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"pairing_code": "111-22-333"} result["flow_id"], user_input={"pairing_code": "111-22-333"}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Koogeek-LS1-20833F" assert result["title"] == "Koogeek-LS1-20833F"
@ -897,7 +897,7 @@ async def test_user_pairing_with_insecure_setup_code(
"homekit_controller", context={"source": config_entries.SOURCE_USER} "homekit_controller", context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert get_flow_context(hass, result) == { assert get_flow_context(hass, result) == {
"source": config_entries.SOURCE_USER, "source": config_entries.SOURCE_USER,
@ -906,7 +906,7 @@ async def test_user_pairing_with_insecure_setup_code(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"device": "TestDevice"} result["flow_id"], user_input={"device": "TestDevice"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair" assert result["step_id"] == "pair"
assert get_flow_context(hass, result) == { assert get_flow_context(hass, result) == {
@ -918,7 +918,7 @@ async def test_user_pairing_with_insecure_setup_code(
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"pairing_code": "123-45-678"} result["flow_id"], user_input={"pairing_code": "123-45-678"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair" assert result["step_id"] == "pair"
assert result["errors"] == {"pairing_code": "insecure_setup_code"} assert result["errors"] == {"pairing_code": "insecure_setup_code"}
@ -926,7 +926,7 @@ async def test_user_pairing_with_insecure_setup_code(
result["flow_id"], result["flow_id"],
user_input={"pairing_code": "123-45-678", "allow_insecure_setup_codes": True}, user_input={"pairing_code": "123-45-678", "allow_insecure_setup_codes": True},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Koogeek-LS1-20833F" assert result["title"] == "Koogeek-LS1-20833F"
@ -935,7 +935,7 @@ async def test_user_no_devices(hass: HomeAssistant, controller) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
"homekit_controller", context={"source": config_entries.SOURCE_USER} "homekit_controller", context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices" assert result["reason"] == "no_devices"
@ -952,7 +952,7 @@ async def test_user_no_unpaired_devices(hass: HomeAssistant, controller) -> None
"homekit_controller", context={"source": config_entries.SOURCE_USER} "homekit_controller", context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices" assert result["reason"] == "no_devices"
@ -966,7 +966,7 @@ async def test_unignore_works(hass: HomeAssistant, controller) -> None:
context={"source": config_entries.SOURCE_UNIGNORE}, context={"source": config_entries.SOURCE_UNIGNORE},
data={"unique_id": device.description.id}, data={"unique_id": device.description.id},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair" assert result["step_id"] == "pair"
assert get_flow_context(hass, result) == { assert get_flow_context(hass, result) == {
"title_placeholders": {"name": "TestDevice", "category": "Other"}, "title_placeholders": {"name": "TestDevice", "category": "Other"},
@ -976,14 +976,14 @@ async def test_unignore_works(hass: HomeAssistant, controller) -> None:
# User initiates pairing by clicking on 'configure' - device enters pairing mode and displays code # User initiates pairing by clicking on 'configure' - device enters pairing mode and displays code
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair" assert result["step_id"] == "pair"
# Pairing finalized # Pairing finalized
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"pairing_code": "111-22-333"} result["flow_id"], user_input={"pairing_code": "111-22-333"}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Koogeek-LS1-20833F" assert result["title"] == "Koogeek-LS1-20833F"
@ -1000,7 +1000,7 @@ async def test_unignore_ignores_missing_devices(
data={"unique_id": "00:00:00:00:00:01"}, data={"unique_id": "00:00:00:00:00:01"},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "accessory_not_found_error" assert result["reason"] == "accessory_not_found_error"
@ -1022,7 +1022,7 @@ async def test_discovery_dismiss_existing_flow_on_paired(
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
data=discovery_info, data=discovery_info,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair" assert result["step_id"] == "pair"
await hass.async_block_till_done() await hass.async_block_till_done()
assert ( assert (
@ -1038,7 +1038,7 @@ async def test_discovery_dismiss_existing_flow_on_paired(
context={"source": config_entries.SOURCE_ZEROCONF}, context={"source": config_entries.SOURCE_ZEROCONF},
data=discovery_info, data=discovery_info,
) )
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_paired" assert result2["reason"] == "already_paired"
await hass.async_block_till_done() await hass.async_block_till_done()
assert ( assert (
@ -1088,7 +1088,7 @@ async def test_mdns_update_to_paired_during_pairing(
with patch.object(device, "async_start_pairing", _async_start_pairing): with patch.object(device, "async_start_pairing", _async_start_pairing):
result = await hass.config_entries.flow.async_configure(result["flow_id"]) result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert get_flow_context(hass, result) == { assert get_flow_context(hass, result) == {
"title_placeholders": {"name": "TestDevice", "category": "Outlet"}, "title_placeholders": {"name": "TestDevice", "category": "Outlet"},
"unique_id": "00:00:00:00:00:00", "unique_id": "00:00:00:00:00:00",

View file

@ -11,6 +11,7 @@ from homeassistant.components.homematicip_cloud.const import (
HMIPC_PIN, HMIPC_PIN,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -38,7 +39,7 @@ async def test_flow_works(hass: HomeAssistant, simple_mock_home) -> None:
data=DEFAULT_CONFIG, data=DEFAULT_CONFIG,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
assert result["errors"] == {"base": "press_the_button"} assert result["errors"] == {"base": "press_the_button"}
@ -70,7 +71,7 @@ async def test_flow_works(hass: HomeAssistant, simple_mock_home) -> None:
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "ABC123" assert result["title"] == "ABC123"
assert result["data"] == {"hapid": "ABC123", "authtoken": True, "name": "hmip"} assert result["data"] == {"hapid": "ABC123", "authtoken": True, "name": "hmip"}
assert result["result"].unique_id == "ABC123" assert result["result"].unique_id == "ABC123"
@ -88,7 +89,7 @@ async def test_flow_init_connection_error(hass: HomeAssistant) -> None:
data=DEFAULT_CONFIG, data=DEFAULT_CONFIG,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
@ -114,7 +115,7 @@ async def test_flow_link_connection_error(hass: HomeAssistant) -> None:
data=DEFAULT_CONFIG, data=DEFAULT_CONFIG,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "connection_aborted" assert result["reason"] == "connection_aborted"
@ -136,7 +137,7 @@ async def test_flow_link_press_button(hass: HomeAssistant) -> None:
data=DEFAULT_CONFIG, data=DEFAULT_CONFIG,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
assert result["errors"] == {"base": "press_the_button"} assert result["errors"] == {"base": "press_the_button"}
@ -147,7 +148,7 @@ async def test_init_flow_show_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
HMIPC_DOMAIN, context={"source": config_entries.SOURCE_USER} HMIPC_DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
@ -164,7 +165,7 @@ async def test_init_already_configured(hass: HomeAssistant) -> None:
data=DEFAULT_CONFIG, data=DEFAULT_CONFIG,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -193,7 +194,7 @@ async def test_import_config(hass: HomeAssistant, simple_mock_home) -> None:
data=IMPORT_CONFIG, data=IMPORT_CONFIG,
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "ABC123" assert result["title"] == "ABC123"
assert result["data"] == {"authtoken": "123", "hapid": "ABC123", "name": "hmip"} assert result["data"] == {"authtoken": "123", "hapid": "ABC123", "name": "hmip"}
assert result["result"].unique_id == "ABC123" assert result["result"].unique_id == "ABC123"
@ -222,5 +223,5 @@ async def test_import_existing_config(hass: HomeAssistant) -> None:
data=IMPORT_CONFIG, data=IMPORT_CONFIG,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -322,7 +322,7 @@ async def test_abort_flow(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
@ -349,7 +349,7 @@ async def test_reauth_flow(
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm" assert result["step_id"] == "reauth_confirm"
result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result = await hass.config_entries.flow.async_configure(result["flow_id"], {})

View file

@ -13,6 +13,7 @@ from homeassistant.components import zeroconf
from homeassistant.components.hue import config_flow, const from homeassistant.components.hue import config_flow, const
from homeassistant.components.hue.errors import CannotConnect from homeassistant.components.hue.errors import CannotConnect
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -61,14 +62,14 @@ async def test_flow_works(hass: HomeAssistant) -> None:
const.DOMAIN, context={"source": config_entries.SOURCE_USER} const.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"id": disc_bridge.id} result["flow_id"], user_input={"id": disc_bridge.id}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
flow = next( flow = next(
@ -83,7 +84,7 @@ async def test_flow_works(hass: HomeAssistant) -> None:
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Hue Bridge aabbccddeeff" assert result["title"] == "Hue Bridge aabbccddeeff"
assert result["data"] == { assert result["data"] == {
"host": "1.2.3.4", "host": "1.2.3.4",
@ -108,14 +109,14 @@ async def test_manual_flow_works(hass: HomeAssistant) -> None:
const.DOMAIN, context={"source": config_entries.SOURCE_USER} const.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"id": "manual"} result["flow_id"], user_input={"id": "manual"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual" assert result["step_id"] == "manual"
with patch.object(config_flow, "discover_bridge", return_value=disc_bridge): with patch.object(config_flow, "discover_bridge", return_value=disc_bridge):
@ -123,7 +124,7 @@ async def test_manual_flow_works(hass: HomeAssistant) -> None:
result["flow_id"], {"host": "2.2.2.2"} result["flow_id"], {"host": "2.2.2.2"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
with ( with (
@ -132,7 +133,7 @@ async def test_manual_flow_works(hass: HomeAssistant) -> None:
): ):
result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"Hue Bridge {disc_bridge.id}" assert result["title"] == f"Hue Bridge {disc_bridge.id}"
assert result["data"] == { assert result["data"] == {
"host": "2.2.2.2", "host": "2.2.2.2",
@ -159,14 +160,14 @@ async def test_manual_flow_bridge_exist(hass: HomeAssistant) -> None:
const.DOMAIN, context={"source": config_entries.SOURCE_USER} const.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual" assert result["step_id"] == "manual"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": "2.2.2.2"} result["flow_id"], {"host": "2.2.2.2"}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -179,7 +180,7 @@ async def test_manual_flow_no_discovered_bridges(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
const.DOMAIN, context={"source": config_entries.SOURCE_USER} const.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual" assert result["step_id"] == "manual"
@ -199,7 +200,7 @@ async def test_flow_all_discovered_bridges_exist(
const.DOMAIN, context={"source": config_entries.SOURCE_USER} const.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual" assert result["step_id"] == "manual"
@ -219,7 +220,7 @@ async def test_flow_bridges_discovered(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
const.DOMAIN, context={"source": config_entries.SOURCE_USER} const.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
with pytest.raises(vol.Invalid): with pytest.raises(vol.Invalid):
@ -243,7 +244,7 @@ async def test_flow_two_bridges_discovered_one_new(
const.DOMAIN, context={"source": config_entries.SOURCE_USER} const.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
assert result["data_schema"]({"id": "beer"}) assert result["data_schema"]({"id": "beer"})
assert result["data_schema"]({"id": "manual"}) assert result["data_schema"]({"id": "manual"})
@ -261,7 +262,7 @@ async def test_flow_timeout_discovery(hass: HomeAssistant) -> None:
const.DOMAIN, context={"source": config_entries.SOURCE_USER} const.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual" assert result["step_id"] == "manual"
@ -285,7 +286,7 @@ async def test_flow_link_unknown_error(hass: HomeAssistant) -> None:
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
assert result["errors"] == {"base": "linking"} assert result["errors"] == {"base": "linking"}
@ -310,7 +311,7 @@ async def test_flow_link_button_not_pressed(hass: HomeAssistant) -> None:
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
assert result["errors"] == {"base": "register_failed"} assert result["errors"] == {"base": "register_failed"}
@ -335,7 +336,7 @@ async def test_flow_link_cannot_connect(hass: HomeAssistant) -> None:
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -350,7 +351,7 @@ async def test_import_with_no_config(
data={"host": "0.0.0.0"}, data={"host": "0.0.0.0"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
@ -385,7 +386,7 @@ async def test_creating_entry_removes_entries_for_same_host_or_bridge(
context={"source": config_entries.SOURCE_IMPORT}, context={"source": config_entries.SOURCE_IMPORT},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
with ( with (
@ -397,7 +398,7 @@ async def test_creating_entry_removes_entries_for_same_host_or_bridge(
): ):
result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Hue Bridge id-1234" assert result["title"] == "Hue Bridge id-1234"
assert result["data"] == { assert result["data"] == {
"host": "2.2.2.2", "host": "2.2.2.2",
@ -431,7 +432,7 @@ async def test_bridge_homekit(
), ),
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
flow = next( flow = next(
@ -454,7 +455,7 @@ async def test_bridge_import_already_configured(hass: HomeAssistant) -> None:
data={"host": "0.0.0.0", "properties": {"id": "aa:bb:cc:dd:ee:ff"}}, data={"host": "0.0.0.0", "properties": {"id": "aa:bb:cc:dd:ee:ff"}},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -481,7 +482,7 @@ async def test_bridge_homekit_already_configured(
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -496,7 +497,7 @@ async def test_options_flow_v1(hass: HomeAssistant) -> None:
result = await hass.config_entries.options.async_init(entry.entry_id) result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
schema = result["data_schema"].schema schema = result["data_schema"].schema
assert ( assert (
@ -516,7 +517,7 @@ async def test_options_flow_v1(hass: HomeAssistant) -> None:
}, },
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
const.CONF_ALLOW_HUE_GROUPS: True, const.CONF_ALLOW_HUE_GROUPS: True,
const.CONF_ALLOW_UNREACHABLE: True, const.CONF_ALLOW_UNREACHABLE: True,
@ -550,7 +551,7 @@ async def test_options_flow_v2(
result = await hass.config_entries.options.async_init(entry.entry_id) result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
schema = result["data_schema"].schema schema = result["data_schema"].schema
assert _get_schema_default(schema, const.CONF_IGNORE_AVAILABILITY) == [] assert _get_schema_default(schema, const.CONF_IGNORE_AVAILABILITY) == []
@ -560,7 +561,7 @@ async def test_options_flow_v2(
user_input={const.CONF_IGNORE_AVAILABILITY: [mock_dev_id]}, user_input={const.CONF_IGNORE_AVAILABILITY: [mock_dev_id]},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
const.CONF_IGNORE_AVAILABILITY: [mock_dev_id], const.CONF_IGNORE_AVAILABILITY: [mock_dev_id],
} }
@ -589,7 +590,7 @@ async def test_bridge_zeroconf(
), ),
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
@ -625,7 +626,7 @@ async def test_bridge_zeroconf_already_exists(
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert entry.data["host"] == "192.168.1.217" assert entry.data["host"] == "192.168.1.217"
@ -650,7 +651,7 @@ async def test_bridge_zeroconf_ipv6(hass: HomeAssistant) -> None:
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_host" assert result["reason"] == "invalid_host"
@ -676,7 +677,7 @@ async def test_bridge_connection_failed(
# a warning message should have been logged that the bridge could not be reached # a warning message should have been logged that the bridge could not be reached
assert "Error while attempting to retrieve discovery information" in caplog.text assert "Error while attempting to retrieve discovery information" in caplog.text
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
# test again with zeroconf discovered wrong bridge IP # test again with zeroconf discovered wrong bridge IP
@ -697,7 +698,7 @@ async def test_bridge_connection_failed(
}, },
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
# test again with homekit discovered wrong bridge IP # test again with homekit discovered wrong bridge IP
@ -714,7 +715,7 @@ async def test_bridge_connection_failed(
type="mock_type", type="mock_type",
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
# repeat test with import flow # repeat test with import flow
@ -723,5 +724,5 @@ async def test_bridge_connection_failed(
context={"source": config_entries.SOURCE_IMPORT}, context={"source": config_entries.SOURCE_IMPORT},
data={"host": "blah"}, data={"host": "blah"},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"

View file

@ -50,7 +50,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert form_result["type"] == "create_entry" assert form_result["type"] is FlowResultType.CREATE_ENTRY
assert form_result["title"] == "test-username" assert form_result["title"] == "test-username"
assert form_result["data"] == { assert form_result["data"] == {
"id": "test-id", "id": "test-id",

View file

@ -190,7 +190,7 @@ async def test_reauth(
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "reauth_successful" assert result.get("reason") == "reauth_successful"
assert mock_config_entry.unique_id == USER_ID assert mock_config_entry.unique_id == USER_ID
@ -261,7 +261,7 @@ async def test_reauth_wrong_account(
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert result.get("type") == "abort" assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "wrong_account" assert result.get("reason") == "wrong_account"
assert mock_config_entry.unique_id == USER_ID assert mock_config_entry.unique_id == USER_ID

View file

@ -77,7 +77,7 @@ async def test_user_flow(hass: HomeAssistant) -> None:
{CONF_STATION: "Wartenau"}, {CONF_STATION: "Wartenau"},
) )
assert result_station_select["type"] == "create_entry" assert result_station_select["type"] is FlowResultType.CREATE_ENTRY
assert result_station_select["title"] == "Wartenau" assert result_station_select["title"] == "Wartenau"
assert result_station_select["data"] == { assert result_station_select["data"] == {
CONF_HOST: "api-test.geofox.de", CONF_HOST: "api-test.geofox.de",
@ -159,7 +159,7 @@ async def test_user_flow_invalid_auth(hass: HomeAssistant) -> None:
}, },
) )
assert result_user["type"] == "form" assert result_user["type"] is FlowResultType.FORM
assert result_user["errors"] == {"base": "invalid_auth"} assert result_user["errors"] == {"base": "invalid_auth"}
@ -181,7 +181,7 @@ async def test_user_flow_cannot_connect(hass: HomeAssistant) -> None:
}, },
) )
assert result_user["type"] == "form" assert result_user["type"] is FlowResultType.FORM
assert result_user["errors"] == {"base": "cannot_connect"} assert result_user["errors"] == {"base": "cannot_connect"}
@ -217,7 +217,7 @@ async def test_user_flow_station(hass: HomeAssistant) -> None:
result_user["flow_id"], result_user["flow_id"],
None, None,
) )
assert result_station["type"] == "form" assert result_station["type"] is FlowResultType.FORM
assert result_station["step_id"] == "station" assert result_station["step_id"] == "station"
@ -255,7 +255,7 @@ async def test_user_flow_station_select(hass: HomeAssistant) -> None:
None, None,
) )
assert result_station_select["type"] == "form" assert result_station_select["type"] is FlowResultType.FORM
assert result_station_select["step_id"] == "station_select" assert result_station_select["step_id"] == "station_select"

View file

@ -9,6 +9,7 @@ from iaqualink.exception import (
from homeassistant.components.iaqualink import config_flow from homeassistant.components.iaqualink import config_flow
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
async def test_already_configured( async def test_already_configured(
@ -23,7 +24,7 @@ async def test_already_configured(
result = await flow.async_step_user(config_data) result = await flow.async_step_user(config_data)
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
async def test_without_config(hass: HomeAssistant) -> None: async def test_without_config(hass: HomeAssistant) -> None:
@ -34,7 +35,7 @@ async def test_without_config(hass: HomeAssistant) -> None:
result = await flow.async_step_user() result = await flow.async_step_user()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {} assert result["errors"] == {}
@ -50,7 +51,7 @@ async def test_with_invalid_credentials(hass: HomeAssistant, config_data) -> Non
): ):
result = await flow.async_step_user(config_data) result = await flow.async_step_user(config_data)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {"base": "invalid_auth"} assert result["errors"] == {"base": "invalid_auth"}
@ -66,7 +67,7 @@ async def test_service_exception(hass: HomeAssistant, config_data) -> None:
): ):
result = await flow.async_step_user(config_data) result = await flow.async_step_user(config_data)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -83,6 +84,6 @@ async def test_with_existing_config(hass: HomeAssistant, config_data) -> None:
): ):
result = await flow.async_step_user(config_data) result = await flow.async_step_user(config_data)
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == config_data["username"] assert result["title"] == config_data["username"]
assert result["data"] == config_data assert result["data"] == config_data

View file

@ -124,7 +124,7 @@ async def test_form_select_modem(hass: HomeAssistant) -> None:
result = await _init_form(hass, STEP_HUB_V2) result = await _init_form(hass, STEP_HUB_V2)
assert result["step_id"] == STEP_HUB_V2 assert result["step_id"] == STEP_HUB_V2
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
async def test_fail_on_existing(hass: HomeAssistant) -> None: async def test_fail_on_existing(hass: HomeAssistant) -> None:
@ -155,7 +155,7 @@ async def test_form_select_plm(hass: HomeAssistant) -> None:
result2, mock_setup, mock_setup_entry = await _device_form( result2, mock_setup, mock_setup_entry = await _device_form(
hass, result["flow_id"], mock_successful_connection, MOCK_USER_INPUT_PLM hass, result["flow_id"], mock_successful_connection, MOCK_USER_INPUT_PLM
) )
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == MOCK_USER_INPUT_PLM assert result2["data"] == MOCK_USER_INPUT_PLM
assert len(mock_setup.mock_calls) == 1 assert len(mock_setup.mock_calls) == 1
@ -173,7 +173,7 @@ async def test_form_select_plm_no_usb(hass: HomeAssistant) -> None:
hass, result["flow_id"], mock_successful_connection, None hass, result["flow_id"], mock_successful_connection, None
) )
USB_PORTS.update(temp_usb_list) USB_PORTS.update(temp_usb_list)
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == STEP_PLM_MANUALLY assert result2["step_id"] == STEP_PLM_MANUALLY
@ -189,8 +189,8 @@ async def test_form_select_plm_manual(hass: HomeAssistant) -> None:
result3, mock_setup, mock_setup_entry = await _device_form( result3, mock_setup, mock_setup_entry = await _device_form(
hass, result2["flow_id"], mock_successful_connection, MOCK_USER_INPUT_PLM hass, result2["flow_id"], mock_successful_connection, MOCK_USER_INPUT_PLM
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["data"] == MOCK_USER_INPUT_PLM assert result3["data"] == MOCK_USER_INPUT_PLM
assert len(mock_setup.mock_calls) == 1 assert len(mock_setup.mock_calls) == 1
@ -205,7 +205,7 @@ async def test_form_select_hub_v1(hass: HomeAssistant) -> None:
result2, mock_setup, mock_setup_entry = await _device_form( result2, mock_setup, mock_setup_entry = await _device_form(
hass, result["flow_id"], mock_successful_connection, MOCK_USER_INPUT_HUB_V1 hass, result["flow_id"], mock_successful_connection, MOCK_USER_INPUT_HUB_V1
) )
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == { assert result2["data"] == {
**MOCK_USER_INPUT_HUB_V1, **MOCK_USER_INPUT_HUB_V1,
CONF_HUB_VERSION: 1, CONF_HUB_VERSION: 1,
@ -223,7 +223,7 @@ async def test_form_select_hub_v2(hass: HomeAssistant) -> None:
result2, mock_setup, mock_setup_entry = await _device_form( result2, mock_setup, mock_setup_entry = await _device_form(
hass, result["flow_id"], mock_successful_connection, MOCK_USER_INPUT_HUB_V2 hass, result["flow_id"], mock_successful_connection, MOCK_USER_INPUT_HUB_V2
) )
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == { assert result2["data"] == {
**MOCK_USER_INPUT_HUB_V2, **MOCK_USER_INPUT_HUB_V2,
CONF_HUB_VERSION: 2, CONF_HUB_VERSION: 2,
@ -263,7 +263,7 @@ async def test_failed_connection_plm(hass: HomeAssistant) -> None:
result2, _, _ = await _device_form( result2, _, _ = await _device_form(
hass, result["flow_id"], mock_failed_connection, MOCK_USER_INPUT_PLM hass, result["flow_id"], mock_failed_connection, MOCK_USER_INPUT_PLM
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -278,7 +278,7 @@ async def test_failed_connection_plm_manually(hass: HomeAssistant) -> None:
result3, _, _ = await _device_form( result3, _, _ = await _device_form(
hass, result["flow_id"], mock_failed_connection, MOCK_USER_INPUT_PLM hass, result["flow_id"], mock_failed_connection, MOCK_USER_INPUT_PLM
) )
assert result3["type"] == "form" assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {"base": "cannot_connect"} assert result3["errors"] == {"base": "cannot_connect"}
@ -290,7 +290,7 @@ async def test_failed_connection_hub(hass: HomeAssistant) -> None:
result2, _, _ = await _device_form( result2, _, _ = await _device_form(
hass, result["flow_id"], mock_failed_connection, MOCK_USER_INPUT_HUB_V2 hass, result["flow_id"], mock_failed_connection, MOCK_USER_INPUT_HUB_V2
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}

View file

@ -358,5 +358,5 @@ async def test_dhcp_discovery_non_intellifire_device(
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_intellifire_device" assert result["reason"] == "not_intellifire_device"

View file

@ -27,7 +27,7 @@ async def test_config_flow(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER} DOMAIN, context={"source": SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
test_data = { test_data = {
@ -57,7 +57,7 @@ async def test_config_flow_failures(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER} DOMAIN, context={"source": SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
test_data = { test_data = {
@ -109,5 +109,5 @@ async def test_flow_entry_already_exists(hass: HomeAssistant, init_integration)
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"

View file

@ -69,5 +69,5 @@ async def test_options(hass: HomeAssistant) -> None:
}, },
) )
assert configured.get("type") == "create_entry" assert configured.get("type") is FlowResultType.CREATE_ENTRY
assert config_entry.options == {CONF_SHOW_ON_MAP: True} assert config_entry.options == {CONF_SHOW_ON_MAP: True}

View file

@ -649,7 +649,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_REAUTH, "unique_id": MOCK_UUID}, context={"source": config_entries.SOURCE_REAUTH, "unique_id": MOCK_UUID},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm" assert result["step_id"] == "reauth_confirm"
with patch( with patch(
@ -664,7 +664,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"password": "invalid_auth"} assert result2["errors"] == {"password": "invalid_auth"}
with patch( with patch(
@ -679,7 +679,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
}, },
) )
assert result3["type"] == "form" assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {"base": "cannot_connect"} assert result3["errors"] == {"base": "cannot_connect"}
with ( with (
@ -699,5 +699,5 @@ async def test_reauth(hass: HomeAssistant) -> None:
await hass.async_block_till_done() await hass.async_block_till_done()
assert mock_setup_entry.called assert mock_setup_entry.called
assert result4["type"] == "abort" assert result4["type"] is FlowResultType.ABORT
assert result4["reason"] == "reauth_successful" assert result4["reason"] == "reauth_successful"

View file

@ -41,7 +41,7 @@ async def test_form(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
result2 = await hass.config_entries.flow.async_configure( result2 = await hass.config_entries.flow.async_configure(
@ -50,7 +50,7 @@ async def test_form(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "JELLYFIN-SERVER" assert result2["title"] == "JELLYFIN-SERVER"
assert result2["data"] == { assert result2["data"] == {
CONF_CLIENT_DEVICE_ID: "TEST-UUID", CONF_CLIENT_DEVICE_ID: "TEST-UUID",
@ -75,7 +75,7 @@ async def test_form_cannot_connect(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
mock_client.auth.connect_to_address.return_value = await async_load_json_fixture( mock_client.auth.connect_to_address.return_value = await async_load_json_fixture(
@ -88,7 +88,7 @@ async def test_form_cannot_connect(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
assert len(mock_client.auth.connect_to_address.mock_calls) == 1 assert len(mock_client.auth.connect_to_address.mock_calls) == 1
@ -104,7 +104,7 @@ async def test_form_invalid_auth(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
mock_client.auth.login.return_value = await async_load_json_fixture( mock_client.auth.login.return_value = await async_load_json_fixture(
@ -117,7 +117,7 @@ async def test_form_invalid_auth(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
assert len(mock_client.auth.connect_to_address.mock_calls) == 1 assert len(mock_client.auth.connect_to_address.mock_calls) == 1
@ -131,7 +131,7 @@ async def test_form_exception(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
mock_client.auth.connect_to_address.side_effect = Exception("UnknownException") mock_client.auth.connect_to_address.side_effect = Exception("UnknownException")
@ -142,7 +142,7 @@ async def test_form_exception(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
assert len(mock_client.auth.connect_to_address.mock_calls) == 1 assert len(mock_client.auth.connect_to_address.mock_calls) == 1
@ -158,7 +158,7 @@ async def test_form_persists_device_id_on_error(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
mock_client_device_id.return_value = "TEST-UUID-1" mock_client_device_id.return_value = "TEST-UUID-1"
@ -172,7 +172,7 @@ async def test_form_persists_device_id_on_error(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
mock_client_device_id.return_value = "TEST-UUID-2" mock_client_device_id.return_value = "TEST-UUID-2"
@ -187,7 +187,7 @@ async def test_form_persists_device_id_on_error(
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3 assert result3
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["data"] == { assert result3["data"] == {
CONF_CLIENT_DEVICE_ID: "TEST-UUID-1", CONF_CLIENT_DEVICE_ID: "TEST-UUID-1",
CONF_URL: TEST_URL, CONF_URL: TEST_URL,
@ -291,7 +291,7 @@ async def test_reauth_cannot_connect(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
assert len(mock_client.auth.connect_to_address.mock_calls) == 1 assert len(mock_client.auth.connect_to_address.mock_calls) == 1
@ -354,7 +354,7 @@ async def test_reauth_invalid(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
assert len(mock_client.auth.connect_to_address.mock_calls) == 1 assert len(mock_client.auth.connect_to_address.mock_calls) == 1
@ -417,7 +417,7 @@ async def test_reauth_exception(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
assert len(mock_client.auth.connect_to_address.mock_calls) == 1 assert len(mock_client.auth.connect_to_address.mock_calls) == 1

View file

@ -9,6 +9,7 @@ from homeassistant import config_entries
from homeassistant.components.juicenet.const import DOMAIN from homeassistant.components.juicenet.const import DOMAIN
from homeassistant.const import CONF_ACCESS_TOKEN from homeassistant.const import CONF_ACCESS_TOKEN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
def _mock_juicenet_return_value(get_devices=None): def _mock_juicenet_return_value(get_devices=None):
@ -23,7 +24,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -43,7 +44,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "JuiceNet" assert result2["title"] == "JuiceNet"
assert result2["data"] == {CONF_ACCESS_TOKEN: "access_token"} assert result2["data"] == {CONF_ACCESS_TOKEN: "access_token"}
assert len(mock_setup.mock_calls) == 1 assert len(mock_setup.mock_calls) == 1
@ -64,7 +65,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
result["flow_id"], {CONF_ACCESS_TOKEN: "access_token"} result["flow_id"], {CONF_ACCESS_TOKEN: "access_token"}
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
@ -82,7 +83,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
result["flow_id"], {CONF_ACCESS_TOKEN: "access_token"} result["flow_id"], {CONF_ACCESS_TOKEN: "access_token"}
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -100,7 +101,7 @@ async def test_form_catch_unknown_errors(hass: HomeAssistant) -> None:
result["flow_id"], {CONF_ACCESS_TOKEN: "access_token"} result["flow_id"], {CONF_ACCESS_TOKEN: "access_token"}
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
@ -126,7 +127,7 @@ async def test_import(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "JuiceNet" assert result["title"] == "JuiceNet"
assert result["data"] == {CONF_ACCESS_TOKEN: "access_token"} assert result["data"] == {CONF_ACCESS_TOKEN: "access_token"}
assert len(mock_setup.mock_calls) == 1 assert len(mock_setup.mock_calls) == 1

View file

@ -24,7 +24,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with patch( with patch(
@ -41,7 +41,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "1.1.1.1" assert result2["title"] == "1.1.1.1"
assert result2["data"] == { assert result2["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -109,7 +109,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
@ -132,7 +132,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -155,5 +155,5 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}

View file

@ -148,7 +148,7 @@ async def test_user_single_instance(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "single_instance_allowed" assert result["reason"] == "single_instance_allowed"

View file

@ -11,6 +11,7 @@ from homeassistant.components.kodi.config_flow import (
) )
from homeassistant.components.kodi.const import DEFAULT_TIMEOUT, DOMAIN from homeassistant.components.kodi.const import DEFAULT_TIMEOUT, DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .util import ( from .util import (
TEST_CREDENTIALS, TEST_CREDENTIALS,
@ -34,7 +35,7 @@ async def user_flow(hass):
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
return result["flow_id"] return result["flow_id"]
@ -59,7 +60,7 @@ async def test_user_flow(hass: HomeAssistant, user_flow) -> None:
result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST) result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST)
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_HOST["host"] assert result["title"] == TEST_HOST["host"]
assert result["data"] == { assert result["data"] == {
**TEST_HOST, **TEST_HOST,
@ -87,7 +88,7 @@ async def test_form_valid_auth(hass: HomeAssistant, user_flow) -> None:
): ):
result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST) result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "credentials" assert result["step_id"] == "credentials"
assert result["errors"] == {} assert result["errors"] == {}
@ -110,7 +111,7 @@ async def test_form_valid_auth(hass: HomeAssistant, user_flow) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_HOST["host"] assert result["title"] == TEST_HOST["host"]
assert result["data"] == { assert result["data"] == {
**TEST_HOST, **TEST_HOST,
@ -142,7 +143,7 @@ async def test_form_valid_ws_port(hass: HomeAssistant, user_flow) -> None:
): ):
result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST) result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "ws_port" assert result["step_id"] == "ws_port"
assert result["errors"] == {} assert result["errors"] == {}
@ -165,7 +166,7 @@ async def test_form_valid_ws_port(hass: HomeAssistant, user_flow) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_HOST["host"] assert result["title"] == TEST_HOST["host"]
assert result["data"] == { assert result["data"] == {
**TEST_HOST, **TEST_HOST,
@ -198,7 +199,7 @@ async def test_form_empty_ws_port(hass: HomeAssistant, user_flow) -> None:
): ):
result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST) result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "ws_port" assert result["step_id"] == "ws_port"
assert result["errors"] == {} assert result["errors"] == {}
@ -211,7 +212,7 @@ async def test_form_empty_ws_port(hass: HomeAssistant, user_flow) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_HOST["host"] assert result["title"] == TEST_HOST["host"]
assert result["data"] == { assert result["data"] == {
**TEST_HOST, **TEST_HOST,
@ -239,7 +240,7 @@ async def test_form_invalid_auth(hass: HomeAssistant, user_flow) -> None:
): ):
result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST) result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "credentials" assert result["step_id"] == "credentials"
assert result["errors"] == {} assert result["errors"] == {}
@ -257,7 +258,7 @@ async def test_form_invalid_auth(hass: HomeAssistant, user_flow) -> None:
result["flow_id"], TEST_CREDENTIALS result["flow_id"], TEST_CREDENTIALS
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "credentials" assert result["step_id"] == "credentials"
assert result["errors"] == {"base": "invalid_auth"} assert result["errors"] == {"base": "invalid_auth"}
@ -275,7 +276,7 @@ async def test_form_invalid_auth(hass: HomeAssistant, user_flow) -> None:
result["flow_id"], TEST_CREDENTIALS result["flow_id"], TEST_CREDENTIALS
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "credentials" assert result["step_id"] == "credentials"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -293,7 +294,7 @@ async def test_form_invalid_auth(hass: HomeAssistant, user_flow) -> None:
result["flow_id"], TEST_CREDENTIALS result["flow_id"], TEST_CREDENTIALS
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "credentials" assert result["step_id"] == "credentials"
assert result["errors"] == {"base": "unknown"} assert result["errors"] == {"base": "unknown"}
@ -316,7 +317,7 @@ async def test_form_invalid_auth(hass: HomeAssistant, user_flow) -> None:
result["flow_id"], TEST_CREDENTIALS result["flow_id"], TEST_CREDENTIALS
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "ws_port" assert result["step_id"] == "ws_port"
assert result["errors"] == {} assert result["errors"] == {}
@ -335,7 +336,7 @@ async def test_form_cannot_connect_http(hass: HomeAssistant, user_flow) -> None:
): ):
result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST) result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -354,7 +355,7 @@ async def test_form_exception_http(hass: HomeAssistant, user_flow) -> None:
): ):
result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST) result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert result["errors"] == {"base": "unknown"} assert result["errors"] == {"base": "unknown"}
@ -378,7 +379,7 @@ async def test_form_cannot_connect_ws(hass: HomeAssistant, user_flow) -> None:
): ):
result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST) result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "ws_port" assert result["step_id"] == "ws_port"
assert result["errors"] == {} assert result["errors"] == {}
@ -399,7 +400,7 @@ async def test_form_cannot_connect_ws(hass: HomeAssistant, user_flow) -> None:
result["flow_id"], TEST_WS_PORT result["flow_id"], TEST_WS_PORT
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "ws_port" assert result["step_id"] == "ws_port"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -417,7 +418,7 @@ async def test_form_cannot_connect_ws(hass: HomeAssistant, user_flow) -> None:
result["flow_id"], TEST_WS_PORT result["flow_id"], TEST_WS_PORT
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "ws_port" assert result["step_id"] == "ws_port"
assert result["errors"] == {"base": "cannot_connect"} assert result["errors"] == {"base": "cannot_connect"}
@ -441,7 +442,7 @@ async def test_form_exception_ws(hass: HomeAssistant, user_flow) -> None:
): ):
result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST) result = await hass.config_entries.flow.async_configure(user_flow, TEST_HOST)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "ws_port" assert result["step_id"] == "ws_port"
assert result["errors"] == {} assert result["errors"] == {}
@ -460,7 +461,7 @@ async def test_form_exception_ws(hass: HomeAssistant, user_flow) -> None:
result["flow_id"], TEST_WS_PORT result["flow_id"], TEST_WS_PORT
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "ws_port" assert result["step_id"] == "ws_port"
assert result["errors"] == {"base": "unknown"} assert result["errors"] == {"base": "unknown"}
@ -483,7 +484,7 @@ async def test_discovery(hass: HomeAssistant) -> None:
data=TEST_DISCOVERY, data=TEST_DISCOVERY,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "discovery_confirm" assert result["step_id"] == "discovery_confirm"
with patch( with patch(
@ -495,7 +496,7 @@ async def test_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "hostname" assert result["title"] == "hostname"
assert result["data"] == { assert result["data"] == {
**TEST_HOST, **TEST_HOST,
@ -527,7 +528,7 @@ async def test_discovery_cannot_connect_http(hass: HomeAssistant) -> None:
data=TEST_DISCOVERY, data=TEST_DISCOVERY,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -554,7 +555,7 @@ async def test_discovery_cannot_connect_ws(hass: HomeAssistant) -> None:
data=TEST_DISCOVERY, data=TEST_DISCOVERY,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "ws_port" assert result["step_id"] == "ws_port"
assert result["errors"] == {} assert result["errors"] == {}
@ -577,7 +578,7 @@ async def test_discovery_exception_http(hass: HomeAssistant, user_flow) -> None:
data=TEST_DISCOVERY, data=TEST_DISCOVERY,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown" assert result["reason"] == "unknown"
@ -599,7 +600,7 @@ async def test_discovery_invalid_auth(hass: HomeAssistant) -> None:
data=TEST_DISCOVERY, data=TEST_DISCOVERY,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "credentials" assert result["step_id"] == "credentials"
assert result["errors"] == {} assert result["errors"] == {}
@ -622,14 +623,14 @@ async def test_discovery_duplicate_data(hass: HomeAssistant) -> None:
data=TEST_DISCOVERY, data=TEST_DISCOVERY,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "discovery_confirm" assert result["step_id"] == "discovery_confirm"
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=TEST_DISCOVERY DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=TEST_DISCOVERY
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress" assert result["reason"] == "already_in_progress"
@ -647,7 +648,7 @@ async def test_discovery_updates_unique_id(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=TEST_DISCOVERY DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=TEST_DISCOVERY
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert entry.data["host"] == "1.1.1.1" assert entry.data["host"] == "1.1.1.1"
@ -663,7 +664,7 @@ async def test_discovery_without_unique_id(hass: HomeAssistant) -> None:
data=TEST_DISCOVERY_WO_UUID, data=TEST_DISCOVERY_WO_UUID,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_uuid" assert result["reason"] == "no_uuid"
@ -690,7 +691,7 @@ async def test_form_import(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_IMPORT["name"] assert result["title"] == TEST_IMPORT["name"]
assert result["data"] == TEST_IMPORT assert result["data"] == TEST_IMPORT
@ -715,7 +716,7 @@ async def test_form_import_invalid_auth(hass: HomeAssistant) -> None:
data=TEST_IMPORT, data=TEST_IMPORT,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_auth" assert result["reason"] == "invalid_auth"
@ -737,7 +738,7 @@ async def test_form_import_cannot_connect(hass: HomeAssistant) -> None:
data=TEST_IMPORT, data=TEST_IMPORT,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
@ -759,5 +760,5 @@ async def test_form_import_exception(hass: HomeAssistant) -> None:
data=TEST_IMPORT, data=TEST_IMPORT,
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown" assert result["reason"] == "unknown"

View file

@ -8,6 +8,7 @@ from homeassistant import config_entries
from homeassistant.components import konnected, ssdp from homeassistant.components import konnected, ssdp
from homeassistant.components.konnected import config_flow from homeassistant.components.konnected import config_flow
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -33,7 +34,7 @@ async def test_flow_works(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER} config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
mock_panel.get_status.return_value = { mock_panel.get_status.return_value = {
@ -43,7 +44,7 @@ async def test_flow_works(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"port": 1234, "host": "1.2.3.4"} result["flow_id"], user_input={"port": 1234, "host": "1.2.3.4"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm" assert result["step_id"] == "confirm"
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
"model": "Konnected Alarm Panel", "model": "Konnected Alarm Panel",
@ -55,7 +56,7 @@ async def test_flow_works(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"]["host"] == "1.2.3.4" assert result["data"]["host"] == "1.2.3.4"
assert result["data"]["port"] == 1234 assert result["data"]["port"] == 1234
assert result["data"]["model"] == "Konnected" assert result["data"]["model"] == "Konnected"
@ -70,7 +71,7 @@ async def test_pro_flow_works(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER} config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
# pro uses chipId instead of MAC as unique id # pro uses chipId instead of MAC as unique id
@ -82,7 +83,7 @@ async def test_pro_flow_works(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"port": 1234, "host": "1.2.3.4"} result["flow_id"], user_input={"port": 1234, "host": "1.2.3.4"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm" assert result["step_id"] == "confirm"
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
"model": "Konnected Alarm Panel Pro", "model": "Konnected Alarm Panel Pro",
@ -94,7 +95,7 @@ async def test_pro_flow_works(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"]["host"] == "1.2.3.4" assert result["data"]["host"] == "1.2.3.4"
assert result["data"]["port"] == 1234 assert result["data"]["port"] == 1234
assert result["data"]["model"] == "Konnected Pro" assert result["data"]["model"] == "Konnected Pro"
@ -126,7 +127,7 @@ async def test_ssdp(hass: HomeAssistant, mock_panel) -> None:
), ),
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm" assert result["step_id"] == "confirm"
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
"model": "Konnected Alarm Panel", "model": "Konnected Alarm Panel",
@ -151,7 +152,7 @@ async def test_ssdp(hass: HomeAssistant, mock_panel) -> None:
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect" assert result["reason"] == "cannot_connect"
# Test abort if invalid data # Test abort if invalid data
@ -167,7 +168,7 @@ async def test_ssdp(hass: HomeAssistant, mock_panel) -> None:
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown" assert result["reason"] == "unknown"
# Test abort if invalid manufacturer # Test abort if invalid manufacturer
@ -185,7 +186,7 @@ async def test_ssdp(hass: HomeAssistant, mock_panel) -> None:
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_konn_panel" assert result["reason"] == "not_konn_panel"
# Test abort if invalid model # Test abort if invalid model
@ -203,7 +204,7 @@ async def test_ssdp(hass: HomeAssistant, mock_panel) -> None:
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_konn_panel" assert result["reason"] == "not_konn_panel"
# Test abort if already configured # Test abort if already configured
@ -227,7 +228,7 @@ async def test_ssdp(hass: HomeAssistant, mock_panel) -> None:
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -267,21 +268,21 @@ async def test_import_no_host_user_finish(hass: HomeAssistant, mock_panel) -> No
"id": "aabbccddeeff", "id": "aabbccddeeff",
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "import_confirm" assert result["step_id"] == "import_confirm"
assert result["description_placeholders"]["id"] == "aabbccddeeff" assert result["description_placeholders"]["id"] == "aabbccddeeff"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
# confirm user is prompted to enter host # confirm user is prompted to enter host
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"host": "1.1.1.1", "port": 1234} result["flow_id"], user_input={"host": "1.1.1.1", "port": 1234}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm" assert result["step_id"] == "confirm"
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
"model": "Konnected Alarm Panel Pro", "model": "Konnected Alarm Panel Pro",
@ -294,7 +295,7 @@ async def test_import_no_host_user_finish(hass: HomeAssistant, mock_panel) -> No
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
async def test_import_ssdp_host_user_finish(hass: HomeAssistant, mock_panel) -> None: async def test_import_ssdp_host_user_finish(hass: HomeAssistant, mock_panel) -> None:
@ -334,7 +335,7 @@ async def test_import_ssdp_host_user_finish(hass: HomeAssistant, mock_panel) ->
"id": "somechipid", "id": "somechipid",
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "import_confirm" assert result["step_id"] == "import_confirm"
assert result["description_placeholders"]["id"] == "somechipid" assert result["description_placeholders"]["id"] == "somechipid"
@ -352,13 +353,13 @@ async def test_import_ssdp_host_user_finish(hass: HomeAssistant, mock_panel) ->
}, },
), ),
) )
assert ssdp_result["type"] == "abort" assert ssdp_result["type"] is FlowResultType.ABORT
assert ssdp_result["reason"] == "already_in_progress" assert ssdp_result["reason"] == "already_in_progress"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm" assert result["step_id"] == "confirm"
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
"model": "Konnected Alarm Panel Pro", "model": "Konnected Alarm Panel Pro",
@ -371,7 +372,7 @@ async def test_import_ssdp_host_user_finish(hass: HomeAssistant, mock_panel) ->
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
async def test_ssdp_already_configured(hass: HomeAssistant, mock_panel) -> None: async def test_ssdp_already_configured(hass: HomeAssistant, mock_panel) -> None:
@ -399,7 +400,7 @@ async def test_ssdp_already_configured(hass: HomeAssistant, mock_panel) -> None:
}, },
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -479,7 +480,7 @@ async def test_ssdp_host_update(hass: HomeAssistant, mock_panel) -> None:
}, },
), ),
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
# confirm the host value was updated, access_token was not # confirm the host value was updated, access_token was not
entry = hass.config_entries.async_entries(config_flow.DOMAIN)[0] entry = hass.config_entries.async_entries(config_flow.DOMAIN)[0]
@ -537,13 +538,13 @@ async def test_import_existing_config(hass: HomeAssistant, mock_panel) -> None:
} }
), ),
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm" assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
"host": "1.2.3.4", "host": "1.2.3.4",
"port": 1234, "port": 1234,
@ -665,7 +666,7 @@ async def test_import_existing_config_entry(hass: HomeAssistant, mock_panel) ->
}, },
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
# We should have updated the host info but not the access token # We should have updated the host info but not the access token
assert len(hass.config_entries.async_entries("konnected")) == 1 assert len(hass.config_entries.async_entries("konnected")) == 1
@ -717,13 +718,13 @@ async def test_import_pin_config(hass: HomeAssistant, mock_panel) -> None:
} }
), ),
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm" assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure( result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
"host": "1.2.3.4", "host": "1.2.3.4",
"port": 1234, "port": 1234,
@ -802,7 +803,7 @@ async def test_option_flow(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.options.async_init( result = await hass.config_entries.options.async_init(
entry.entry_id, context={"source": "test"} entry.entry_id, context={"source": "test"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_io" assert result["step_id"] == "options_io"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -817,7 +818,7 @@ async def test_option_flow(hass: HomeAssistant, mock_panel) -> None:
"out": "Switchable Output", "out": "Switchable Output",
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_binary" assert result["step_id"] == "options_binary"
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
"zone": "Zone 2", "zone": "Zone 2",
@ -827,7 +828,7 @@ async def test_option_flow(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"type": "door"} result["flow_id"], user_input={"type": "door"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_binary" assert result["step_id"] == "options_binary"
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
"zone": "Zone 6", "zone": "Zone 6",
@ -838,7 +839,7 @@ async def test_option_flow(hass: HomeAssistant, mock_panel) -> None:
result["flow_id"], result["flow_id"],
user_input={"type": "window", "name": "winder", "inverse": True}, user_input={"type": "window", "name": "winder", "inverse": True},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_digital" assert result["step_id"] == "options_digital"
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
"zone": "Zone 3", "zone": "Zone 3",
@ -848,7 +849,7 @@ async def test_option_flow(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"type": "dht"} result["flow_id"], user_input={"type": "dht"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_switch" assert result["step_id"] == "options_switch"
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
"zone": "Zone 4", "zone": "Zone 4",
@ -859,7 +860,7 @@ async def test_option_flow(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_switch" assert result["step_id"] == "options_switch"
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
"zone": "OUT", "zone": "OUT",
@ -879,7 +880,7 @@ async def test_option_flow(hass: HomeAssistant, mock_panel) -> None:
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_switch" assert result["step_id"] == "options_switch"
assert result["description_placeholders"] == { assert result["description_placeholders"] == {
"zone": "OUT", "zone": "OUT",
@ -899,7 +900,7 @@ async def test_option_flow(hass: HomeAssistant, mock_panel) -> None:
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_misc" assert result["step_id"] == "options_misc"
# make sure we enforce url format # make sure we enforce url format
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -912,7 +913,7 @@ async def test_option_flow(hass: HomeAssistant, mock_panel) -> None:
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_misc" assert result["step_id"] == "options_misc"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], result["flow_id"],
@ -923,7 +924,7 @@ async def test_option_flow(hass: HomeAssistant, mock_panel) -> None:
"api_host": "http://overridehost:1111", "api_host": "http://overridehost:1111",
}, },
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
"io": { "io": {
"2": "Binary Sensor", "2": "Binary Sensor",
@ -988,7 +989,7 @@ async def test_option_flow_pro(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.options.async_init( result = await hass.config_entries.options.async_init(
entry.entry_id, context={"source": "test"} entry.entry_id, context={"source": "test"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_io" assert result["step_id"] == "options_io"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -1003,7 +1004,7 @@ async def test_option_flow_pro(hass: HomeAssistant, mock_panel) -> None:
"7": "Digital Sensor", "7": "Digital Sensor",
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_io_ext" assert result["step_id"] == "options_io_ext"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -1019,14 +1020,14 @@ async def test_option_flow_pro(hass: HomeAssistant, mock_panel) -> None:
"alarm2_out2": "Disabled", "alarm2_out2": "Disabled",
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_binary" assert result["step_id"] == "options_binary"
# zone 2 # zone 2
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"type": "door"} result["flow_id"], user_input={"type": "door"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_binary" assert result["step_id"] == "options_binary"
# zone 6 # zone 6
@ -1034,42 +1035,42 @@ async def test_option_flow_pro(hass: HomeAssistant, mock_panel) -> None:
result["flow_id"], result["flow_id"],
user_input={"type": "window", "name": "winder", "inverse": True}, user_input={"type": "window", "name": "winder", "inverse": True},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_binary" assert result["step_id"] == "options_binary"
# zone 10 # zone 10
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"type": "door"} result["flow_id"], user_input={"type": "door"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_binary" assert result["step_id"] == "options_binary"
# zone 11 # zone 11
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"type": "window"} result["flow_id"], user_input={"type": "window"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_digital" assert result["step_id"] == "options_digital"
# zone 3 # zone 3
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"type": "dht"} result["flow_id"], user_input={"type": "dht"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_digital" assert result["step_id"] == "options_digital"
# zone 7 # zone 7
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"type": "ds18b20", "name": "temper"} result["flow_id"], user_input={"type": "ds18b20", "name": "temper"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_switch" assert result["step_id"] == "options_switch"
# zone 4 # zone 4
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_switch" assert result["step_id"] == "options_switch"
# zone 8 # zone 8
@ -1083,21 +1084,21 @@ async def test_option_flow_pro(hass: HomeAssistant, mock_panel) -> None:
"repeat": 4, "repeat": 4,
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_switch" assert result["step_id"] == "options_switch"
# zone out1 # zone out1
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_switch" assert result["step_id"] == "options_switch"
# zone alarm1 # zone alarm1
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={} result["flow_id"], user_input={}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_misc" assert result["step_id"] == "options_misc"
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
@ -1105,7 +1106,7 @@ async def test_option_flow_pro(hass: HomeAssistant, mock_panel) -> None:
user_input={"discovery": False, "blink": True, "override_api_host": False}, user_input={"discovery": False, "blink": True, "override_api_host": False},
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
"io": { "io": {
"10": "Binary Sensor", "10": "Binary Sensor",
@ -1201,7 +1202,7 @@ async def test_option_flow_import(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.options.async_init( result = await hass.config_entries.options.async_init(
entry.entry_id, context={"source": "test"} entry.entry_id, context={"source": "test"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_io" assert result["step_id"] == "options_io"
# confirm the defaults are set based on current config - we"ll spot check this throughout # confirm the defaults are set based on current config - we"ll spot check this throughout
@ -1218,7 +1219,7 @@ async def test_option_flow_import(hass: HomeAssistant, mock_panel) -> None:
"3": "Switchable Output", "3": "Switchable Output",
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_io_ext" assert result["step_id"] == "options_io_ext"
schema = result["data_schema"]({}) schema = result["data_schema"]({})
assert schema["8"] == "Disabled" assert schema["8"] == "Disabled"
@ -1227,7 +1228,7 @@ async def test_option_flow_import(hass: HomeAssistant, mock_panel) -> None:
result["flow_id"], result["flow_id"],
user_input={}, user_input={},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_binary" assert result["step_id"] == "options_binary"
# zone 1 # zone 1
@ -1238,7 +1239,7 @@ async def test_option_flow_import(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"type": "door"} result["flow_id"], user_input={"type": "door"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_digital" assert result["step_id"] == "options_digital"
# zone 2 # zone 2
@ -1249,7 +1250,7 @@ async def test_option_flow_import(hass: HomeAssistant, mock_panel) -> None:
result["flow_id"], result["flow_id"],
user_input={"type": "dht"}, user_input={"type": "dht"},
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_switch" assert result["step_id"] == "options_switch"
# zone 3 # zone 3
@ -1263,7 +1264,7 @@ async def test_option_flow_import(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.options.async_configure( result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"activation": "high", "more_states": "No"} result["flow_id"], user_input={"activation": "high", "more_states": "No"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_misc" assert result["step_id"] == "options_misc"
schema = result["data_schema"]({}) schema = result["data_schema"]({})
@ -1275,7 +1276,7 @@ async def test_option_flow_import(hass: HomeAssistant, mock_panel) -> None:
) )
# verify the updated fields # verify the updated fields
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
"io": {"1": "Binary Sensor", "2": "Digital Sensor", "3": "Switchable Output"}, "io": {"1": "Binary Sensor", "2": "Digital Sensor", "3": "Switchable Output"},
"discovery": True, "discovery": True,
@ -1348,7 +1349,7 @@ async def test_option_flow_existing(hass: HomeAssistant, mock_panel) -> None:
result = await hass.config_entries.options.async_init( result = await hass.config_entries.options.async_init(
entry.entry_id, context={"source": "test"} entry.entry_id, context={"source": "test"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "options_io" assert result["step_id"] == "options_io"
# confirm the defaults are pulled in from the existing options # confirm the defaults are pulled in from the existing options

View file

@ -9,6 +9,7 @@ import pytest
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.kostal_plenticore.const import DOMAIN from homeassistant.components.kostal_plenticore.const import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -44,7 +45,7 @@ async def test_form_g1(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with patch( with patch(
@ -91,7 +92,7 @@ async def test_form_g1(
"scb:network", "Hostname" "scb:network", "Hostname"
) )
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "scb" assert result2["title"] == "scb"
assert result2["data"] == { assert result2["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -110,7 +111,7 @@ async def test_form_g2(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with patch( with patch(
@ -157,7 +158,7 @@ async def test_form_g2(
"scb:network", "Network:Hostname" "scb:network", "Network:Hostname"
) )
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "scb" assert result2["title"] == "scb"
assert result2["data"] == { assert result2["data"] == {
"host": "1.1.1.1", "host": "1.1.1.1",
@ -196,7 +197,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"password": "invalid_auth"} assert result2["errors"] == {"password": "invalid_auth"}
@ -230,7 +231,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"host": "cannot_connect"} assert result2["errors"] == {"host": "cannot_connect"}
@ -264,7 +265,7 @@ async def test_form_unexpected_error(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}
@ -288,5 +289,5 @@ async def test_already_configured(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"

View file

@ -5,6 +5,7 @@ from unittest.mock import patch
from homeassistant.components.kraken.const import CONF_TRACKED_ASSET_PAIRS, DOMAIN from homeassistant.components.kraken.const import CONF_TRACKED_ASSET_PAIRS, DOMAIN
from homeassistant.const import CONF_SCAN_INTERVAL from homeassistant.const import CONF_SCAN_INTERVAL
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .const import TICKER_INFORMATION_RESPONSE, TRADEABLE_ASSET_PAIR_RESPONSE from .const import TICKER_INFORMATION_RESPONSE, TRADEABLE_ASSET_PAIR_RESPONSE
@ -20,13 +21,13 @@ async def test_config_flow(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"} DOMAIN, context={"source": "user"}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -37,7 +38,7 @@ async def test_already_configured(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"} DOMAIN, context={"source": "user"}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -86,7 +87,7 @@ async def test_options(hass: HomeAssistant) -> None:
CONF_TRACKED_ASSET_PAIRS: ["ADA/ETH"], CONF_TRACKED_ASSET_PAIRS: ["ADA/ETH"],
}, },
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
await hass.async_block_till_done() await hass.async_block_till_done()
ada_eth_sensor = hass.states.get("sensor.ada_eth_ask") ada_eth_sensor = hass.states.get("sensor.ada_eth_ask")

View file

@ -7,6 +7,7 @@ import pykulersky
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components.kulersky.config_flow import DOMAIN from homeassistant.components.kulersky.config_flow import DOMAIN
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
async def test_flow_success(hass: HomeAssistant) -> None: async def test_flow_success(hass: HomeAssistant) -> None:
@ -15,7 +16,7 @@ async def test_flow_success(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
light = MagicMock(spec=pykulersky.Light) light = MagicMock(spec=pykulersky.Light)
@ -37,7 +38,7 @@ async def test_flow_success(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Kuler Sky" assert result2["title"] == "Kuler Sky"
assert result2["data"] == {} assert result2["data"] == {}
@ -50,7 +51,7 @@ async def test_flow_no_devices_found(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
with ( with (
@ -69,7 +70,7 @@ async def test_flow_no_devices_found(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "no_devices_found" assert result2["reason"] == "no_devices_found"
assert len(mock_setup_entry.mock_calls) == 0 assert len(mock_setup_entry.mock_calls) == 0
@ -80,7 +81,7 @@ async def test_flow_exceptions_caught(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
with ( with (
@ -99,6 +100,6 @@ async def test_flow_exceptions_caught(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "no_devices_found" assert result2["reason"] == "no_devices_found"
assert len(mock_setup_entry.mock_calls) == 0 assert len(mock_setup_entry.mock_calls) == 0

View file

@ -11,6 +11,7 @@ from homeassistant import config_entries
from homeassistant.components.lg_soundbar.const import DEFAULT_PORT, DOMAIN from homeassistant.components.lg_soundbar.const import DEFAULT_PORT, DOMAIN
from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -58,7 +59,7 @@ async def test_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -83,7 +84,7 @@ async def test_form(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "name" assert result2["title"] == "name"
assert result2["result"].unique_id == "uuid" assert result2["result"].unique_id == "uuid"
assert result2["data"] == { assert result2["data"] == {
@ -99,7 +100,7 @@ async def test_form_mac_info_response_empty(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -124,7 +125,7 @@ async def test_form_mac_info_response_empty(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "name" assert result2["title"] == "name"
assert result2["result"].unique_id == "uuid" assert result2["result"].unique_id == "uuid"
assert result2["data"] == { assert result2["data"] == {
@ -145,7 +146,7 @@ async def test_form_uuid_present_in_both_functions_uuid_q_empty(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -172,7 +173,7 @@ async def test_form_uuid_present_in_both_functions_uuid_q_empty(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "name" assert result2["title"] == "name"
assert result2["result"].unique_id == "uuid" assert result2["result"].unique_id == "uuid"
assert result2["data"] == { assert result2["data"] == {
@ -193,7 +194,7 @@ async def test_form_uuid_present_in_both_functions_uuid_q_not_empty(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -224,7 +225,7 @@ async def test_form_uuid_present_in_both_functions_uuid_q_not_empty(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "name" assert result2["title"] == "name"
assert result2["result"].unique_id == "uuid" assert result2["result"].unique_id == "uuid"
assert result2["data"] == { assert result2["data"] == {
@ -240,7 +241,7 @@ async def test_form_uuid_missing_from_mac_info(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -266,7 +267,7 @@ async def test_form_uuid_missing_from_mac_info(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "name" assert result2["title"] == "name"
assert result2["result"].unique_id == "uuid" assert result2["result"].unique_id == "uuid"
assert result2["data"] == { assert result2["data"] == {
@ -282,7 +283,7 @@ async def test_form_uuid_not_provided_by_api(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -311,7 +312,7 @@ async def test_form_uuid_not_provided_by_api(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "name" assert result2["title"] == "name"
assert result2["result"].unique_id is None assert result2["result"].unique_id is None
assert result2["data"] == { assert result2["data"] == {
@ -327,7 +328,7 @@ async def test_form_both_queues_empty(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -352,7 +353,7 @@ async def test_form_both_queues_empty(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "no_data"} assert result2["errors"] == {"base": "no_data"}
assert len(mock_setup_entry.mock_calls) == 0 assert len(mock_setup_entry.mock_calls) == 0
@ -373,7 +374,7 @@ async def test_no_uuid_host_already_configured(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -395,7 +396,7 @@ async def test_no_uuid_host_already_configured(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"
@ -416,7 +417,7 @@ async def test_form_socket_timeout(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -437,7 +438,7 @@ async def test_form_os_error(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -474,5 +475,5 @@ async def test_form_already_configured(hass: HomeAssistant) -> None:
}, },
) )
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"

View file

@ -41,13 +41,13 @@ async def test_discovery(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "pick_device" assert result2["step_id"] == "pick_device"
assert not result2["errors"] assert not result2["errors"]
@ -55,13 +55,13 @@ async def test_discovery(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "pick_device" assert result2["step_id"] == "pick_device"
assert not result2["errors"] assert not result2["errors"]
@ -77,7 +77,7 @@ async def test_discovery(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == DEFAULT_ENTRY_TITLE assert result3["title"] == DEFAULT_ENTRY_TITLE
assert result3["data"] == {CONF_HOST: IP_ADDRESS} assert result3["data"] == {CONF_HOST: IP_ADDRESS}
mock_setup.assert_called_once() mock_setup.assert_called_once()
@ -87,7 +87,7 @@ async def test_discovery(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -95,7 +95,7 @@ async def test_discovery(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "no_devices_found" assert result2["reason"] == "no_devices_found"
@ -106,13 +106,13 @@ async def test_discovery_but_cannot_connect(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "pick_device" assert result2["step_id"] == "pick_device"
assert not result2["errors"] assert not result2["errors"]
@ -122,7 +122,7 @@ async def test_discovery_but_cannot_connect(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "abort" assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "cannot_connect" assert result3["reason"] == "cannot_connect"
@ -140,7 +140,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -148,7 +148,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "pick_device" assert result2["step_id"] == "pick_device"
assert not result2["errors"] assert not result2["errors"]
@ -157,7 +157,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -165,7 +165,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "pick_device" assert result2["step_id"] == "pick_device"
assert not result2["errors"] assert not result2["errors"]
@ -177,7 +177,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result3 = await hass.config_entries.flow.async_configure( result3 = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_DEVICE: SERIAL} result["flow_id"], {CONF_DEVICE: SERIAL}
) )
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == DEFAULT_ENTRY_TITLE assert result3["title"] == DEFAULT_ENTRY_TITLE
assert result3["data"] == { assert result3["data"] == {
CONF_HOST: IP_ADDRESS, CONF_HOST: IP_ADDRESS,
@ -190,7 +190,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -198,7 +198,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "no_devices_found" assert result2["reason"] == "no_devices_found"
@ -215,7 +215,7 @@ async def test_discovery_no_device(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "no_devices_found" assert result2["reason"] == "no_devices_found"
@ -224,7 +224,7 @@ async def test_manual(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -238,7 +238,7 @@ async def test_manual(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "user" assert result2["step_id"] == "user"
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -253,7 +253,7 @@ async def test_manual(hass: HomeAssistant) -> None:
result["flow_id"], {CONF_HOST: IP_ADDRESS} result["flow_id"], {CONF_HOST: IP_ADDRESS}
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result4["type"] == "create_entry" assert result4["type"] is FlowResultType.CREATE_ENTRY
assert result4["title"] == DEFAULT_ENTRY_TITLE assert result4["title"] == DEFAULT_ENTRY_TITLE
assert result4["data"] == { assert result4["data"] == {
CONF_HOST: IP_ADDRESS, CONF_HOST: IP_ADDRESS,
@ -272,7 +272,7 @@ async def test_manual(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "abort" assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured" assert result2["reason"] == "already_configured"
@ -281,7 +281,7 @@ async def test_manual_dns_error(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -312,7 +312,7 @@ async def test_manual_dns_error(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "user" assert result2["step_id"] == "user"
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -322,7 +322,7 @@ async def test_manual_no_capabilities(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -337,7 +337,7 @@ async def test_manual_no_capabilities(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == { assert result["data"] == {
CONF_HOST: IP_ADDRESS, CONF_HOST: IP_ADDRESS,
} }
@ -448,7 +448,7 @@ async def test_discovered_by_dhcp_or_discovery(
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: IP_ADDRESS, CONF_HOST: IP_ADDRESS,
} }
@ -548,7 +548,7 @@ async def test_refuse_relays(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -560,7 +560,7 @@ async def test_refuse_relays(hass: HomeAssistant) -> None:
result["flow_id"], {CONF_HOST: IP_ADDRESS} result["flow_id"], {CONF_HOST: IP_ADDRESS}
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}

View file

@ -19,7 +19,7 @@ async def test_show_config_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -31,7 +31,7 @@ async def test_create_entry(hass: HomeAssistant, mock_litejet) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "/dev/test" assert result["title"] == "/dev/test"
assert result["data"] == test_data assert result["data"] == test_data
@ -50,7 +50,7 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "single_instance_allowed" assert result["reason"] == "single_instance_allowed"
@ -65,7 +65,7 @@ async def test_flow_open_failed(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"][CONF_PORT] == "open_failed" assert result["errors"][CONF_PORT] == "open_failed"

View file

@ -22,7 +22,7 @@ async def test_form(hass: HomeAssistant, mock_account) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {} assert result["errors"] == {}
with ( with (
@ -40,7 +40,7 @@ async def test_form(hass: HomeAssistant, mock_account) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == CONFIG[DOMAIN][CONF_USERNAME] assert result2["title"] == CONFIG[DOMAIN][CONF_USERNAME]
assert result2["data"] == CONFIG[DOMAIN] assert result2["data"] == CONFIG[DOMAIN]
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1
@ -59,7 +59,7 @@ async def test_already_configured(hass: HomeAssistant) -> None:
data=CONFIG[litterrobot.DOMAIN], data=CONFIG[litterrobot.DOMAIN],
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -77,7 +77,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
result["flow_id"], CONFIG[DOMAIN] result["flow_id"], CONFIG[DOMAIN]
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"} assert result2["errors"] == {"base": "invalid_auth"}
@ -95,7 +95,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
result["flow_id"], CONFIG[DOMAIN] result["flow_id"], CONFIG[DOMAIN]
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"} assert result2["errors"] == {"base": "cannot_connect"}
@ -112,7 +112,7 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
result["flow_id"], CONFIG[DOMAIN] result["flow_id"], CONFIG[DOMAIN]
) )
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"} assert result2["errors"] == {"base": "unknown"}

View file

@ -31,7 +31,7 @@ async def test_manual_setup(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -59,7 +59,7 @@ async def test_manual_setup_already_exists(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -78,7 +78,7 @@ async def test_manual_setup_device_offline(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -88,7 +88,7 @@ async def test_manual_setup_device_offline(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {CONF_HOST: "cannot_connect"} assert result["errors"] == {CONF_HOST: "cannot_connect"}
@ -97,7 +97,7 @@ async def test_manual_setup_unknown_exception(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
assert not result["errors"] assert not result["errors"]
@ -107,7 +107,7 @@ async def test_manual_setup_unknown_exception(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "unknown"} assert result["errors"] == {"base": "unknown"}

View file

@ -75,7 +75,7 @@ async def test_bridge_import_flow(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == CasetaConfigFlow.ENTRY_DEFAULT_TITLE assert result["title"] == CasetaConfigFlow.ENTRY_DEFAULT_TITLE
assert result["data"] == entry_mock_data assert result["data"] == entry_mock_data
assert result["result"].unique_id == "000004d2" assert result["result"].unique_id == "000004d2"
@ -102,7 +102,7 @@ async def test_bridge_cannot_connect(hass: HomeAssistant) -> None:
data=entry_mock_data, data=entry_mock_data,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == STEP_IMPORT_FAILED assert result["step_id"] == STEP_IMPORT_FAILED
assert result["errors"] == {"base": ERROR_CANNOT_CONNECT} assert result["errors"] == {"base": ERROR_CANNOT_CONNECT}
@ -125,7 +125,7 @@ async def test_bridge_cannot_connect_unknown_error(hass: HomeAssistant) -> None:
data=EMPTY_MOCK_CONFIG_ENTRY, data=EMPTY_MOCK_CONFIG_ENTRY,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == STEP_IMPORT_FAILED assert result["step_id"] == STEP_IMPORT_FAILED
assert result["errors"] == {"base": ERROR_CANNOT_CONNECT} assert result["errors"] == {"base": ERROR_CANNOT_CONNECT}
@ -145,7 +145,7 @@ async def test_bridge_invalid_ssl_error(hass: HomeAssistant) -> None:
data=EMPTY_MOCK_CONFIG_ENTRY, data=EMPTY_MOCK_CONFIG_ENTRY,
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == STEP_IMPORT_FAILED assert result["step_id"] == STEP_IMPORT_FAILED
assert result["errors"] == {"base": ERROR_CANNOT_CONNECT} assert result["errors"] == {"base": ERROR_CANNOT_CONNECT}
@ -195,7 +195,7 @@ async def test_already_configured_with_ignored(hass: HomeAssistant) -> None:
CONF_CA_CERTS: "", CONF_CA_CERTS: "",
}, },
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
async def test_form_user(hass: HomeAssistant, tmp_path: Path) -> None: async def test_form_user(hass: HomeAssistant, tmp_path: Path) -> None:
@ -207,7 +207,7 @@ async def test_form_user(hass: HomeAssistant, tmp_path: Path) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -218,7 +218,7 @@ async def test_form_user(hass: HomeAssistant, tmp_path: Path) -> None:
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "link" assert result2["step_id"] == "link"
with ( with (
@ -240,7 +240,7 @@ async def test_form_user(hass: HomeAssistant, tmp_path: Path) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "1.1.1.1" assert result3["title"] == "1.1.1.1"
assert result3["data"] == { assert result3["data"] == {
CONF_HOST: "1.1.1.1", CONF_HOST: "1.1.1.1",
@ -261,7 +261,7 @@ async def test_form_user_pairing_fails(hass: HomeAssistant, tmp_path: Path) -> N
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -272,7 +272,7 @@ async def test_form_user_pairing_fails(hass: HomeAssistant, tmp_path: Path) -> N
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "link" assert result2["step_id"] == "link"
with ( with (
@ -294,7 +294,7 @@ async def test_form_user_pairing_fails(hass: HomeAssistant, tmp_path: Path) -> N
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "form" assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {"base": "cannot_connect"} assert result3["errors"] == {"base": "cannot_connect"}
assert len(mock_setup.mock_calls) == 0 assert len(mock_setup.mock_calls) == 0
assert len(mock_setup_entry.mock_calls) == 0 assert len(mock_setup_entry.mock_calls) == 0
@ -311,7 +311,7 @@ async def test_form_user_reuses_existing_assets_when_pairing_again(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -322,7 +322,7 @@ async def test_form_user_reuses_existing_assets_when_pairing_again(
}, },
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "link" assert result2["step_id"] == "link"
with ( with (
@ -344,7 +344,7 @@ async def test_form_user_reuses_existing_assets_when_pairing_again(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "1.1.1.1" assert result3["title"] == "1.1.1.1"
assert result3["data"] == { assert result3["data"] == {
CONF_HOST: "1.1.1.1", CONF_HOST: "1.1.1.1",
@ -366,7 +366,7 @@ async def test_form_user_reuses_existing_assets_when_pairing_again(
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -380,7 +380,7 @@ async def test_form_user_reuses_existing_assets_when_pairing_again(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "form" assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "link" assert result2["step_id"] == "link"
with ( with (
@ -396,7 +396,7 @@ async def test_form_user_reuses_existing_assets_when_pairing_again(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result3["type"] == "create_entry" assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "1.1.1.1" assert result3["title"] == "1.1.1.1"
assert result3["data"] == { assert result3["data"] == {
CONF_HOST: "1.1.1.1", CONF_HOST: "1.1.1.1",
@ -433,7 +433,7 @@ async def test_zeroconf_host_already_configured(
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
@ -461,7 +461,7 @@ async def test_zeroconf_lutron_id_already_configured(hass: HomeAssistant) -> Non
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
assert config_entry.data[CONF_HOST] == "1.1.1.1" assert config_entry.data[CONF_HOST] == "1.1.1.1"
@ -484,7 +484,7 @@ async def test_zeroconf_not_lutron_device(hass: HomeAssistant) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_lutron_device" assert result["reason"] == "not_lutron_device"
@ -512,7 +512,7 @@ async def test_zeroconf(hass: HomeAssistant, source, tmp_path: Path) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link" assert result["step_id"] == "link"
with ( with (
@ -534,7 +534,7 @@ async def test_zeroconf(hass: HomeAssistant, source, tmp_path: Path) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "abc" assert result2["title"] == "abc"
assert result2["data"] == { assert result2["data"] == {
CONF_HOST: "1.1.1.1", CONF_HOST: "1.1.1.1",

View file

@ -52,7 +52,7 @@ async def test_form(hass: HomeAssistant, mock_login, mock_get_devices) -> None:
result = await hass.config_entries.flow.async_init( result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"] is None assert result["errors"] is None
with patch( with patch(
@ -64,7 +64,7 @@ async def test_form(hass: HomeAssistant, mock_login, mock_get_devices) -> None:
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result2["type"] == "create_entry" assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "test-email@test-domain.com" assert result2["title"] == "test-email@test-domain.com"
assert result2["data"] == { assert result2["data"] == {
"username": "test-email@test-domain.com", "username": "test-email@test-domain.com",
@ -90,7 +90,7 @@ async def test_form_errors(
) )
assert len(mock_login.mock_calls) == 1 assert len(mock_login.mock_calls) == 1
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == reason assert result["reason"] == reason
@ -114,7 +114,7 @@ async def test_form_response_errors(
data={"username": "test-email@test-domain.com", "password": "test-password"}, data={"username": "test-email@test-domain.com", "password": "test-password"},
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == message assert result["reason"] == message
@ -139,7 +139,7 @@ async def test_token_refresh(hass: HomeAssistant, mock_login, mock_get_devices)
}, },
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured" assert result["reason"] == "already_configured"
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(mock_setup_entry.mock_calls) == 0 assert len(mock_setup_entry.mock_calls) == 0

View file

@ -9,6 +9,7 @@ from homeassistant.components.met.const import DOMAIN, HOME_LOCATION_NAME
from homeassistant.config import async_process_ha_core_config from homeassistant.config import async_process_ha_core_config
from homeassistant.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME from homeassistant.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import init_integration from . import init_integration
@ -31,7 +32,7 @@ async def test_show_config_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
@ -49,7 +50,7 @@ async def test_flow_with_home_location(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER} DOMAIN, context={"source": config_entries.SOURCE_USER}
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user" assert result["step_id"] == "user"
default_data = result["data_schema"]({}) default_data = result["data_schema"]({})
@ -72,7 +73,7 @@ async def test_create_entry(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "home" assert result["title"] == "home"
assert result["data"] == test_data assert result["data"] == test_data
@ -100,7 +101,7 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data DOMAIN, context={"source": config_entries.SOURCE_USER}, data=test_data
) )
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["errors"]["name"] == "already_configured" assert result["errors"]["name"] == "already_configured"
@ -110,7 +111,7 @@ async def test_onboarding_step(hass: HomeAssistant) -> None:
DOMAIN, context={"source": "onboarding"}, data={} DOMAIN, context={"source": "onboarding"}, data={}
) )
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == HOME_LOCATION_NAME assert result["title"] == HOME_LOCATION_NAME
assert result["data"] == {"track_home": True} assert result["data"] == {"track_home": True}
@ -134,7 +135,7 @@ async def test_onboarding_step_abort_no_home(
DOMAIN, context={"source": "onboarding"}, data={} DOMAIN, context={"source": "onboarding"}, data={}
) )
assert result["type"] == "abort" assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_home" assert result["reason"] == "no_home"
@ -153,7 +154,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
# Test show Options form # Test show Options form
result = await hass.config_entries.options.async_init(entry.entry_id) result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == "form" assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init" assert result["step_id"] == "init"
# Test Options flow updated config entry # Test Options flow updated config entry
@ -164,7 +165,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
entry.entry_id, data=update_data entry.entry_id, data=update_data
) )
await hass.async_block_till_done() await hass.async_block_till_done()
assert result["type"] == "create_entry" assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Mock Title" assert result["title"] == "Mock Title"
assert result["data"] == update_data assert result["data"] == update_data
weatherdatamock.assert_called_with( weatherdatamock.assert_called_with(

Some files were not shown because too many files have changed in this diff Show more