diff --git a/tests/components/accuweather/test_config_flow.py b/tests/components/accuweather/test_config_flow.py index acac15204f9..bc75ef17309 100644 --- a/tests/components/accuweather/test_config_flow.py +++ b/tests/components/accuweather/test_config_flow.py @@ -113,7 +113,7 @@ async def test_integration_already_exists(hass: HomeAssistant) -> None: data=VALID_CONFIG, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "single_instance_allowed" diff --git a/tests/components/acmeda/test_config_flow.py b/tests/components/acmeda/test_config_flow.py index 1b79e37cab3..5227d283f25 100644 --- a/tests/components/acmeda/test_config_flow.py +++ b/tests/components/acmeda/test_config_flow.py @@ -146,5 +146,5 @@ async def test_already_configured(hass: HomeAssistant, mock_hub_discover) -> Non DOMAIN, context={"source": SOURCE_USER} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "no_devices_found" diff --git a/tests/components/adax/test_config_flow.py b/tests/components/adax/test_config_flow.py index 40640c66143..579ca2019f8 100644 --- a/tests/components/adax/test_config_flow.py +++ b/tests/components/adax/test_config_flow.py @@ -58,7 +58,7 @@ async def test_form(hass: HomeAssistant) -> None: ) 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["data"] == { 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() - assert result3["type"] == "abort" + assert result3["type"] is FlowResultType.ABORT assert result3["reason"] == "already_configured" @@ -173,7 +173,7 @@ async def test_local_create_entry(hass: HomeAssistant) -> None: ) test_data[CONNECTION_TYPE] = LOCAL - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "8383838" assert result["data"] == { "connection_type": "Local", @@ -229,7 +229,7 @@ async def test_local_flow_entry_already_exists(hass: HomeAssistant) -> None: test_data, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/adguard/test_config_flow.py b/tests/components/adguard/test_config_flow.py index 3229a753699..d493962611f 100644 --- a/tests/components/adguard/test_config_flow.py +++ b/tests/components/adguard/test_config_flow.py @@ -116,7 +116,7 @@ async def test_integration_already_exists(hass: HomeAssistant) -> None: context={"source": config_entries.SOURCE_USER}, ) assert result - assert result.get("type") == "abort" + assert result.get("type") is FlowResultType.ABORT assert result.get("reason") == "already_configured" diff --git a/tests/components/aemet/test_config_flow.py b/tests/components/aemet/test_config_flow.py index a9a2d45f618..45fec473396 100644 --- a/tests/components/aemet/test_config_flow.py +++ b/tests/components/aemet/test_config_flow.py @@ -127,7 +127,7 @@ async def test_form_duplicated_id( DOMAIN, context={"source": SOURCE_USER}, data=CONFIG ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/airly/test_config_flow.py b/tests/components/airly/test_config_flow.py index 96f4d95995b..7c0cac805d3 100644 --- a/tests/components/airly/test_config_flow.py +++ b/tests/components/airly/test_config_flow.py @@ -98,7 +98,7 @@ async def test_duplicate_error( DOMAIN, context={"source": SOURCE_USER}, data=CONFIG ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/airnow/test_config_flow.py b/tests/components/airnow/test_config_flow.py index 740adec4b00..b62cb43844b 100644 --- a/tests/components/airnow/test_config_flow.py +++ b/tests/components/airnow/test_config_flow.py @@ -35,7 +35,7 @@ async def test_form_invalid_auth(hass: HomeAssistant, config, setup_airnow) -> N DOMAIN, context={"source": config_entries.SOURCE_USER} ) 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"} @@ -46,7 +46,7 @@ async def test_form_invalid_location(hass: HomeAssistant, config, setup_airnow) DOMAIN, context={"source": config_entries.SOURCE_USER} ) 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"} @@ -57,7 +57,7 @@ async def test_form_cannot_connect(hass: HomeAssistant, config, setup_airnow) -> DOMAIN, context={"source": config_entries.SOURCE_USER} ) 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"} @@ -68,7 +68,7 @@ async def test_form_empty_result(hass: HomeAssistant, config, setup_airnow) -> N DOMAIN, context={"source": config_entries.SOURCE_USER} ) 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"} @@ -79,7 +79,7 @@ async def test_form_unexpected(hass: HomeAssistant, config, setup_airnow) -> Non DOMAIN, context={"source": config_entries.SOURCE_USER} ) 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"} @@ -89,7 +89,7 @@ async def test_entry_already_exists(hass: HomeAssistant, config, config_entry) - DOMAIN, context={"source": config_entries.SOURCE_USER} ) 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" diff --git a/tests/components/airthings/test_config_flow.py b/tests/components/airthings/test_config_flow.py index ff4cdfa30d2..081e1bfd86d 100644 --- a/tests/components/airthings/test_config_flow.py +++ b/tests/components/airthings/test_config_flow.py @@ -121,5 +121,5 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None: 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" diff --git a/tests/components/airtouch4/test_config_flow.py b/tests/components/airtouch4/test_config_flow.py index e5e3672f69d..d574531faa7 100644 --- a/tests/components/airtouch4/test_config_flow.py +++ b/tests/components/airtouch4/test_config_flow.py @@ -7,6 +7,7 @@ from airtouch4pyapi.airtouch import AirTouch, AirTouchAc, AirTouchGroup, AirTouc from homeassistant import config_entries from homeassistant.components.airtouch4.const import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None mock_ac = AirTouchAc() mock_groups = AirTouchGroup() @@ -39,7 +40,7 @@ async def test_form(hass: HomeAssistant) -> None: ) 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["data"] == { "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( result["flow_id"], {"host": "0.0.0.1"} ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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( result["flow_id"], {"host": "0.0.0.1"} ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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( result["flow_id"], {"host": "0.0.0.1"} ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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"} ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "no_units"} diff --git a/tests/components/airzone/test_config_flow.py b/tests/components/airzone/test_config_flow.py index 090674d5fd2..072699c7a26 100644 --- a/tests/components/airzone/test_config_flow.py +++ b/tests/components/airzone/test_config_flow.py @@ -177,7 +177,7 @@ async def test_form_duplicated_id(hass: HomeAssistant) -> None: DOMAIN, context={"source": SOURCE_USER}, data=CONFIG ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/aladdin_connect/test_config_flow.py b/tests/components/aladdin_connect/test_config_flow.py index d41b88de8e4..65b8b24a59d 100644 --- a/tests/components/aladdin_connect/test_config_flow.py +++ b/tests/components/aladdin_connect/test_config_flow.py @@ -116,7 +116,7 @@ async def test_form_already_configured( 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 with patch( @@ -132,7 +132,7 @@ async def test_form_already_configured( ) await hass.async_block_till_done() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT assert result2["reason"] == "already_configured" diff --git a/tests/components/androidtv_remote/test_config_flow.py b/tests/components/androidtv_remote/test_config_flow.py index eb51f9465c3..8778630be8d 100644 --- a/tests/components/androidtv_remote/test_config_flow.py +++ b/tests/components/androidtv_remote/test_config_flow.py @@ -880,7 +880,7 @@ async def test_options_flow( # Trigger options flow, first time 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" data_schema = result["data_schema"].schema assert set(data_schema) == {"enable_ime"} @@ -889,7 +889,7 @@ async def test_options_flow( result["flow_id"], 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} await hass.async_block_till_done() @@ -902,7 +902,7 @@ async def test_options_flow( result["flow_id"], 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} await hass.async_block_till_done() @@ -915,7 +915,7 @@ async def test_options_flow( result["flow_id"], 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} await hass.async_block_till_done() diff --git a/tests/components/apple_tv/test_config_flow.py b/tests/components/apple_tv/test_config_flow.py index e7025890ec4..e7bfa68bdaf 100644 --- a/tests/components/apple_tv/test_config_flow.py +++ b/tests/components/apple_tv/test_config_flow.py @@ -136,7 +136,7 @@ async def test_user_adds_full_device(hass: HomeAssistant, full_device, pairing) result6 = await hass.config_entries.flow.async_configure( result["flow_id"], {"pin": 1234} ) - assert result6["type"] == "create_entry" + assert result6["type"] is FlowResultType.CREATE_ENTRY assert result6["data"] == { "address": "127.0.0.1", "credentials": { @@ -174,7 +174,7 @@ async def test_user_adds_dmap_device( result6 = await hass.config_entries.flow.async_configure( result["flow_id"], {"pin": 1234} ) - assert result6["type"] == "create_entry" + assert result6["type"] is FlowResultType.CREATE_ENTRY assert result6["data"] == { "address": "127.0.0.1", "credentials": {Protocol.DMAP.value: "dmap_creds"}, @@ -540,7 +540,7 @@ async def test_ignores_disabled_service( result3 = await hass.config_entries.flow.async_configure( result["flow_id"], {"pin": 1111} ) - assert result3["type"] == "create_entry" + assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["data"] == { "address": "127.0.0.1", "credentials": { @@ -621,7 +621,7 @@ async def test_zeroconf_add_mrp_device( result3 = await hass.config_entries.flow.async_configure( result["flow_id"], {"pin": 1111} ) - assert result3["type"] == "create_entry" + assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["data"] == { "address": "127.0.0.1", "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"} 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"] == { "address": "127.0.0.1", "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( 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] diff --git a/tests/components/aurora/test_config_flow.py b/tests/components/aurora/test_config_flow.py index a6d6a67cf30..a91c4eb8bc9 100644 --- a/tests/components/aurora/test_config_flow.py +++ b/tests/components/aurora/test_config_flow.py @@ -23,7 +23,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -42,7 +42,7 @@ async def test_form(hass: HomeAssistant) -> None: ) 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["data"] == DATA assert len(mock_setup_entry.mock_calls) == 1 @@ -64,7 +64,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None: DATA, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {"base": "cannot_connect"} @@ -85,7 +85,7 @@ async def test_with_unknown_error(hass: HomeAssistant) -> None: DATA, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {"base": "unknown"} diff --git a/tests/components/aurora_abb_powerone/test_config_flow.py b/tests/components/aurora_abb_powerone/test_config_flow.py index 91ab362b5bc..9c27c14d633 100644 --- a/tests/components/aurora_abb_powerone/test_config_flow.py +++ b/tests/components/aurora_abb_powerone/test_config_flow.py @@ -31,7 +31,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -91,7 +91,7 @@ async def test_form_no_comports(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with patch( diff --git a/tests/components/aussie_broadband/test_config_flow.py b/tests/components/aussie_broadband/test_config_flow.py index bc7ed8b8167..6ee674ab0f4 100644 --- a/tests/components/aussie_broadband/test_config_flow.py +++ b/tests/components/aussie_broadband/test_config_flow.py @@ -233,5 +233,5 @@ async def test_reauth(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result7["type"] == "abort" + assert result7["type"] is FlowResultType.ABORT assert result7["reason"] == "reauth_successful" diff --git a/tests/components/azure_event_hub/test_config_flow.py b/tests/components/azure_event_hub/test_config_flow.py index 70914f0ee83..cedbc5b43d6 100644 --- a/tests/components/azure_event_hub/test_config_flow.py +++ b/tests/components/azure_event_hub/test_config_flow.py @@ -56,14 +56,14 @@ async def test_form( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=None ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None result2 = await hass.config_entries.flow.async_configure( result["flow_id"], step1_config.copy(), ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == step_id result3 = await hass.config_entries.flow.async_configure( result2["flow_id"], @@ -136,7 +136,7 @@ async def test_connection_error_sas( context={"source": config_entries.SOURCE_USER}, data=BASE_CONFIG_SAS.copy(), ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None mock_get_eventhub_properties.side_effect = side_effect @@ -165,7 +165,7 @@ async def test_connection_error_cs( context={"source": config_entries.SOURCE_USER}, data=BASE_CONFIG_CS.copy(), ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None mock_from_connection_string.return_value.get_eventhub_properties.side_effect = ( side_effect diff --git a/tests/components/baf/test_config_flow.py b/tests/components/baf/test_config_flow.py index cf91be0d400..765801d22cf 100644 --- a/tests/components/baf/test_config_flow.py +++ b/tests/components/baf/test_config_flow.py @@ -30,7 +30,7 @@ async def test_form_user(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -113,7 +113,7 @@ async def test_zeroconf_discovery(hass: HomeAssistant) -> None: ) 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["data"] == {CONF_IP_ADDRESS: "127.0.0.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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( diff --git a/tests/components/blebox/test_config_flow.py b/tests/components/blebox/test_config_flow.py index e94553e10cf..7213b33555c 100644 --- a/tests/components/blebox/test_config_flow.py +++ b/tests/components/blebox/test_config_flow.py @@ -66,7 +66,7 @@ async def test_flow_works( config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "My gate controller" assert result["data"] == { config_flow.CONF_HOST: "172.2.3.4", diff --git a/tests/components/blink/test_config_flow.py b/tests/components/blink/test_config_flow.py index 10b34fa532c..82ea847dcf2 100644 --- a/tests/components/blink/test_config_flow.py +++ b/tests/components/blink/test_config_flow.py @@ -17,7 +17,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -37,7 +37,7 @@ async def test_form(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "blink" assert result2["result"].unique_id == "blink@example.com" assert result2["data"] == { @@ -72,7 +72,7 @@ async def test_form_2fa(hass: HomeAssistant) -> None: {"username": "blink@example.com", "password": "example"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "2fa" with ( @@ -98,7 +98,7 @@ async def test_form_2fa(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result3["type"] == "create_entry" + assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["title"] == "blink" assert result3["result"].unique_id == "blink@example.com" 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"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "2fa" with ( @@ -149,7 +149,7 @@ async def test_form_2fa_connect_error(hass: HomeAssistant) -> None: result2["flow_id"], {"pin": "1234"} ) - assert result3["type"] == "form" + assert result3["type"] is FlowResultType.FORM 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"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "2fa" with ( @@ -200,7 +200,7 @@ async def test_form_2fa_invalid_key(hass: HomeAssistant) -> None: result2["flow_id"], {"pin": "1234"} ) - assert result3["type"] == "form" + assert result3["type"] is FlowResultType.FORM 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"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "2fa" with ( @@ -249,7 +249,7 @@ async def test_form_2fa_unknown_error(hass: HomeAssistant) -> None: result2["flow_id"], {"pin": "1234"} ) - assert result3["type"] == "form" + assert result3["type"] is FlowResultType.FORM 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"} ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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"} ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "unknown"} diff --git a/tests/components/bond/test_config_flow.py b/tests/components/bond/test_config_flow.py index bfe61c536d9..d61ed4844a1 100644 --- a/tests/components/bond/test_config_flow.py +++ b/tests/components/bond/test_config_flow.py @@ -15,6 +15,7 @@ from homeassistant.components.bond.const import DOMAIN from homeassistant.config_entries import ConfigEntryState from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from .common import ( patch_bond_bridge, @@ -35,7 +36,7 @@ async def test_user_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -53,7 +54,7 @@ async def test_user_form(hass: HomeAssistant) -> None: ) 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["data"] == { 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -90,7 +91,7 @@ async def test_user_form_with_non_bridge(hass: HomeAssistant) -> None: ) 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["data"] == { 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"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT assert result2["reason"] == "already_configured" assert len(mock_setup_entry.mock_calls) == 0 @@ -228,7 +229,7 @@ async def test_zeroconf_form(hass: HomeAssistant) -> None: type="mock_type", ), ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -243,7 +244,7 @@ async def test_zeroconf_form(hass: HomeAssistant) -> None: ) 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["data"] == { 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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -285,7 +286,7 @@ async def test_zeroconf_form_token_unavailable(hass: HomeAssistant) -> None: ) 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["data"] == { 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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -327,7 +328,7 @@ async def test_zeroconf_form_token_times_out(hass: HomeAssistant) -> None: ) 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["data"] == { 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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "discovered-name" assert result2["data"] == { 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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "ZXXX12345" assert result2["data"] == { 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() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" assert entry.data["host"] == "127.0.0.2" 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() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" assert entry.data["host"] == "127.0.0.2" 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() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" assert entry.data["host"] == "127.0.0.2" 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() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" assert len(mock_setup_entry.mock_calls) == 0 @@ -618,7 +619,7 @@ async def _help_test_form_unexpected_error( result["flow_id"], user_input ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "unknown"} diff --git a/tests/components/bosch_shc/test_config_flow.py b/tests/components/bosch_shc/test_config_flow.py index 2fe2b98308d..b3a28151c93 100644 --- a/tests/components/bosch_shc/test_config_flow.py +++ b/tests/components/bosch_shc/test_config_flow.py @@ -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.const import CONF_SHC_CERT, CONF_SHC_KEY, DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -65,7 +66,7 @@ async def test_form_user(hass: HomeAssistant, mock_zeroconf: None) -> None: {"host": "1.1.1.1"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "credentials" assert result2["errors"] == {} @@ -92,7 +93,7 @@ async def test_form_user(hass: HomeAssistant, mock_zeroconf: None) -> None: ) await hass.async_block_till_done() - assert result3["type"] == "create_entry" + assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["title"] == "shc012345" assert result3["data"] == { "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["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["errors"] == {"base": "unknown"} @@ -179,7 +180,7 @@ async def test_form_pairing_error(hass: HomeAssistant, mock_zeroconf: None) -> N {"host": "1.1.1.1"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "credentials" 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() - assert result3["type"] == "form" + assert result3["type"] is FlowResultType.FORM assert result3["step_id"] == "credentials" 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"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "credentials" 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() - assert result3["type"] == "form" + assert result3["type"] is FlowResultType.FORM assert result3["step_id"] == "credentials" assert result3["errors"] == {"base": "invalid_auth"} @@ -285,7 +286,7 @@ async def test_form_validate_connection_error( {"host": "1.1.1.1"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "credentials" assert result2["errors"] == {} @@ -311,7 +312,7 @@ async def test_form_validate_connection_error( ) await hass.async_block_till_done() - assert result3["type"] == "form" + assert result3["type"] is FlowResultType.FORM assert result3["step_id"] == "credentials" assert result3["errors"] == {"base": "cannot_connect"} @@ -345,7 +346,7 @@ async def test_form_validate_session_error( {"host": "1.1.1.1"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "credentials" assert result2["errors"] == {} @@ -371,7 +372,7 @@ async def test_form_validate_session_error( ) await hass.async_block_till_done() - assert result3["type"] == "form" + assert result3["type"] is FlowResultType.FORM assert result3["step_id"] == "credentials" assert result3["errors"] == {"base": "session_error"} @@ -405,7 +406,7 @@ async def test_form_validate_exception( {"host": "1.1.1.1"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "credentials" assert result2["errors"] == {} @@ -431,7 +432,7 @@ async def test_form_validate_exception( ) await hass.async_block_till_done() - assert result3["type"] == "form" + assert result3["type"] is FlowResultType.FORM assert result3["step_id"] == "credentials" assert result3["errors"] == {"base": "unknown"} @@ -471,7 +472,7 @@ async def test_form_already_configured( {"host": "1.1.1.1"}, ) - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT assert result2["reason"] == "already_configured" # 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, context={"source": config_entries.SOURCE_ZEROCONF}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "confirm_discovery" assert result["errors"] == {} context = next( @@ -516,7 +517,7 @@ async def test_zeroconf(hass: HomeAssistant, mock_zeroconf: None) -> None: result["flow_id"], {}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "credentials" with ( @@ -544,7 +545,7 @@ async def test_zeroconf(hass: HomeAssistant, mock_zeroconf: None) -> None: ) await hass.async_block_till_done() - assert result3["type"] == "create_entry" + assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["title"] == "shc012345" assert result3["data"] == { "host": "1.1.1.1", @@ -588,7 +589,7 @@ async def test_zeroconf_already_configured( context={"source": config_entries.SOURCE_ZEROCONF}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" # Test config entry got updated with latest IP @@ -607,7 +608,7 @@ async def test_zeroconf_cannot_connect( data=DISCOVERY_INFO, context={"source": config_entries.SOURCE_ZEROCONF}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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}, data=mock_config.data, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" with ( @@ -674,7 +675,7 @@ async def test_reauth(hass: HomeAssistant, mock_zeroconf: None) -> None: {"host": "2.2.2.2"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "credentials" assert result2["errors"] == {} @@ -701,7 +702,7 @@ async def test_reauth(hass: HomeAssistant, mock_zeroconf: None) -> None: ) await hass.async_block_till_done() - assert result3["type"] == "abort" + assert result3["type"] is FlowResultType.ABORT assert result3["reason"] == "reauth_successful" assert mock_config.data["host"] == "2.2.2.2" diff --git a/tests/components/bring/test_config_flow.py b/tests/components/bring/test_config_flow.py index be5ce48680c..351ba533101 100644 --- a/tests/components/bring/test_config_flow.py +++ b/tests/components/bring/test_config_flow.py @@ -86,7 +86,7 @@ async def test_flow_user_init_data_unknown_error_and_recover( 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["data"] == MOCK_DATA_STEP diff --git a/tests/components/broadlink/test_config_flow.py b/tests/components/broadlink/test_config_flow.py index 143742d3a9a..2def8c0b3b9 100644 --- a/tests/components/broadlink/test_config_flow.py +++ b/tests/components/broadlink/test_config_flow.py @@ -11,6 +11,7 @@ from homeassistant import config_entries from homeassistant.components import dhcp from homeassistant.components.broadlink.const import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from . import get_device @@ -42,7 +43,7 @@ async def test_flow_user_works(hass: HomeAssistant) -> None: DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -52,7 +53,7 @@ async def test_flow_user_works(hass: HomeAssistant) -> None: {"host": device.host, "timeout": device.timeout}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "finish" assert result["errors"] == {} @@ -61,7 +62,7 @@ async def test_flow_user_works(hass: HomeAssistant) -> None: {"name": device.name}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == device.name 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}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" 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"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {"base": "invalid_host"} @@ -156,7 +157,7 @@ async def test_flow_user_invalid_hostname(hass: HomeAssistant) -> None: {"host": "pancakemaster.local"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {"base": "invalid_host"} @@ -175,7 +176,7 @@ async def test_flow_user_device_not_found(hass: HomeAssistant) -> None: {"host": device.host}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {"base": "cannot_connect"} @@ -195,7 +196,7 @@ async def test_flow_user_device_not_supported(hass: HomeAssistant) -> None: {"host": device.host}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "not_supported" @@ -211,7 +212,7 @@ async def test_flow_user_network_unreachable(hass: HomeAssistant) -> None: {"host": "192.168.1.32"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reset" assert result["errors"] == {"base": "invalid_auth"} @@ -270,7 +271,7 @@ async def test_flow_auth_network_timeout(hass: HomeAssistant) -> None: {"host": device.host}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "auth" assert result["errors"] == {"base": "cannot_connect"} @@ -291,7 +292,7 @@ async def test_flow_auth_firmware_error(hass: HomeAssistant) -> None: {"host": device.host}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "auth" assert result["errors"] == {"base": "unknown"} @@ -312,7 +313,7 @@ async def test_flow_auth_network_unreachable(hass: HomeAssistant) -> None: {"host": device.host}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "auth" assert result["errors"] == {"base": "cannot_connect"} @@ -333,7 +334,7 @@ async def test_flow_auth_os_error(hass: HomeAssistant) -> None: {"host": device.host}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "auth" assert result["errors"] == {"base": "unknown"} @@ -365,7 +366,7 @@ async def test_flow_reset_works(hass: HomeAssistant) -> None: {"name": device.name}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == device.name 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}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "unlock" assert result["errors"] == {} @@ -400,7 +401,7 @@ async def test_flow_unlock_works(hass: HomeAssistant) -> None: {"name": device.name}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == device.name assert result["data"] == device.get_entry_data() @@ -430,7 +431,7 @@ async def test_flow_unlock_network_timeout(hass: HomeAssistant) -> None: {"unlock": True}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "unlock" assert result["errors"] == {"base": "cannot_connect"} @@ -457,7 +458,7 @@ async def test_flow_unlock_firmware_error(hass: HomeAssistant) -> None: {"unlock": True}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "unlock" assert result["errors"] == {"base": "unknown"} @@ -484,7 +485,7 @@ async def test_flow_unlock_network_unreachable(hass: HomeAssistant) -> None: {"unlock": True}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "unlock" assert result["errors"] == {"base": "cannot_connect"} @@ -511,7 +512,7 @@ async def test_flow_unlock_os_error(hass: HomeAssistant) -> None: {"unlock": True}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "unlock" assert result["errors"] == {"base": "unknown"} @@ -542,7 +543,7 @@ async def test_flow_do_not_unlock(hass: HomeAssistant) -> None: {"name": device.name}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == device.name assert result["data"] == device.get_entry_data() @@ -561,7 +562,7 @@ async def test_flow_import_works(hass: HomeAssistant) -> None: data={"host": device.host}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "finish" assert result["errors"] == {} @@ -570,7 +571,7 @@ async def test_flow_import_works(hass: HomeAssistant) -> None: {"name": device.name}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == device.name assert result["data"]["host"] == device.host 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 ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -636,7 +637,7 @@ async def test_flow_import_mac_already_configured(hass: HomeAssistant) -> None: data={"host": device.host}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" 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"}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "cannot_connect" @@ -670,7 +671,7 @@ async def test_flow_import_device_not_supported(hass: HomeAssistant) -> None: data={"host": device.host}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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"}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "invalid_host" @@ -696,7 +697,7 @@ async def test_flow_import_invalid_hostname(hass: HomeAssistant) -> None: data={"host": "hotdog.local"}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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"}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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"}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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 ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reset" 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}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" 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}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" 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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "finish" 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "Living Room" assert result2["data"] == { "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() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "cannot_connect" @@ -899,7 +900,7 @@ async def test_dhcp_unreachable(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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" @@ -964,7 +965,7 @@ async def test_dhcp_already_exists(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -989,6 +990,6 @@ async def test_dhcp_updates_host(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" assert mock_entry.data["host"] == "4.5.6.7" diff --git a/tests/components/brunt/test_config_flow.py b/tests/components/brunt/test_config_flow.py index 6c4d928c0ca..2796882a3c1 100644 --- a/tests/components/brunt/test_config_flow.py +++ b/tests/components/brunt/test_config_flow.py @@ -24,7 +24,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}, data=None ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None with patch( diff --git a/tests/components/buienradar/test_config_flow.py b/tests/components/buienradar/test_config_flow.py index 9fb0d9c4c48..316cb90a348 100644 --- a/tests/components/buienradar/test_config_flow.py +++ b/tests/components/buienradar/test_config_flow.py @@ -22,7 +22,7 @@ async def test_config_flow_setup_(hass: HomeAssistant) -> None: DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -31,7 +31,7 @@ async def test_config_flow_setup_(hass: HomeAssistant) -> None: {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["data"] == { 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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "init" result = await hass.config_entries.options.async_configure( diff --git a/tests/components/caldav/test_config_flow.py b/tests/components/caldav/test_config_flow.py index e7cbf9dd7ea..c6d5552c874 100644 --- a/tests/components/caldav/test_config_flow.py +++ b/tests/components/caldav/test_config_flow.py @@ -113,7 +113,7 @@ async def test_reauth_success( "entry_id": config_entry.entry_id, }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" result2 = await hass.config_entries.flow.async_configure( @@ -154,7 +154,7 @@ async def test_reauth_failure( "entry_id": config_entry.entry_id, }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" dav_client.return_value.principal.side_effect = DAVError diff --git a/tests/components/cast/test_config_flow.py b/tests/components/cast/test_config_flow.py index ab24aa4df5c..2c0c36d6632 100644 --- a/tests/components/cast/test_config_flow.py +++ b/tests/components/cast/test_config_flow.py @@ -55,7 +55,7 @@ async def test_single_instance(hass: HomeAssistant, source) -> None: result = await hass.config_entries.flow.async_init( "cast", context={"source": source} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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( "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"], {}) users = await hass.auth.async_get_users() 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 == { "ignore_cec": [], "known_hosts": [], @@ -84,7 +84,7 @@ async def test_user_setup_options(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( "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"], {"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() 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 == { "ignore_cec": [], "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( "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"], {}) users = await hass.auth.async_get_users() 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 == { "ignore_cec": [], "known_hosts": [], @@ -132,7 +132,7 @@ async def test_zeroconf_setup_onboarding(hass: HomeAssistant) -> None: users = await hass.auth.async_get_users() 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 == { "ignore_cec": [], "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["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) config_entry = hass.config_entries.async_entries("cast")[0] diff --git a/tests/components/cloud/test_config_flow.py b/tests/components/cloud/test_config_flow.py index 6b506d6b883..9f6e1762482 100644 --- a/tests/components/cloud/test_config_flow.py +++ b/tests/components/cloud/test_config_flow.py @@ -4,6 +4,7 @@ from unittest.mock import patch from homeassistant.components.cloud.const import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType 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( DOMAIN, context={"source": "system"} ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "Home Assistant Cloud" assert result["data"] == {} 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( DOMAIN, context={"source": "system"} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "single_instance_allowed" diff --git a/tests/components/coinbase/test_config_flow.py b/tests/components/coinbase/test_config_flow.py index 79b0115bc7c..f213392bb1e 100644 --- a/tests/components/coinbase/test_config_flow.py +++ b/tests/components/coinbase/test_config_flow.py @@ -16,6 +16,7 @@ from homeassistant.components.coinbase.const import ( ) from homeassistant.const import CONF_API_KEY, CONF_API_TOKEN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from .common import ( init_mock_coinbase, @@ -32,7 +33,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -59,7 +60,7 @@ async def test_form(hass: HomeAssistant) -> None: ) 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["data"] == {CONF_API_KEY: "123456", CONF_API_TOKEN: "AbCDeF"} 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 "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 "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 ( "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"} @@ -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"} @@ -219,7 +220,7 @@ async def test_option_form(hass: HomeAssistant) -> None: CONF_EXCHANGE_PRECISION: 5, }, ) - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY await hass.async_block_till_done() 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"} @@ -277,7 +278,7 @@ async def test_form_bad_exchange_rate(hass: HomeAssistant) -> None: CONF_EXCHANGE_PRECISION: 5, }, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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"} diff --git a/tests/components/control4/test_config_flow.py b/tests/components/control4/test_config_flow.py index 8ec6df063e5..d1faf2da6c6 100644 --- a/tests/components/control4/test_config_flow.py +++ b/tests/components/control4/test_config_flow.py @@ -15,6 +15,7 @@ from homeassistant.const import ( CONF_USERNAME, ) from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from tests.common import MockConfigEntry @@ -48,7 +49,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} c4_account = _get_mock_c4_account() @@ -77,7 +78,7 @@ async def test_form(hass: HomeAssistant) -> None: ) 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["data"] == { 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"} @@ -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"} @@ -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"} @@ -170,14 +171,14 @@ async def test_option_flow(hass: HomeAssistant) -> None: 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" result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={CONF_SCAN_INTERVAL: 4}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["data"] == { 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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "init" result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={} ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["data"] == { CONF_SCAN_INTERVAL: DEFAULT_SCAN_INTERVAL, } diff --git a/tests/components/coolmaster/test_config_flow.py b/tests/components/coolmaster/test_config_flow.py index ef7828e126d..83a074815b5 100644 --- a/tests/components/coolmaster/test_config_flow.py +++ b/tests/components/coolmaster/test_config_flow.py @@ -6,6 +6,7 @@ from homeassistant import config_entries from homeassistant.components.coolmaster.config_flow import AVAILABLE_MODES from homeassistant.components.coolmaster.const import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType def _flow_data(): @@ -21,7 +22,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None with ( @@ -39,7 +40,7 @@ async def test_form(hass: HomeAssistant) -> None: ) 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["data"] == { "host": "1.1.1.1", @@ -64,7 +65,7 @@ async def test_form_timeout(hass: HomeAssistant) -> None: result["flow_id"], _flow_data() ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "cannot_connect"} @@ -82,7 +83,7 @@ async def test_form_connection_refused(hass: HomeAssistant) -> None: result["flow_id"], _flow_data() ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "cannot_connect"} @@ -100,5 +101,5 @@ async def test_form_no_units(hass: HomeAssistant) -> None: result["flow_id"], _flow_data() ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "no_units"} diff --git a/tests/components/denonavr/test_config_flow.py b/tests/components/denonavr/test_config_flow.py index f675b188fb9..324b795052c 100644 --- a/tests/components/denonavr/test_config_flow.py +++ b/tests/components/denonavr/test_config_flow.py @@ -92,7 +92,7 @@ async def test_config_flow_manual_host_success(hass: HomeAssistant) -> None: DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -101,7 +101,7 @@ async def test_config_flow_manual_host_success(hass: HomeAssistant) -> None: {CONF_HOST: TEST_HOST}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_NAME assert result["data"] == { 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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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["data"] == { 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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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["errors"] == {} @@ -178,7 +178,7 @@ async def test_config_flow_manual_discover_2_success(hass: HomeAssistant) -> Non {"select_host": TEST_HOST2}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_NAME assert result["data"] == { 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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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["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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -239,7 +239,7 @@ async def test_config_flow_manual_host_no_serial(hass: HomeAssistant) -> None: {CONF_HOST: TEST_HOST}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_NAME assert result["data"] == { 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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -278,7 +278,7 @@ async def test_config_flow_manual_host_connection_error(hass: HomeAssistant) -> {CONF_HOST: TEST_HOST}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -304,7 +304,7 @@ async def test_config_flow_manual_host_no_device_info(hass: HomeAssistant) -> No {CONF_HOST: TEST_HOST}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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" 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["data"] == { 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" @@ -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" @@ -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" @@ -471,7 +471,7 @@ async def test_config_flow_manual_host_no_serial_double_config( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -484,7 +484,7 @@ async def test_config_flow_manual_host_no_serial_double_config( {CONF_HOST: TEST_HOST}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_NAME assert result["data"] == { 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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -511,5 +511,5 @@ async def test_config_flow_manual_host_no_serial_double_config( {CONF_HOST: TEST_HOST}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/devialet/test_config_flow.py b/tests/components/devialet/test_config_flow.py index 200a2673913..6fec4e927dc 100644 --- a/tests/components/devialet/test_config_flow.py +++ b/tests/components/devialet/test_config_flow.py @@ -111,7 +111,7 @@ async def test_zeroconf_devialet( DOMAIN, context={"source": SOURCE_ZEROCONF}, data=MOCK_ZEROCONF_DATA ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM with patch( "homeassistant.components.devialet.async_setup_entry", @@ -123,7 +123,7 @@ async def test_zeroconf_devialet( ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "Livingroom" assert result2["data"] == { CONF_HOST: HOST, @@ -140,7 +140,7 @@ async def test_async_step_confirm( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_ZEROCONF}, data=MOCK_ZEROCONF_DATA ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "confirm" aioclient_mock.get( diff --git a/tests/components/devolo_home_control/test_config_flow.py b/tests/components/devolo_home_control/test_config_flow.py index d26da474e39..48f9bf31f4f 100644 --- a/tests/components/devolo_home_control/test_config_flow.py +++ b/tests/components/devolo_home_control/test_config_flow.py @@ -95,7 +95,7 @@ async def test_form_advanced_options(hass: HomeAssistant) -> None: ) 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["data"] == { "username": "test-username", @@ -286,7 +286,7 @@ async def _setup(hass: HomeAssistant, result: FlowResult) -> None: ) 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["data"] == { "username": "test-username", diff --git a/tests/components/dnsip/test_config_flow.py b/tests/components/dnsip/test_config_flow.py index 54ce26b15a8..29c8d81dd2d 100644 --- a/tests/components/dnsip/test_config_flow.py +++ b/tests/components/dnsip/test_config_flow.py @@ -32,7 +32,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( 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["errors"] == {} diff --git a/tests/components/doorbird/test_config_flow.py b/tests/components/doorbird/test_config_flow.py index 5d73c0785a4..cd4ddccda87 100644 --- a/tests/components/doorbird/test_config_flow.py +++ b/tests/components/doorbird/test_config_flow.py @@ -72,7 +72,7 @@ async def test_user_form(hass: HomeAssistant) -> None: ) 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["data"] == { "host": "1.2.3.4", @@ -100,7 +100,7 @@ async def test_form_zeroconf_wrong_oui(hass: HomeAssistant) -> None: type="mock_type", ), ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "not_doorbird_device" @@ -120,7 +120,7 @@ async def test_form_zeroconf_link_local_ignored(hass: HomeAssistant) -> None: type="mock_type", ), ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "link_local_address" @@ -147,7 +147,7 @@ async def test_form_zeroconf_ipv4_address(hass: HomeAssistant) -> None: type="mock_type", ), ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" 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", ), ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "1.2.3.4" assert result2["data"] == { "host": "1.2.3.4", @@ -307,7 +307,7 @@ async def test_form_user_invalid_auth(hass: HomeAssistant) -> None: VALID_CONFIG, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "invalid_auth"} diff --git a/tests/components/drop_connect/test_config_flow.py b/tests/components/drop_connect/test_config_flow.py index 4785ea9348f..8cd765b46b4 100644 --- a/tests/components/drop_connect/test_config_flow.py +++ b/tests/components/drop_connect/test_config_flow.py @@ -24,7 +24,7 @@ async def test_mqtt_setup(hass: HomeAssistant, mqtt_mock: MqttMockHAClient) -> N data=discovery_info, ) assert result is not None - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "confirm" 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, ) assert result is not None - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "confirm" 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, ) assert result is not None - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "invalid_discovery_info" @@ -100,7 +100,7 @@ async def test_mqtt_setup_incomplete_payload( data=discovery_info, ) assert result is not None - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "invalid_discovery_info" @@ -122,7 +122,7 @@ async def test_mqtt_setup_bad_json( data=discovery_info, ) assert result is not None - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "invalid_discovery_info" @@ -144,7 +144,7 @@ async def test_mqtt_setup_bad_topic( data=discovery_info, ) assert result is not None - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "invalid_discovery_info" @@ -166,7 +166,7 @@ async def test_mqtt_setup_no_payload( data=discovery_info, ) assert result is not None - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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( "drop_connect", context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "not_supported" diff --git a/tests/components/dsmr/test_config_flow.py b/tests/components/dsmr/test_config_flow.py index a8eea28d748..791797f7dcd 100644 --- a/tests/components/dsmr/test_config_flow.py +++ b/tests/components/dsmr/test_config_flow.py @@ -39,7 +39,7 @@ async def test_setup_network( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] is None @@ -48,7 +48,7 @@ async def test_setup_network( {"type": "Network"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "setup_network" assert result["errors"] == {} @@ -70,7 +70,7 @@ async def test_setup_network( "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["data"] == {**entry_data, **SERIAL_DATA} @@ -87,7 +87,7 @@ async def test_setup_network_rfxtrx( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] is None @@ -96,7 +96,7 @@ async def test_setup_network_rfxtrx( {"type": "Network"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "setup_network" assert result["errors"] == {} @@ -121,7 +121,7 @@ async def test_setup_network_rfxtrx( "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["data"] == {**entry_data, **SERIAL_DATA} @@ -237,7 +237,7 @@ async def test_setup_serial_rfxtrx( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] is None @@ -246,7 +246,7 @@ async def test_setup_serial_rfxtrx( {"type": "Serial"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "setup_serial" assert result["errors"] == {} @@ -266,7 +266,7 @@ async def test_setup_serial_rfxtrx( "protocol": "rfxtrx_dsmr_protocol", } - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == port.device assert result["data"] == {**entry_data, **SERIAL_DATA} @@ -280,7 +280,7 @@ async def test_setup_serial_manual( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] is None @@ -289,7 +289,7 @@ async def test_setup_serial_manual( {"type": "Serial"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "setup_serial" assert result["errors"] == {} @@ -298,7 +298,7 @@ async def test_setup_serial_manual( {"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["errors"] is None @@ -314,7 +314,7 @@ async def test_setup_serial_manual( "protocol": "dsmr_protocol", } - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "/dev/ttyUSB0" assert result["data"] == {**entry_data, **SERIAL_DATA} @@ -338,7 +338,7 @@ async def test_setup_serial_fail( side_effect=chain([serial.SerialException], repeat(DEFAULT)), ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] is None @@ -347,7 +347,7 @@ async def test_setup_serial_fail( {"type": "Serial"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "setup_serial" assert result["errors"] == {} @@ -360,7 +360,7 @@ async def test_setup_serial_fail( {"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["errors"] == {"base": "cannot_connect"} @@ -398,7 +398,7 @@ async def test_setup_serial_timeout( ) 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["errors"] is None @@ -407,7 +407,7 @@ async def test_setup_serial_timeout( {"type": "Serial"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "setup_serial" assert result["errors"] == {} @@ -416,7 +416,7 @@ async def test_setup_serial_timeout( 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["errors"] == {"base": "cannot_communicate"} @@ -442,7 +442,7 @@ async def test_setup_serial_wrong_telegram( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] is None @@ -451,7 +451,7 @@ async def test_setup_serial_wrong_telegram( {"type": "Serial"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "setup_serial" assert result["errors"] == {} @@ -463,7 +463,7 @@ async def test_setup_serial_wrong_telegram( {"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["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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "init" result = await hass.config_entries.options.async_configure( diff --git a/tests/components/dynalite/test_config_flow.py b/tests/components/dynalite/test_config_flow.py index 724cb616deb..bdbd03faa22 100644 --- a/tests/components/dynalite/test_config_flow.py +++ b/tests/components/dynalite/test_config_flow.py @@ -8,6 +8,7 @@ from homeassistant import config_entries from homeassistant.components import dynalite from homeassistant.const import CONF_PORT from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from homeassistant.helpers.issue_registry import ( IssueSeverity, async_get as async_get_issue_registry, @@ -86,7 +87,7 @@ async def test_existing(hass: HomeAssistant) -> None: context={"source": config_entries.SOURCE_IMPORT}, data={dynalite.CONF_HOST: host}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -116,7 +117,7 @@ async def test_existing_update(hass: HomeAssistant) -> None: await hass.async_block_till_done() assert mock_dyn_dev().configure.call_count == 2 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" @@ -136,7 +137,7 @@ async def test_two_entries(hass: HomeAssistant) -> None: context={"source": config_entries.SOURCE_IMPORT}, 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 @@ -148,7 +149,7 @@ async def test_setup_user(hass): 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["errors"] is None @@ -161,7 +162,7 @@ async def test_setup_user(hass): {"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["title"] == host assert result["data"] == { @@ -188,5 +189,5 @@ async def test_setup_user_existing_host(hass): {"host": host, "port": 1234}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/eafm/test_config_flow.py b/tests/components/eafm/test_config_flow.py index e8f86154e67..9773a8b619e 100644 --- a/tests/components/eafm/test_config_flow.py +++ b/tests/components/eafm/test_config_flow.py @@ -8,6 +8,7 @@ from voluptuous.error import Invalid from homeassistant import config_entries from homeassistant.components.eafm import const from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType 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( const.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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( const.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM with pytest.raises(Invalid): 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( 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): result = await hass.config_entries.flow.async_configure( 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["data"] == { "station": "L12345", diff --git a/tests/components/elkm1/test_config_flow.py b/tests/components/elkm1/test_config_flow.py index c361063d7ea..e56bb5f4699 100644 --- a/tests/components/elkm1/test_config_flow.py +++ b/tests/components/elkm1/test_config_flow.py @@ -66,7 +66,7 @@ async def test_form_user_with_secure_elk_no_discovery(hass: HomeAssistant) -> No ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "ElkM1" assert result2["data"] == { "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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "ElkM1" assert result2["data"] == { "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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "ElkM1" assert result2["data"] == { "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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None 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() - assert result3["type"] == "create_entry" + assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["title"] == "ElkM1 ddeeff" assert result3["data"] == { "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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None 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() - assert result3["type"] == "create_entry" + assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["title"] == "ElkM1" assert result3["data"] == { "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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None 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() - assert result3["type"] == "create_entry" + assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["title"] == "ElkM1 ddeeff" assert result3["data"] == { "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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "ElkM1" assert result2["data"] == { "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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "guest_house" assert result2["data"] == { "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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "ElkM1" assert result2["data"] == { "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"} @@ -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"} @@ -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"} @@ -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"} @@ -807,7 +807,7 @@ async def test_form_import(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "ohana" assert result["data"] == { @@ -877,7 +877,7 @@ async def test_form_import_device_discovered(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "ohana" assert result["result"].unique_id == MOCK_MAC assert result["data"] == { @@ -929,7 +929,7 @@ async def test_form_import_non_secure_device_discovered(hass: HomeAssistant) -> ) await hass.async_block_till_done() - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "ohana" assert result["result"].unique_id == MOCK_MAC 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() - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "ohana" assert result["result"].unique_id == MOCK_MAC assert result["data"] == { @@ -1007,7 +1007,7 @@ async def test_form_import_non_secure_device_discovered_invalid_auth( ) await hass.async_block_till_done() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "invalid_auth" @@ -1189,7 +1189,7 @@ async def test_discovered_by_discovery(hass: HomeAssistant) -> None: ) 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["data"] == { "auto_configure": True, @@ -1239,7 +1239,7 @@ async def test_discovered_by_discovery_non_standard_port(hass: HomeAssistant) -> ) 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["data"] == { "auto_configure": True, @@ -1310,7 +1310,7 @@ async def test_discovered_by_dhcp_udp_responds(hass: HomeAssistant) -> None: ) 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["data"] == { "auto_configure": True, @@ -1359,7 +1359,7 @@ async def test_discovered_by_dhcp_udp_responds_with_nonsecure_port( ) 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["data"] == { "auto_configure": True, @@ -1412,7 +1412,7 @@ async def test_discovered_by_dhcp_udp_responds_existing_config_entry( ) 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["data"] == { "auto_configure": True, @@ -1450,7 +1450,7 @@ async def test_multiple_instances_with_discovery(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert not result["errors"] 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() - assert result3["type"] == "create_entry" + assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["title"] == "ElkM1 ddeeff" assert result3["data"] == { "auto_configure": True, @@ -1502,7 +1502,7 @@ async def test_multiple_instances_with_discovery(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert not result["errors"] 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() - assert result3["type"] == "create_entry" + assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["title"] == "ElkM1 ddeefe" assert result3["data"] == { "auto_configure": True, @@ -1551,7 +1551,7 @@ async def test_multiple_instances_with_discovery(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "guest_house" assert result2["data"] == { "auto_configure": True, @@ -1599,7 +1599,7 @@ async def test_multiple_instances_with_tls_v12(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert not result["errors"] 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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert not result["errors"] assert result2["step_id"] == "discovered_connection" with ( @@ -1636,7 +1636,7 @@ async def test_multiple_instances_with_tls_v12(hass: HomeAssistant) -> None: ) 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["data"] == { "auto_configure": True, @@ -1655,7 +1655,7 @@ async def test_multiple_instances_with_tls_v12(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert not result["errors"] 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() - assert result3["type"] == "create_entry" + assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["title"] == "ElkM1 ddeefe" assert result3["data"] == { "auto_configure": True, @@ -1705,7 +1705,7 @@ async def test_multiple_instances_with_tls_v12(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "guest_house" assert result2["data"] == { "auto_configure": True, diff --git a/tests/components/emonitor/test_config_flow.py b/tests/components/emonitor/test_config_flow.py index 07809a83d89..e77ebcc08b0 100644 --- a/tests/components/emonitor/test_config_flow.py +++ b/tests/components/emonitor/test_config_flow.py @@ -10,6 +10,7 @@ from homeassistant.components import dhcp from homeassistant.components.emonitor.const import DOMAIN from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from tests.common import MockConfigEntry @@ -32,7 +33,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -53,7 +54,7 @@ async def test_form(hass: HomeAssistant) -> None: ) 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["data"] == { "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"} @@ -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"} @@ -117,7 +118,7 @@ async def test_dhcp_can_confirm(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "confirm" assert result["description_placeholders"] == { "host": "1.2.3.4", @@ -134,7 +135,7 @@ async def test_dhcp_can_confirm(hass: HomeAssistant) -> None: ) 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["data"] == { "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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" @@ -181,7 +182,7 @@ async def test_dhcp_already_exists(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -219,5 +220,5 @@ async def test_user_unique_id_already_exists(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT assert result2["reason"] == "already_configured" diff --git a/tests/components/emulated_roku/test_config_flow.py b/tests/components/emulated_roku/test_config_flow.py index 700adbf0039..45cb83b4fea 100644 --- a/tests/components/emulated_roku/test_config_flow.py +++ b/tests/components/emulated_roku/test_config_flow.py @@ -3,6 +3,7 @@ from homeassistant import config_entries from homeassistant.components.emulated_roku import config_flow from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType 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}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "Emulated Roku Test" 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}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/enphase_envoy/test_config_flow.py b/tests/components/enphase_envoy/test_config_flow.py index 9000cf92e0e..7af0cd584a4 100644 --- a/tests/components/enphase_envoy/test_config_flow.py +++ b/tests/components/enphase_envoy/test_config_flow.py @@ -11,6 +11,7 @@ from homeassistant import config_entries from homeassistant.components import zeroconf from homeassistant.components.enphase_envoy.const import DOMAIN, PLATFORMS from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "Envoy 1234" assert result2["data"] == { "host": "1.1.1.1", @@ -48,7 +49,7 @@ async def test_user_no_serial_number( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "Envoy" assert result2["data"] == { "host": "1.1.1.1", @@ -78,7 +79,7 @@ async def test_user_fetching_serial_fails( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "Envoy" assert result2["data"] == { "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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "unknown"} @@ -193,7 +194,7 @@ async def test_zeroconf_pre_token_firmware( type="mock_type", ), ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "Envoy 1234" assert result2["result"].unique_id == "1234" assert result2["data"] == { @@ -235,7 +236,7 @@ async def test_zeroconf_token_firmware( type="mock_type", ), ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "Envoy 1234" assert result2["result"].unique_id == "1234" assert result2["data"] == { @@ -278,7 +279,7 @@ async def test_form_host_already_exists( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} # existing config @@ -295,7 +296,7 @@ async def test_form_host_already_exists( "password": "wrong-password", }, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "invalid_auth"} # still original config after failure @@ -313,7 +314,7 @@ async def test_form_host_already_exists( }, ) await hass.async_block_till_done() - assert result3["type"] == "abort" + assert result3["type"] is FlowResultType.ABORT assert result3["reason"] == "reauth_successful" # 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() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" 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() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "not_ipv4_address" 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() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" 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() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT assert result2["reason"] == "reauth_successful" diff --git a/tests/components/environment_canada/test_config_flow.py b/tests/components/environment_canada/test_config_flow.py index aa1297571b5..3571c74cdcc 100644 --- a/tests/components/environment_canada/test_config_flow.py +++ b/tests/components/environment_canada/test_config_flow.py @@ -123,7 +123,7 @@ async def test_exception_handling(hass: HomeAssistant, error) -> None: {}, ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {"base": base_error} diff --git a/tests/components/epson/test_config_flow.py b/tests/components/epson/test_config_flow.py index c6ca921df0f..d485a4bfdef 100644 --- a/tests/components/epson/test_config_flow.py +++ b/tests/components/epson/test_config_flow.py @@ -8,6 +8,7 @@ from homeassistant import config_entries from homeassistant.components.epson.const import DOMAIN from homeassistant.const import CONF_HOST, CONF_NAME, STATE_UNAVAILABLE from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} assert result["step_id"] == config_entries.SOURCE_USER with ( @@ -40,7 +41,7 @@ async def test_form(hass: HomeAssistant) -> None: ) 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["data"] == {CONF_HOST: "1.1.1.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"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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"}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "powered_off"} diff --git a/tests/components/faa_delays/test_config_flow.py b/tests/components/faa_delays/test_config_flow.py index 61e5ffb8e6b..4420bc73632 100644 --- a/tests/components/faa_delays/test_config_flow.py +++ b/tests/components/faa_delays/test_config_flow.py @@ -26,7 +26,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -44,7 +44,7 @@ async def test_form(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "test" assert result2["data"] == { "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"} @@ -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"} diff --git a/tests/components/firmata/test_config_flow.py b/tests/components/firmata/test_config_flow.py index a3c8ca7e728..0ef98a27bb6 100644 --- a/tests/components/firmata/test_config_flow.py +++ b/tests/components/firmata/test_config_flow.py @@ -8,6 +8,7 @@ from homeassistant import config_entries from homeassistant.components.firmata.const import CONF_SERIAL_PORT, DOMAIN from homeassistant.const import CONF_NAME from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType 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"}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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"}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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"}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "cannot_connect" @@ -79,7 +80,7 @@ async def test_import(hass: HomeAssistant) -> None: 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["data"] == { CONF_NAME: "serial-/dev/nonExistent", diff --git a/tests/components/fitbit/test_config_flow.py b/tests/components/fitbit/test_config_flow.py index 2fd431176b9..843a85dec68 100644 --- a/tests/components/fitbit/test_config_flow.py +++ b/tests/components/fitbit/test_config_flow.py @@ -480,7 +480,7 @@ async def test_reauth_flow( "entry_id": config_entry.entry_id, }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" result = await hass.config_entries.flow.async_configure( diff --git a/tests/components/flick_electric/test_config_flow.py b/tests/components/flick_electric/test_config_flow.py index 1b56aaf6376..1b3ed1de34d 100644 --- a/tests/components/flick_electric/test_config_flow.py +++ b/tests/components/flick_electric/test_config_flow.py @@ -29,7 +29,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( diff --git a/tests/components/flipr/test_config_flow.py b/tests/components/flipr/test_config_flow.py index 60dcc15a701..b99e6af7383 100644 --- a/tests/components/flipr/test_config_flow.py +++ b/tests/components/flipr/test_config_flow.py @@ -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"} @@ -129,7 +129,7 @@ async def test_no_flip_id(hass: HomeAssistant, mock_setup) -> None: ) assert result["step_id"] == "user" - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {"base": "no_flipr_id_found"} 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"} 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"} diff --git a/tests/components/flo/test_config_flow.py b/tests/components/flo/test_config_flow.py index f5a730a2056..99f8f315fb2 100644 --- a/tests/components/flo/test_config_flow.py +++ b/tests/components/flo/test_config_flow.py @@ -9,6 +9,7 @@ from homeassistant import config_entries from homeassistant.components.flo.const import DOMAIN from homeassistant.const import CONTENT_TYPE_JSON 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 @@ -21,7 +22,7 @@ async def test_form(hass: HomeAssistant, aioclient_mock_fixture) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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} ) - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == TEST_USER_ID assert result2["data"] == {"username": TEST_USER_ID, "password": TEST_PASSWORD} 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"} ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "cannot_connect"} diff --git a/tests/components/flume/test_config_flow.py b/tests/components/flume/test_config_flow.py index 8fa66c03258..706cee44739 100644 --- a/tests/components/flume/test_config_flow.py +++ b/tests/components/flume/test_config_flow.py @@ -13,6 +13,7 @@ from homeassistant.const import ( CONF_USERNAME, ) from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from tests.common import MockConfigEntry @@ -29,7 +30,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "test-username" assert result2["data"] == { 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"} @@ -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"} @@ -147,7 +148,7 @@ async def test_reauth(hass: HomeAssistant) -> None: 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" 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"} 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"} 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 result4["type"] == "abort" + assert result4["type"] is FlowResultType.ABORT assert result4["reason"] == "reauth_successful" diff --git a/tests/components/flux_led/test_config_flow.py b/tests/components/flux_led/test_config_flow.py index a4ba42ed629..d95bc99f097 100644 --- a/tests/components/flux_led/test_config_flow.py +++ b/tests/components/flux_led/test_config_flow.py @@ -55,13 +55,13 @@ async def test_discovery(hass: HomeAssistant) -> None: DOMAIN, context={"source": config_entries.SOURCE_USER} ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "pick_device" assert not result2["errors"] @@ -69,13 +69,13 @@ async def test_discovery(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "pick_device" assert not result2["errors"] @@ -91,7 +91,7 @@ async def test_discovery(hass: HomeAssistant) -> None: ) 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["data"] == { CONF_MINOR_VERSION: 4, @@ -111,7 +111,7 @@ async def test_discovery(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT 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} ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "pick_device" assert not result2["errors"] @@ -144,13 +144,13 @@ async def test_discovery_legacy(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "pick_device" assert not result2["errors"] @@ -166,7 +166,7 @@ async def test_discovery_legacy(hass: HomeAssistant) -> None: ) 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["data"] == { CONF_MINOR_VERSION: 4, @@ -186,7 +186,7 @@ async def test_discovery_legacy(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "pick_device" 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "pick_device" 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( 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["data"] == { 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] @@ -312,7 +312,7 @@ async def test_manual_working_discovery(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "user" 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} ) 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["data"] == { CONF_MINOR_VERSION: 4, @@ -351,7 +351,7 @@ async def test_manual_working_discovery(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] @@ -375,7 +375,7 @@ async def test_manual_no_discovery_data(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["data"] == { CONF_HOST: IP_ADDRESS, 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["data"] == { CONF_MINOR_VERSION: 4, 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["data"] == { CONF_MINOR_VERSION: 4, 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["data"] == { CONF_HOST: IP_ADDRESS, 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["data"] == { CONF_HOST: IP_ADDRESS, CONF_MODEL_NUM: MODEL_NUM, @@ -703,7 +703,7 @@ async def test_options(hass: HomeAssistant) -> None: await hass.async_block_till_done() 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" user_input = { @@ -716,7 +716,7 @@ async def test_options(hass: HomeAssistant) -> None: result["flow_id"], user_input ) 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"] == config_entry.options assert hass.states.get("light.bulb_rgbcw_ddeeff") is not None diff --git a/tests/components/fyta/test_config_flow.py b/tests/components/fyta/test_config_flow.py index 93b83caa379..60e6fc76c5b 100644 --- a/tests/components/fyta/test_config_flow.py +++ b/tests/components/fyta/test_config_flow.py @@ -40,7 +40,7 @@ async def test_user_flow( ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == USERNAME assert result2["data"] == {CONF_USERNAME: USERNAME, CONF_PASSWORD: PASSWORD} assert len(mock_setup_entry.mock_calls) == 1 diff --git a/tests/components/generic/test_config_flow.py b/tests/components/generic/test_config_flow.py index 751361d47dd..f22bb4d93da 100644 --- a/tests/components/generic/test_config_flow.py +++ b/tests/components/generic/test_config_flow.py @@ -127,7 +127,7 @@ async def test_form_only_stillimage( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} data = TESTDATA.copy() @@ -501,7 +501,7 @@ async def test_form_image_http_exceptions( ) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == expected_message @@ -518,7 +518,7 @@ async def test_form_stream_invalidimage( ) 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"} @@ -535,7 +535,7 @@ async def test_form_stream_invalidimage2( ) 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"} @@ -552,7 +552,7 @@ async def test_form_stream_invalidimage3( ) 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"} @@ -571,7 +571,7 @@ async def test_form_stream_timeout(hass: HomeAssistant, fakeimg_png, user_flow) user_flow["flow_id"], TESTDATA, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"stream_source": "timeout"} @@ -588,7 +588,7 @@ async def test_form_stream_worker_error( user_flow["flow_id"], TESTDATA, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"stream_source": "Some message"} @@ -606,7 +606,7 @@ async def test_form_stream_permission_error( user_flow["flow_id"], TESTDATA, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"stream_source": "stream_not_permitted"} @@ -623,7 +623,7 @@ async def test_form_no_route_to_host( user_flow["flow_id"], TESTDATA, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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"], TESTDATA, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"stream_source": "stream_io_error"} diff --git a/tests/components/github/test_config_flow.py b/tests/components/github/test_config_flow.py index 882ed88edb2..a721298c129 100644 --- a/tests/components/github/test_config_flow.py +++ b/tests/components/github/test_config_flow.py @@ -276,7 +276,7 @@ async def test_options_flow( 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" result = await hass.config_entries.options.async_configure( diff --git a/tests/components/google/test_config_flow.py b/tests/components/google/test_config_flow.py index c27808c24aa..12af97c8604 100644 --- a/tests/components/google/test_config_flow.py +++ b/tests/components/google/test_config_flow.py @@ -151,7 +151,7 @@ async def test_full_flow_application_creds( result = await hass.config_entries.flow.async_init( 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 "description_placeholders" in result assert "url" in result["description_placeholders"] @@ -167,7 +167,7 @@ async def test_full_flow_application_creds( 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 "data" in result data = result["data"] @@ -213,7 +213,7 @@ async def test_code_error( result = await hass.config_entries.flow.async_init( 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" @@ -233,7 +233,7 @@ async def test_timeout_error( result = await hass.config_entries.flow.async_init( 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" @@ -252,7 +252,7 @@ async def test_expired_after_exchange( result = await hass.config_entries.flow.async_init( 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 "description_placeholders" in result assert "url" in result["description_placeholders"] @@ -267,7 +267,7 @@ async def test_expired_after_exchange( await hass.async_block_till_done() 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" @@ -287,7 +287,7 @@ async def test_exchange_error( result = await hass.config_entries.flow.async_init( 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 "description_placeholders" in result assert "url" in result["description_placeholders"] @@ -309,7 +309,7 @@ async def test_exchange_error( # Status has not updated, will retry 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" # Run another tick, which attempts credential exchange again @@ -323,7 +323,7 @@ async def test_exchange_error( 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 "data" in result data = result["data"] @@ -373,7 +373,7 @@ async def test_duplicate_config_entries( result = await hass.config_entries.flow.async_init( 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 "description_placeholders" in result 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 hass.async_block_till_done() 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" @@ -415,7 +415,7 @@ async def test_multiple_config_entries( result = await hass.config_entries.flow.async_init( 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 "description_placeholders" in result assert "url" in result["description_placeholders"] @@ -430,7 +430,7 @@ async def test_multiple_config_entries( result = await hass.config_entries.flow.async_configure( 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 len(mock_setup.mock_calls) == 1 @@ -445,7 +445,7 @@ async def test_missing_configuration( result = await hass.config_entries.flow.async_init( 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" @@ -471,7 +471,7 @@ async def test_wrong_configuration( result = await hass.config_entries.flow.async_init( 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" @@ -506,14 +506,14 @@ async def test_reauth_flow( }, data=config_entry.data, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" result = await hass.config_entries.flow.async_configure( flow_id=result["flow_id"], user_input={}, ) - assert result.get("type") == "progress" + assert result.get("type") is FlowResultType.SHOW_PROGRESS assert result.get("step_id") == "auth" assert "description_placeholders" in result assert "url" in result["description_placeholders"] @@ -529,7 +529,7 @@ async def test_reauth_flow( flow_id=result["flow_id"] ) - assert result.get("type") == "abort" + assert result.get("type") is FlowResultType.ABORT assert result.get("reason") == "reauth_successful" 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( 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 "description_placeholders" in result assert "url" in result["description_placeholders"] @@ -590,7 +590,7 @@ async def test_calendar_lookup_failure( flow_id=result["flow_id"] ) - assert result.get("type") == "abort" + assert result.get("type") is FlowResultType.ABORT assert result.get("reason") == reason @@ -611,7 +611,7 @@ async def test_options_flow_triggers_reauth( assert config_entry.options == {} # Default is read_write 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" data_schema = result["data_schema"].schema assert set(data_schema) == {"calendar_access"} @@ -622,7 +622,7 @@ async def test_options_flow_triggers_reauth( "calendar_access": "read_only", }, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY 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 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" result = await hass.config_entries.options.async_configure( @@ -652,7 +652,7 @@ async def test_options_flow_no_changes( "calendar_access": "read_write", }, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY 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", }, ) - assert result["type"] == "external" + assert result["type"] is FlowResultType.EXTERNAL_STEP assert result["url"] == ( f"{OAUTH2_AUTHORIZE}?response_type=code&client_id={CLIENT_ID}" "&redirect_uri=https://example.com/auth/external/callback" @@ -770,7 +770,7 @@ async def test_web_reauth_flow( }, data=config_entry.data, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" with patch( @@ -791,7 +791,7 @@ async def test_web_reauth_flow( "redirect_uri": "https://example.com/auth/external/callback", }, ) - assert result.get("type") == "external" + assert result.get("type") is FlowResultType.EXTERNAL_STEP assert result["url"] == ( f"{OAUTH2_AUTHORIZE}?response_type=code&client_id={CLIENT_ID}" "&redirect_uri=https://example.com/auth/external/callback" diff --git a/tests/components/google_assistant_sdk/test_config_flow.py b/tests/components/google_assistant_sdk/test_config_flow.py index 49e849398af..4a4931d7bae 100644 --- a/tests/components/google_assistant_sdk/test_config_flow.py +++ b/tests/components/google_assistant_sdk/test_config_flow.py @@ -5,6 +5,7 @@ from unittest.mock import patch from homeassistant import config_entries from homeassistant.components.google_assistant_sdk.const import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from homeassistant.helpers import config_entry_oauth2_flow 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(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" in result 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(mock_setup.mock_calls) == 1 - assert result.get("type") == "abort" + assert result.get("type") is FlowResultType.ABORT assert result.get("reason") == "reauth_successful" 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"]) - assert result.get("type") == "abort" + assert result.get("type") is FlowResultType.ABORT assert result.get("reason") == "single_instance_allowed" @@ -221,7 +222,7 @@ async def test_options_flow( # Trigger options flow, first time 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" data_schema = result["data_schema"].schema assert set(data_schema) == {"language_code"} @@ -230,12 +231,12 @@ async def test_options_flow( result["flow_id"], 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"} # Retrigger options flow, not change language 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" data_schema = result["data_schema"].schema assert set(data_schema) == {"language_code"} @@ -244,12 +245,12 @@ async def test_options_flow( result["flow_id"], 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"} # Retrigger options flow, change language 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" data_schema = result["data_schema"].schema assert set(data_schema) == {"language_code"} @@ -258,5 +259,5 @@ async def test_options_flow( result["flow_id"], 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"} diff --git a/tests/components/google_mail/test_config_flow.py b/tests/components/google_mail/test_config_flow.py index 62db6603988..06479504f9d 100644 --- a/tests/components/google_mail/test_config_flow.py +++ b/tests/components/google_mail/test_config_flow.py @@ -8,6 +8,7 @@ import pytest from homeassistant import config_entries from homeassistant.components.google_mail.const import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from homeassistant.helpers import config_entry_oauth2_flow 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(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" in result 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 result.get("type") == "abort" + assert result.get("type") is FlowResultType.ABORT assert result["reason"] == abort_reason assert result["description_placeholders"] == placeholders 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"]) - assert result.get("type") == "abort" + assert result.get("type") is FlowResultType.ABORT assert result.get("reason") == "already_configured" diff --git a/tests/components/google_sheets/test_config_flow.py b/tests/components/google_sheets/test_config_flow.py index edf4580485f..5d8a19d1b61 100644 --- a/tests/components/google_sheets/test_config_flow.py +++ b/tests/components/google_sheets/test_config_flow.py @@ -13,6 +13,7 @@ from homeassistant.components.application_credentials import ( ) from homeassistant.components.google_sheets.const import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from homeassistant.helpers import config_entry_oauth2_flow 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_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" in result 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"]) - assert result.get("type") == "abort" + assert result.get("type") is FlowResultType.ABORT 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(mock_setup.mock_calls) == 1 - assert result.get("type") == "abort" + assert result.get("type") is FlowResultType.ABORT assert result.get("reason") == "reauth_successful" 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"]) - assert result.get("type") == "abort" + assert result.get("type") is FlowResultType.ABORT 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"]) - assert result.get("type") == "abort" + assert result.get("type") is FlowResultType.ABORT assert result.get("reason") == "already_configured" diff --git a/tests/components/growatt_server/test_config_flow.py b/tests/components/growatt_server/test_config_flow.py index 81ca870a22e..e17ea90047b 100644 --- a/tests/components/growatt_server/test_config_flow.py +++ b/tests/components/growatt_server/test_config_flow.py @@ -93,7 +93,7 @@ async def test_no_plants_on_account(hass: HomeAssistant) -> None: result["flow_id"], user_input ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "no_plants" @@ -180,5 +180,5 @@ async def test_existing_plant_configured(hass: HomeAssistant) -> None: result["flow_id"], user_input ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/guardian/test_config_flow.py b/tests/components/guardian/test_config_flow.py index 06ce37a32af..0f99578768a 100644 --- a/tests/components/guardian/test_config_flow.py +++ b/tests/components/guardian/test_config_flow.py @@ -129,7 +129,7 @@ async def test_step_zeroconf_already_in_progress(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_ZEROCONF}, data=zeroconf_data ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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( DOMAIN, context={"source": SOURCE_DHCP}, data=dhcp_data ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_in_progress" diff --git a/tests/components/habitica/test_config_flow.py b/tests/components/habitica/test_config_flow.py index fe5ddcacdea..4dfc696daf2 100644 --- a/tests/components/habitica/test_config_flow.py +++ b/tests/components/habitica/test_config_flow.py @@ -7,6 +7,7 @@ from aiohttp import ClientResponseError from homeassistant import config_entries from homeassistant.components.habitica.const import DEFAULT_URL, DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from tests.common import MockConfigEntry @@ -17,7 +18,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} mock_obj = MagicMock() @@ -42,7 +43,7 @@ async def test_form(hass: HomeAssistant) -> None: ) 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["data"] == { "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"} @@ -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"} @@ -117,7 +118,7 @@ async def test_manual_flow_config_exist(hass: HomeAssistant) -> None: DOMAIN, context={"source": config_entries.SOURCE_IMPORT} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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" diff --git a/tests/components/harmony/test_config_flow.py b/tests/components/harmony/test_config_flow.py index 3dc5a612452..d87bfd32326 100644 --- a/tests/components/harmony/test_config_flow.py +++ b/tests/components/harmony/test_config_flow.py @@ -29,7 +29,7 @@ async def test_user_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} harmonyapi = _get_mock_harmonyapi(connect=True) @@ -49,7 +49,7 @@ async def test_user_form(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "friend" assert result2["data"] == {"host": "1.2.3.4", "name": "friend"} 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["errors"] == {} assert result["description_placeholders"] == { @@ -104,7 +104,7 @@ async def test_form_ssdp(hass: HomeAssistant) -> None: ) 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["data"] == {"host": "192.168.1.12", "name": "Harmony Hub"} 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" @@ -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: @@ -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"} diff --git a/tests/components/hassio/test_config_flow.py b/tests/components/hassio/test_config_flow.py index 1c56f4e25f5..1153203817d 100644 --- a/tests/components/hassio/test_config_flow.py +++ b/tests/components/hassio/test_config_flow.py @@ -4,6 +4,7 @@ from unittest.mock import patch from homeassistant.components.hassio import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType 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( DOMAIN, context={"source": "system"} ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "Supervisor" assert result["data"] == {} 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( DOMAIN, context={"source": "system"} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/here_travel_time/test_config_flow.py b/tests/components/here_travel_time/test_config_flow.py index 1309878a2f3..002e2ed8fdb 100644 --- a/tests/components/here_travel_time/test_config_flow.py +++ b/tests/components/here_travel_time/test_config_flow.py @@ -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"} @@ -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"} diff --git a/tests/components/hlk_sw16/test_config_flow.py b/tests/components/hlk_sw16/test_config_flow.py index e8c0d36c81c..6a758ec5066 100644 --- a/tests/components/hlk_sw16/test_config_flow.py +++ b/tests/components/hlk_sw16/test_config_flow.py @@ -6,6 +6,7 @@ from unittest.mock import patch from homeassistant import config_entries from homeassistant.components.hlk_sw16.const import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType class MockSW16Client: @@ -54,7 +55,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} conf = { @@ -83,7 +84,7 @@ async def test_form(hass: HomeAssistant) -> None: ) 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["data"] == { "host": "127.0.0.1", @@ -101,7 +102,7 @@ async def test_form(hass: HomeAssistant) -> None: result3 = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result3["type"] == "form" + assert result3["type"] is FlowResultType.FORM assert result3["errors"] == {} result4 = await hass.config_entries.flow.async_configure( @@ -109,7 +110,7 @@ async def test_form(hass: HomeAssistant) -> None: conf, ) - assert result4["type"] == "abort" + assert result4["type"] is FlowResultType.ABORT assert result4["reason"] == "already_configured" @@ -119,7 +120,7 @@ async def test_import(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_IMPORT} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} conf = { @@ -148,7 +149,7 @@ async def test_import(hass: HomeAssistant) -> None: ) 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["data"] == { "host": "127.0.0.1", @@ -180,7 +181,7 @@ async def test_form_invalid_data(hass: HomeAssistant) -> None: conf, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "cannot_connect"} @@ -205,5 +206,5 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None: conf, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "cannot_connect"} diff --git a/tests/components/homekit/test_config_flow.py b/tests/components/homekit/test_config_flow.py index 0cd8e3284db..ff47abab833 100644 --- a/tests/components/homekit/test_config_flow.py +++ b/tests/components/homekit/test_config_flow.py @@ -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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None result2 = await hass.config_entries.flow.async_configure( diff --git a/tests/components/homekit_controller/test_config_flow.py b/tests/components/homekit_controller/test_config_flow.py index fbbd945b987..a336758f4ac 100644 --- a/tests/components/homekit_controller/test_config_flow.py +++ b/tests/components/homekit_controller/test_config_flow.py @@ -243,7 +243,7 @@ async def test_discovery_works( context={"source": config_entries.SOURCE_ZEROCONF}, data=discovery_info, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "pair" assert get_flow_context(hass, result) == { "source": config_entries.SOURCE_ZEROCONF, @@ -253,14 +253,14 @@ async def test_discovery_works( # User initiates pairing - device enters pairing mode and displays code 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" # Pairing doesn't error error and pairing results result = await hass.config_entries.flow.async_configure( 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["data"] == {} @@ -276,7 +276,7 @@ async def test_abort_duplicate_flow(hass: HomeAssistant, controller) -> None: context={"source": config_entries.SOURCE_ZEROCONF}, data=discovery_info, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "pair" 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}, data=discovery_info, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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}, data=discovery_info, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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}, data=discovery_info, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "ignored_model" @@ -335,7 +335,7 @@ async def test_id_missing(hass: HomeAssistant, controller) -> None: context={"source": config_entries.SOURCE_ZEROCONF}, data=discovery_info, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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}, data=discovery_info, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "ignored_model" @@ -380,7 +380,7 @@ async def test_discovery_ignored_hk_bridge( context={"source": config_entries.SOURCE_ZEROCONF}, data=discovery_info, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "ignored_model" @@ -408,7 +408,7 @@ async def test_discovery_does_not_ignore_non_homekit( context={"source": config_entries.SOURCE_ZEROCONF}, data=discovery_info, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM 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 # 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: @@ -549,7 +549,7 @@ async def test_discovery_already_configured(hass: HomeAssistant, controller) -> context={"source": config_entries.SOURCE_ZEROCONF}, data=discovery_info, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" assert entry.data["AccessoryIP"] == discovery_info.host 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}, data=discovery_info, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" await hass.async_block_till_done() @@ -615,7 +615,7 @@ async def test_pair_abort_errors_on_start( test_exc = exception("error") with patch.object(device, "async_start_pairing", side_effect=test_exc): 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 @@ -640,7 +640,7 @@ async def test_pair_try_later_errors_on_start( with patch.object(device, "async_start_pairing", side_effect=test_exc): result2 = await hass.config_entries.flow.async_configure(result["flow_id"]) 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 @@ -654,7 +654,7 @@ async def test_pair_try_later_errors_on_start( 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" @@ -686,7 +686,7 @@ async def test_pair_form_errors_on_start( result = await hass.config_entries.flow.async_configure( 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 get_flow_context(hass, result) == { @@ -697,7 +697,7 @@ async def test_pair_form_errors_on_start( # User gets back the form result = await hass.config_entries.flow.async_configure(result["flow_id"]) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} # 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"} ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY 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): 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) == { "title_placeholders": {"name": "TestDevice", "category": "Outlet"}, "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["flow_id"], user_input={"pairing_code": "111-22-333"} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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): 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) == { "title_placeholders": {"name": "TestDevice", "category": "Outlet"}, "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["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 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): 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) == { "title_placeholders": {"name": "TestDevice", "category": "Outlet"}, "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["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["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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert get_flow_context(hass, result) == { "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["flow_id"], user_input={"device": "TestDevice"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "pair" 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["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" @@ -897,7 +897,7 @@ async def test_user_pairing_with_insecure_setup_code( "homekit_controller", context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert get_flow_context(hass, result) == { "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["flow_id"], user_input={"device": "TestDevice"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "pair" 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["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["errors"] == {"pairing_code": "insecure_setup_code"} @@ -926,7 +926,7 @@ async def test_user_pairing_with_insecure_setup_code( result["flow_id"], 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" @@ -935,7 +935,7 @@ async def test_user_no_devices(hass: HomeAssistant, controller) -> None: result = await hass.config_entries.flow.async_init( "homekit_controller", context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "no_devices" @@ -966,7 +966,7 @@ async def test_unignore_works(hass: HomeAssistant, controller) -> None: context={"source": config_entries.SOURCE_UNIGNORE}, data={"unique_id": device.description.id}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "pair" assert get_flow_context(hass, result) == { "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 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" # Pairing finalized result = await hass.config_entries.flow.async_configure( 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" @@ -1000,7 +1000,7 @@ async def test_unignore_ignores_missing_devices( 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" @@ -1022,7 +1022,7 @@ async def test_discovery_dismiss_existing_flow_on_paired( context={"source": config_entries.SOURCE_ZEROCONF}, data=discovery_info, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "pair" await hass.async_block_till_done() assert ( @@ -1038,7 +1038,7 @@ async def test_discovery_dismiss_existing_flow_on_paired( context={"source": config_entries.SOURCE_ZEROCONF}, data=discovery_info, ) - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT assert result2["reason"] == "already_paired" await hass.async_block_till_done() assert ( @@ -1088,7 +1088,7 @@ async def test_mdns_update_to_paired_during_pairing( with patch.object(device, "async_start_pairing", _async_start_pairing): 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) == { "title_placeholders": {"name": "TestDevice", "category": "Outlet"}, "unique_id": "00:00:00:00:00:00", diff --git a/tests/components/homematicip_cloud/test_config_flow.py b/tests/components/homematicip_cloud/test_config_flow.py index 4b0d1c26b8f..d541bce4648 100644 --- a/tests/components/homematicip_cloud/test_config_flow.py +++ b/tests/components/homematicip_cloud/test_config_flow.py @@ -11,6 +11,7 @@ from homeassistant.components.homematicip_cloud.const import ( HMIPC_PIN, ) from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from tests.common import MockConfigEntry @@ -38,7 +39,7 @@ async def test_flow_works(hass: HomeAssistant, simple_mock_home) -> None: data=DEFAULT_CONFIG, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "link" 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={} ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "ABC123" assert result["data"] == {"hapid": "ABC123", "authtoken": True, "name": "hmip"} assert result["result"].unique_id == "ABC123" @@ -88,7 +89,7 @@ async def test_flow_init_connection_error(hass: HomeAssistant) -> None: data=DEFAULT_CONFIG, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "init" @@ -114,7 +115,7 @@ async def test_flow_link_connection_error(hass: HomeAssistant) -> None: data=DEFAULT_CONFIG, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "connection_aborted" @@ -136,7 +137,7 @@ async def test_flow_link_press_button(hass: HomeAssistant) -> None: data=DEFAULT_CONFIG, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "link" 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( HMIPC_DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "init" @@ -164,7 +165,7 @@ async def test_init_already_configured(hass: HomeAssistant) -> None: data=DEFAULT_CONFIG, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -193,7 +194,7 @@ async def test_import_config(hass: HomeAssistant, simple_mock_home) -> None: data=IMPORT_CONFIG, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "ABC123" assert result["data"] == {"authtoken": "123", "hapid": "ABC123", "name": "hmip"} assert result["result"].unique_id == "ABC123" @@ -222,5 +223,5 @@ async def test_import_existing_config(hass: HomeAssistant) -> None: data=IMPORT_CONFIG, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/homewizard/test_config_flow.py b/tests/components/homewizard/test_config_flow.py index 08f1436c03a..8d12a8a1787 100644 --- a/tests/components/homewizard/test_config_flow.py +++ b/tests/components/homewizard/test_config_flow.py @@ -322,7 +322,7 @@ async def test_abort_flow( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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" result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) diff --git a/tests/components/hue/test_config_flow.py b/tests/components/hue/test_config_flow.py index 74cceb03aba..325c32227e3 100644 --- a/tests/components/hue/test_config_flow.py +++ b/tests/components/hue/test_config_flow.py @@ -13,6 +13,7 @@ from homeassistant.components import zeroconf from homeassistant.components.hue import config_flow, const from homeassistant.components.hue.errors import CannotConnect from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from homeassistant.helpers import device_registry as dr 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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "init" result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={"id": disc_bridge.id} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "link" flow = next( @@ -83,7 +84,7 @@ async def test_flow_works(hass: HomeAssistant) -> None: 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["data"] == { "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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "init" result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={"id": "manual"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "manual" 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"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "link" 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"], {}) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == f"Hue Bridge {disc_bridge.id}" assert result["data"] == { "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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "manual" result = await hass.config_entries.flow.async_configure( result["flow_id"], {"host": "2.2.2.2"} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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( const.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM 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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "manual" @@ -219,7 +220,7 @@ async def test_flow_bridges_discovered( result = await hass.config_entries.flow.async_init( const.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "init" 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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "init" assert result["data_schema"]({"id": "beer"}) 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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "manual" @@ -285,7 +286,7 @@ async def test_flow_link_unknown_error(hass: HomeAssistant) -> None: result["flow_id"], user_input={} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "link" 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={} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "link" 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={} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "cannot_connect" @@ -350,7 +351,7 @@ async def test_import_with_no_config( data={"host": "0.0.0.0"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM 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}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "link" 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"], {}) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "Hue Bridge id-1234" assert result["data"] == { "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" 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"}}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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" @@ -496,7 +497,7 @@ async def test_options_flow_v1(hass: HomeAssistant) -> None: 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" schema = result["data_schema"].schema 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"] == { const.CONF_ALLOW_HUE_GROUPS: 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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "init" schema = result["data_schema"].schema 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]}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["data"] == { 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" @@ -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 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" @@ -676,7 +677,7 @@ async def test_bridge_connection_failed( # 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 result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "cannot_connect" # 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" # test again with homekit discovered wrong bridge IP @@ -714,7 +715,7 @@ async def test_bridge_connection_failed( type="mock_type", ), ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "cannot_connect" # repeat test with import flow @@ -723,5 +724,5 @@ async def test_bridge_connection_failed( context={"source": config_entries.SOURCE_IMPORT}, data={"host": "blah"}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "cannot_connect" diff --git a/tests/components/huisbaasje/test_config_flow.py b/tests/components/huisbaasje/test_config_flow.py index cca5c572712..bf595737f29 100644 --- a/tests/components/huisbaasje/test_config_flow.py +++ b/tests/components/huisbaasje/test_config_flow.py @@ -50,7 +50,7 @@ async def test_form(hass: HomeAssistant) -> None: ) 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["data"] == { "id": "test-id", diff --git a/tests/components/husqvarna_automower/test_config_flow.py b/tests/components/husqvarna_automower/test_config_flow.py index ce986c4c724..0a345eed627 100644 --- a/tests/components/husqvarna_automower/test_config_flow.py +++ b/tests/components/husqvarna_automower/test_config_flow.py @@ -190,7 +190,7 @@ async def test_reauth( 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 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 result.get("type") == "abort" + assert result.get("type") is FlowResultType.ABORT assert result.get("reason") == "wrong_account" assert mock_config_entry.unique_id == USER_ID diff --git a/tests/components/hvv_departures/test_config_flow.py b/tests/components/hvv_departures/test_config_flow.py index 5a7aa8f8dde..d9545b903c1 100644 --- a/tests/components/hvv_departures/test_config_flow.py +++ b/tests/components/hvv_departures/test_config_flow.py @@ -77,7 +77,7 @@ async def test_user_flow(hass: HomeAssistant) -> None: {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["data"] == { 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"} @@ -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"} @@ -217,7 +217,7 @@ async def test_user_flow_station(hass: HomeAssistant) -> None: result_user["flow_id"], None, ) - assert result_station["type"] == "form" + assert result_station["type"] is FlowResultType.FORM assert result_station["step_id"] == "station" @@ -255,7 +255,7 @@ async def test_user_flow_station_select(hass: HomeAssistant) -> None: None, ) - assert result_station_select["type"] == "form" + assert result_station_select["type"] is FlowResultType.FORM assert result_station_select["step_id"] == "station_select" diff --git a/tests/components/iaqualink/test_config_flow.py b/tests/components/iaqualink/test_config_flow.py index 64a09e218c3..4aaa66416f6 100644 --- a/tests/components/iaqualink/test_config_flow.py +++ b/tests/components/iaqualink/test_config_flow.py @@ -9,6 +9,7 @@ from iaqualink.exception import ( from homeassistant.components.iaqualink import config_flow from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType async def test_already_configured( @@ -23,7 +24,7 @@ async def test_already_configured( 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: @@ -34,7 +35,7 @@ async def test_without_config(hass: HomeAssistant) -> None: result = await flow.async_step_user() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == config_data["username"] assert result["data"] == config_data diff --git a/tests/components/insteon/test_config_flow.py b/tests/components/insteon/test_config_flow.py index 35ebfb62b77..711290ef3b1 100644 --- a/tests/components/insteon/test_config_flow.py +++ b/tests/components/insteon/test_config_flow.py @@ -124,7 +124,7 @@ async def test_form_select_modem(hass: HomeAssistant) -> None: result = await _init_form(hass, 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: @@ -155,7 +155,7 @@ async def test_form_select_plm(hass: HomeAssistant) -> None: result2, mock_setup, mock_setup_entry = await _device_form( 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 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 ) USB_PORTS.update(temp_usb_list) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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( hass, result2["flow_id"], mock_successful_connection, MOCK_USER_INPUT_PLM ) - assert result2["type"] == "form" - assert result3["type"] == "create_entry" + assert result2["type"] is FlowResultType.FORM + assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["data"] == MOCK_USER_INPUT_PLM 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( 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"] == { **MOCK_USER_INPUT_HUB_V1, 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( 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"] == { **MOCK_USER_INPUT_HUB_V2, CONF_HUB_VERSION: 2, @@ -263,7 +263,7 @@ async def test_failed_connection_plm(hass: HomeAssistant) -> None: result2, _, _ = await _device_form( 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"} @@ -278,7 +278,7 @@ async def test_failed_connection_plm_manually(hass: HomeAssistant) -> None: result3, _, _ = await _device_form( 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"} @@ -290,7 +290,7 @@ async def test_failed_connection_hub(hass: HomeAssistant) -> None: result2, _, _ = await _device_form( 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"} diff --git a/tests/components/intellifire/test_config_flow.py b/tests/components/intellifire/test_config_flow.py index 6c5e082ba13..ba4e2f039a3 100644 --- a/tests/components/intellifire/test_config_flow.py +++ b/tests/components/intellifire/test_config_flow.py @@ -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" diff --git a/tests/components/ipma/test_config_flow.py b/tests/components/ipma/test_config_flow.py index e17c8d011a9..ef9b667f03d 100644 --- a/tests/components/ipma/test_config_flow.py +++ b/tests/components/ipma/test_config_flow.py @@ -27,7 +27,7 @@ async def test_config_flow(hass: HomeAssistant) -> None: DOMAIN, context={"source": SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" test_data = { @@ -57,7 +57,7 @@ async def test_config_flow_failures(hass: HomeAssistant) -> None: DOMAIN, context={"source": SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" test_data = { @@ -109,5 +109,5 @@ async def test_flow_entry_already_exists(hass: HomeAssistant, init_integration) ) await hass.async_block_till_done() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/iss/test_config_flow.py b/tests/components/iss/test_config_flow.py index 73261fbc2e7..2fa7b63e937 100644 --- a/tests/components/iss/test_config_flow.py +++ b/tests/components/iss/test_config_flow.py @@ -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} diff --git a/tests/components/isy994/test_config_flow.py b/tests/components/isy994/test_config_flow.py index dc9c19e9e75..411439e2e70 100644 --- a/tests/components/isy994/test_config_flow.py +++ b/tests/components/isy994/test_config_flow.py @@ -649,7 +649,7 @@ async def test_reauth(hass: HomeAssistant) -> None: 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" 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"} 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"} with ( @@ -699,5 +699,5 @@ async def test_reauth(hass: HomeAssistant) -> None: await hass.async_block_till_done() assert mock_setup_entry.called - assert result4["type"] == "abort" + assert result4["type"] is FlowResultType.ABORT assert result4["reason"] == "reauth_successful" diff --git a/tests/components/jellyfin/test_config_flow.py b/tests/components/jellyfin/test_config_flow.py index 2256a3d5d89..b55766c2c68 100644 --- a/tests/components/jellyfin/test_config_flow.py +++ b/tests/components/jellyfin/test_config_flow.py @@ -41,7 +41,7 @@ async def test_form( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} result2 = await hass.config_entries.flow.async_configure( @@ -50,7 +50,7 @@ async def test_form( ) 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["data"] == { CONF_CLIENT_DEVICE_ID: "TEST-UUID", @@ -75,7 +75,7 @@ async def test_form_cannot_connect( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "cannot_connect"} 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "invalid_auth"} 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "unknown"} 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "invalid_auth"} 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() assert result3 - assert result3["type"] == "create_entry" + assert result3["type"] is FlowResultType.CREATE_ENTRY assert result3["data"] == { CONF_CLIENT_DEVICE_ID: "TEST-UUID-1", CONF_URL: TEST_URL, @@ -291,7 +291,7 @@ async def test_reauth_cannot_connect( ) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "cannot_connect"} 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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "invalid_auth"} 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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "unknown"} assert len(mock_client.auth.connect_to_address.mock_calls) == 1 diff --git a/tests/components/juicenet/test_config_flow.py b/tests/components/juicenet/test_config_flow.py index 2a4be10b49b..48d63cd8cd0 100644 --- a/tests/components/juicenet/test_config_flow.py +++ b/tests/components/juicenet/test_config_flow.py @@ -9,6 +9,7 @@ from homeassistant import config_entries from homeassistant.components.juicenet.const import DOMAIN from homeassistant.const import CONF_ACCESS_TOKEN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -43,7 +44,7 @@ async def test_form(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "JuiceNet" assert result2["data"] == {CONF_ACCESS_TOKEN: "access_token"} 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"} ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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"} ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM 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"} ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "unknown"} @@ -126,7 +127,7 @@ async def test_import(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "JuiceNet" assert result["data"] == {CONF_ACCESS_TOKEN: "access_token"} assert len(mock_setup.mock_calls) == 1 diff --git a/tests/components/kmtronic/test_config_flow.py b/tests/components/kmtronic/test_config_flow.py index a59821b4ec5..725058c662a 100644 --- a/tests/components/kmtronic/test_config_flow.py +++ b/tests/components/kmtronic/test_config_flow.py @@ -24,7 +24,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with patch( @@ -41,7 +41,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None: ) 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["data"] == { "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"} @@ -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"} @@ -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"} diff --git a/tests/components/knx/test_config_flow.py b/tests/components/knx/test_config_flow.py index 44d5b8bcf80..f12a57f97ba 100644 --- a/tests/components/knx/test_config_flow.py +++ b/tests/components/knx/test_config_flow.py @@ -148,7 +148,7 @@ async def test_user_single_instance(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "single_instance_allowed" diff --git a/tests/components/kodi/test_config_flow.py b/tests/components/kodi/test_config_flow.py index ecc3bc1f672..d570654be93 100644 --- a/tests/components/kodi/test_config_flow.py +++ b/tests/components/kodi/test_config_flow.py @@ -11,6 +11,7 @@ from homeassistant.components.kodi.config_flow import ( ) from homeassistant.components.kodi.const import DEFAULT_TIMEOUT, DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from .util import ( TEST_CREDENTIALS, @@ -34,7 +35,7 @@ async def user_flow(hass): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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) 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["data"] == { **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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "credentials" assert result["errors"] == {} @@ -110,7 +111,7 @@ async def test_form_valid_auth(hass: HomeAssistant, user_flow) -> None: ) 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["data"] == { **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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "ws_port" 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() - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_HOST["host"] assert result["data"] == { **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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "ws_port" 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() - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == TEST_HOST["host"] assert result["data"] == { **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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "credentials" assert result["errors"] == {} @@ -257,7 +258,7 @@ async def test_form_invalid_auth(hass: HomeAssistant, user_flow) -> None: result["flow_id"], TEST_CREDENTIALS ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "credentials" 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 ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "credentials" 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 ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "credentials" 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 ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "ws_port" 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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "ws_port" 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 ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "ws_port" 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 ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "ws_port" 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) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "ws_port" assert result["errors"] == {} @@ -460,7 +461,7 @@ async def test_form_exception_ws(hass: HomeAssistant, user_flow) -> None: result["flow_id"], TEST_WS_PORT ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "ws_port" assert result["errors"] == {"base": "unknown"} @@ -483,7 +484,7 @@ async def test_discovery(hass: HomeAssistant) -> None: data=TEST_DISCOVERY, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "discovery_confirm" with patch( @@ -495,7 +496,7 @@ async def test_discovery(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "hostname" assert result["data"] == { **TEST_HOST, @@ -527,7 +528,7 @@ async def test_discovery_cannot_connect_http(hass: HomeAssistant) -> None: data=TEST_DISCOVERY, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "cannot_connect" @@ -554,7 +555,7 @@ async def test_discovery_cannot_connect_ws(hass: HomeAssistant) -> None: data=TEST_DISCOVERY, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "ws_port" assert result["errors"] == {} @@ -577,7 +578,7 @@ async def test_discovery_exception_http(hass: HomeAssistant, user_flow) -> None: data=TEST_DISCOVERY, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "unknown" @@ -599,7 +600,7 @@ async def test_discovery_invalid_auth(hass: HomeAssistant) -> None: data=TEST_DISCOVERY, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "credentials" assert result["errors"] == {} @@ -622,14 +623,14 @@ async def test_discovery_duplicate_data(hass: HomeAssistant) -> None: data=TEST_DISCOVERY, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "discovery_confirm" result = await hass.config_entries.flow.async_init( 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" @@ -647,7 +648,7 @@ async def test_discovery_updates_unique_id(hass: HomeAssistant) -> None: 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 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, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "no_uuid" @@ -690,7 +691,7 @@ async def test_form_import(hass: HomeAssistant) -> None: ) 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["data"] == TEST_IMPORT @@ -715,7 +716,7 @@ async def test_form_import_invalid_auth(hass: HomeAssistant) -> None: data=TEST_IMPORT, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "invalid_auth" @@ -737,7 +738,7 @@ async def test_form_import_cannot_connect(hass: HomeAssistant) -> None: data=TEST_IMPORT, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "cannot_connect" @@ -759,5 +760,5 @@ async def test_form_import_exception(hass: HomeAssistant) -> None: data=TEST_IMPORT, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "unknown" diff --git a/tests/components/konnected/test_config_flow.py b/tests/components/konnected/test_config_flow.py index c46e115d159..5865616c544 100644 --- a/tests/components/konnected/test_config_flow.py +++ b/tests/components/konnected/test_config_flow.py @@ -8,6 +8,7 @@ from homeassistant import config_entries from homeassistant.components import konnected, ssdp from homeassistant.components.konnected import config_flow from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType 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( config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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["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["description_placeholders"] == { "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["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"]["port"] == 1234 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( config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" # 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["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["description_placeholders"] == { "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["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"]["port"] == 1234 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["description_placeholders"] == { "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" # 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" # 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" # 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" # 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" @@ -267,21 +268,21 @@ async def test_import_no_host_user_finish(hass: HomeAssistant, mock_panel) -> No "id": "aabbccddeeff", }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "import_confirm" assert result["description_placeholders"]["id"] == "aabbccddeeff" result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" # confirm user is prompted to enter host result = await hass.config_entries.flow.async_configure( 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["description_placeholders"] == { "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["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: @@ -334,7 +335,7 @@ async def test_import_ssdp_host_user_finish(hass: HomeAssistant, mock_panel) -> "id": "somechipid", }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "import_confirm" 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" result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "confirm" assert result["description_placeholders"] == { "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["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: @@ -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" @@ -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 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" result = await hass.config_entries.flow.async_configure( 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", "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 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" result = await hass.config_entries.flow.async_configure( 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", "port": 1234, @@ -802,7 +803,7 @@ async def test_option_flow(hass: HomeAssistant, mock_panel) -> None: result = await hass.config_entries.options.async_init( entry.entry_id, context={"source": "test"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_io" 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", }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_binary" assert result["description_placeholders"] == { "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["flow_id"], user_input={"type": "door"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_binary" assert result["description_placeholders"] == { "zone": "Zone 6", @@ -838,7 +839,7 @@ async def test_option_flow(hass: HomeAssistant, mock_panel) -> None: result["flow_id"], 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["description_placeholders"] == { "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["flow_id"], user_input={"type": "dht"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_switch" assert result["description_placeholders"] == { "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["flow_id"], user_input={} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_switch" assert result["description_placeholders"] == { "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["description_placeholders"] == { "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" # make sure we enforce url format 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" result = await hass.config_entries.options.async_configure( result["flow_id"], @@ -923,7 +924,7 @@ async def test_option_flow(hass: HomeAssistant, mock_panel) -> None: "api_host": "http://overridehost:1111", }, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["data"] == { "io": { "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( entry.entry_id, context={"source": "test"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_io" 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", }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_io_ext" 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", }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_binary" # zone 2 result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={"type": "door"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_binary" # zone 6 @@ -1034,42 +1035,42 @@ async def test_option_flow_pro(hass: HomeAssistant, mock_panel) -> None: result["flow_id"], user_input={"type": "window", "name": "winder", "inverse": True}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_binary" # zone 10 result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={"type": "door"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_binary" # zone 11 result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={"type": "window"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_digital" # zone 3 result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={"type": "dht"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_digital" # zone 7 result = await hass.config_entries.options.async_configure( 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" # zone 4 result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_switch" # zone 8 @@ -1083,21 +1084,21 @@ async def test_option_flow_pro(hass: HomeAssistant, mock_panel) -> None: "repeat": 4, }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_switch" # zone out1 result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_switch" # zone alarm1 result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_misc" 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}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["data"] == { "io": { "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( entry.entry_id, context={"source": "test"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_io" # 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", }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_io_ext" schema = result["data_schema"]({}) assert schema["8"] == "Disabled" @@ -1227,7 +1228,7 @@ async def test_option_flow_import(hass: HomeAssistant, mock_panel) -> None: result["flow_id"], user_input={}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_binary" # 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["flow_id"], user_input={"type": "door"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_digital" # zone 2 @@ -1249,7 +1250,7 @@ async def test_option_flow_import(hass: HomeAssistant, mock_panel) -> None: result["flow_id"], user_input={"type": "dht"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_switch" # 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["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" schema = result["data_schema"]({}) @@ -1275,7 +1276,7 @@ async def test_option_flow_import(hass: HomeAssistant, mock_panel) -> None: ) # verify the updated fields - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["data"] == { "io": {"1": "Binary Sensor", "2": "Digital Sensor", "3": "Switchable Output"}, "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( entry.entry_id, context={"source": "test"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options_io" # confirm the defaults are pulled in from the existing options diff --git a/tests/components/kostal_plenticore/test_config_flow.py b/tests/components/kostal_plenticore/test_config_flow.py index 41acfb1d136..d94256ebf1a 100644 --- a/tests/components/kostal_plenticore/test_config_flow.py +++ b/tests/components/kostal_plenticore/test_config_flow.py @@ -9,6 +9,7 @@ import pytest from homeassistant import config_entries from homeassistant.components.kostal_plenticore.const import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from tests.common import MockConfigEntry @@ -44,7 +45,7 @@ async def test_form_g1( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with patch( @@ -91,7 +92,7 @@ async def test_form_g1( "scb:network", "Hostname" ) - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "scb" assert result2["data"] == { "host": "1.1.1.1", @@ -110,7 +111,7 @@ async def test_form_g2( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with patch( @@ -157,7 +158,7 @@ async def test_form_g2( "scb:network", "Network:Hostname" ) - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "scb" assert result2["data"] == { "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"} @@ -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"} @@ -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"} @@ -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" diff --git a/tests/components/kraken/test_config_flow.py b/tests/components/kraken/test_config_flow.py index e6639264291..e1971ec3ab8 100644 --- a/tests/components/kraken/test_config_flow.py +++ b/tests/components/kraken/test_config_flow.py @@ -5,6 +5,7 @@ from unittest.mock import patch from homeassistant.components.kraken.const import CONF_TRACKED_ASSET_PAIRS, DOMAIN from homeassistant.const import CONF_SCAN_INTERVAL from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType 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( 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"], {}) 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 @@ -37,7 +38,7 @@ async def test_already_configured(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": "user"} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -86,7 +87,7 @@ async def test_options(hass: HomeAssistant) -> None: CONF_TRACKED_ASSET_PAIRS: ["ADA/ETH"], }, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY await hass.async_block_till_done() ada_eth_sensor = hass.states.get("sensor.ada_eth_ask") diff --git a/tests/components/kulersky/test_config_flow.py b/tests/components/kulersky/test_config_flow.py index 9638df360c8..a2f3949bd07 100644 --- a/tests/components/kulersky/test_config_flow.py +++ b/tests/components/kulersky/test_config_flow.py @@ -7,6 +7,7 @@ import pykulersky from homeassistant import config_entries from homeassistant.components.kulersky.config_flow import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None light = MagicMock(spec=pykulersky.Light) @@ -37,7 +38,7 @@ async def test_flow_success(hass: HomeAssistant) -> None: ) 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["data"] == {} @@ -50,7 +51,7 @@ async def test_flow_no_devices_found(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None with ( @@ -69,7 +70,7 @@ async def test_flow_no_devices_found(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT assert result2["reason"] == "no_devices_found" 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None with ( @@ -99,6 +100,6 @@ async def test_flow_exceptions_caught(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT assert result2["reason"] == "no_devices_found" assert len(mock_setup_entry.mock_calls) == 0 diff --git a/tests/components/lg_soundbar/test_config_flow.py b/tests/components/lg_soundbar/test_config_flow.py index 4fab919c555..806c993e792 100644 --- a/tests/components/lg_soundbar/test_config_flow.py +++ b/tests/components/lg_soundbar/test_config_flow.py @@ -11,6 +11,7 @@ from homeassistant import config_entries from homeassistant.components.lg_soundbar.const import DEFAULT_PORT, DOMAIN from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from tests.common import MockConfigEntry @@ -58,7 +59,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -83,7 +84,7 @@ async def test_form(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "name" assert result2["result"].unique_id == "uuid" 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -124,7 +125,7 @@ async def test_form_mac_info_response_empty(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "name" assert result2["result"].unique_id == "uuid" 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -172,7 +173,7 @@ async def test_form_uuid_present_in_both_functions_uuid_q_empty( ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "name" assert result2["result"].unique_id == "uuid" 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -224,7 +225,7 @@ async def test_form_uuid_present_in_both_functions_uuid_q_not_empty( ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "name" assert result2["result"].unique_id == "uuid" 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -266,7 +267,7 @@ async def test_form_uuid_missing_from_mac_info(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "name" assert result2["result"].unique_id == "uuid" 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -311,7 +312,7 @@ async def test_form_uuid_not_provided_by_api(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "name" assert result2["result"].unique_id is None 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -352,7 +353,7 @@ async def test_form_both_queues_empty(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "no_data"} 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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} 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" @@ -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"} @@ -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"} @@ -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" diff --git a/tests/components/lifx/test_config_flow.py b/tests/components/lifx/test_config_flow.py index 67fcc1b7dfa..59b7090788a 100644 --- a/tests/components/lifx/test_config_flow.py +++ b/tests/components/lifx/test_config_flow.py @@ -41,13 +41,13 @@ async def test_discovery(hass: HomeAssistant) -> None: DOMAIN, context={"source": config_entries.SOURCE_USER} ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "pick_device" assert not result2["errors"] @@ -55,13 +55,13 @@ async def test_discovery(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "pick_device" assert not result2["errors"] @@ -77,7 +77,7 @@ async def test_discovery(hass: HomeAssistant) -> None: ) 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["data"] == {CONF_HOST: IP_ADDRESS} mock_setup.assert_called_once() @@ -87,7 +87,7 @@ async def test_discovery(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT 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} ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {}) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "pick_device" assert not result2["errors"] @@ -122,7 +122,7 @@ async def test_discovery_but_cannot_connect(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result3["type"] == "abort" + assert result3["type"] is FlowResultType.ABORT 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "pick_device" 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "pick_device" 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( 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["data"] == { 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] @@ -238,7 +238,7 @@ async def test_manual(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "user" assert result2["errors"] == {"base": "cannot_connect"} @@ -253,7 +253,7 @@ async def test_manual(hass: HomeAssistant) -> None: result["flow_id"], {CONF_HOST: IP_ADDRESS} ) 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["data"] == { CONF_HOST: IP_ADDRESS, @@ -272,7 +272,7 @@ async def test_manual(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] @@ -312,7 +312,7 @@ async def test_manual_dns_error(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "user" 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] @@ -337,7 +337,7 @@ async def test_manual_no_capabilities(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["data"] == { 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"], {}) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["data"] == { CONF_HOST: IP_ADDRESS, } @@ -548,7 +548,7 @@ async def test_refuse_relays(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] @@ -560,7 +560,7 @@ async def test_refuse_relays(hass: HomeAssistant) -> None: result["flow_id"], {CONF_HOST: IP_ADDRESS} ) await hass.async_block_till_done() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "cannot_connect"} diff --git a/tests/components/litejet/test_config_flow.py b/tests/components/litejet/test_config_flow.py index 4803fd393d8..7b8fa481b69 100644 --- a/tests/components/litejet/test_config_flow.py +++ b/tests/components/litejet/test_config_flow.py @@ -19,7 +19,7 @@ async def test_show_config_form(hass: HomeAssistant) -> None: DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM 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 ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "/dev/test" 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 ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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 ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"][CONF_PORT] == "open_failed" diff --git a/tests/components/litterrobot/test_config_flow.py b/tests/components/litterrobot/test_config_flow.py index b8739a73fb8..5ffb78c7782 100644 --- a/tests/components/litterrobot/test_config_flow.py +++ b/tests/components/litterrobot/test_config_flow.py @@ -22,7 +22,7 @@ async def test_form(hass: HomeAssistant, mock_account) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -40,7 +40,7 @@ async def test_form(hass: HomeAssistant, mock_account) -> None: ) 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["data"] == CONFIG[DOMAIN] assert len(mock_setup_entry.mock_calls) == 1 @@ -59,7 +59,7 @@ async def test_already_configured(hass: HomeAssistant) -> None: data=CONFIG[litterrobot.DOMAIN], ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -77,7 +77,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None: result["flow_id"], CONFIG[DOMAIN] ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "invalid_auth"} @@ -95,7 +95,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None: result["flow_id"], CONFIG[DOMAIN] ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "cannot_connect"} @@ -112,7 +112,7 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None: result["flow_id"], CONFIG[DOMAIN] ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "unknown"} diff --git a/tests/components/lookin/test_config_flow.py b/tests/components/lookin/test_config_flow.py index e3896b9c3d4..1eddbe23b24 100644 --- a/tests/components/lookin/test_config_flow.py +++ b/tests/components/lookin/test_config_flow.py @@ -31,7 +31,7 @@ async def test_manual_setup(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] @@ -88,7 +88,7 @@ async def test_manual_setup_device_offline(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert not result["errors"] @@ -107,7 +107,7 @@ async def test_manual_setup_unknown_exception(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {"base": "unknown"} diff --git a/tests/components/lutron_caseta/test_config_flow.py b/tests/components/lutron_caseta/test_config_flow.py index fd529353b98..b2edaa07155 100644 --- a/tests/components/lutron_caseta/test_config_flow.py +++ b/tests/components/lutron_caseta/test_config_flow.py @@ -75,7 +75,7 @@ async def test_bridge_import_flow(hass: HomeAssistant) -> None: ) 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["data"] == entry_mock_data assert result["result"].unique_id == "000004d2" @@ -102,7 +102,7 @@ async def test_bridge_cannot_connect(hass: HomeAssistant) -> None: data=entry_mock_data, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == STEP_IMPORT_FAILED 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, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == STEP_IMPORT_FAILED 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, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == STEP_IMPORT_FAILED assert result["errors"] == {"base": ERROR_CANNOT_CONNECT} @@ -195,7 +195,7 @@ async def test_already_configured_with_ignored(hass: HomeAssistant) -> None: CONF_CA_CERTS: "", }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None 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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "link" with ( @@ -240,7 +240,7 @@ async def test_form_user(hass: HomeAssistant, tmp_path: Path) -> None: ) 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["data"] == { 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None 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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "link" with ( @@ -294,7 +294,7 @@ async def test_form_user_pairing_fails(hass: HomeAssistant, tmp_path: Path) -> N ) await hass.async_block_till_done() - assert result3["type"] == "form" + assert result3["type"] is FlowResultType.FORM assert result3["errors"] == {"base": "cannot_connect"} assert len(mock_setup.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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None 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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "link" with ( @@ -344,7 +344,7 @@ async def test_form_user_reuses_existing_assets_when_pairing_again( ) 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["data"] == { 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( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None 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() - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["step_id"] == "link" with ( @@ -396,7 +396,7 @@ async def test_form_user_reuses_existing_assets_when_pairing_again( ) 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["data"] == { CONF_HOST: "1.1.1.1", @@ -433,7 +433,7 @@ async def test_zeroconf_host_already_configured( ) await hass.async_block_till_done() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" 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() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "link" with ( @@ -534,7 +534,7 @@ async def test_zeroconf(hass: HomeAssistant, source, tmp_path: Path) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "abc" assert result2["data"] == { CONF_HOST: "1.1.1.1", diff --git a/tests/components/melcloud/test_config_flow.py b/tests/components/melcloud/test_config_flow.py index 312daebd93f..621838e8c67 100644 --- a/tests/components/melcloud/test_config_flow.py +++ b/tests/components/melcloud/test_config_flow.py @@ -52,7 +52,7 @@ async def test_form(hass: HomeAssistant, mock_login, mock_get_devices) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None with patch( @@ -64,7 +64,7 @@ async def test_form(hass: HomeAssistant, mock_login, mock_get_devices) -> None: ) 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["data"] == { "username": "test-email@test-domain.com", @@ -90,7 +90,7 @@ async def test_form_errors( ) assert len(mock_login.mock_calls) == 1 - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == reason @@ -114,7 +114,7 @@ async def test_form_response_errors( data={"username": "test-email@test-domain.com", "password": "test-password"}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT 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" await hass.async_block_till_done() assert len(mock_setup_entry.mock_calls) == 0 diff --git a/tests/components/met/test_config_flow.py b/tests/components/met/test_config_flow.py index 8d0b1620022..c494c4afeb9 100644 --- a/tests/components/met/test_config_flow.py +++ b/tests/components/met/test_config_flow.py @@ -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.const import CONF_ELEVATION, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from . import init_integration @@ -31,7 +32,7 @@ async def test_show_config_form(hass: HomeAssistant) -> None: DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM 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} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" 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 ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "home" 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 ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"]["name"] == "already_configured" @@ -110,7 +111,7 @@ async def test_onboarding_step(hass: HomeAssistant) -> None: 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["data"] == {"track_home": True} @@ -134,7 +135,7 @@ async def test_onboarding_step_abort_no_home( DOMAIN, context={"source": "onboarding"}, data={} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "no_home" @@ -153,7 +154,7 @@ async def test_options_flow(hass: HomeAssistant) -> None: # Test show Options form 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" # Test Options flow updated config entry @@ -164,7 +165,7 @@ async def test_options_flow(hass: HomeAssistant) -> None: entry.entry_id, data=update_data ) 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["data"] == update_data weatherdatamock.assert_called_with( diff --git a/tests/components/met_eireann/test_config_flow.py b/tests/components/met_eireann/test_config_flow.py index 2bb5c9ffe8f..cddc20b835a 100644 --- a/tests/components/met_eireann/test_config_flow.py +++ b/tests/components/met_eireann/test_config_flow.py @@ -26,7 +26,7 @@ async def test_show_config_form(hass: HomeAssistant) -> None: 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 @@ -44,7 +44,7 @@ async def test_flow_with_home_location(hass: HomeAssistant) -> None: 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 default_data = result["data_schema"]({}) diff --git a/tests/components/metoffice/test_config_flow.py b/tests/components/metoffice/test_config_flow.py index e4424b0b394..c2e75d89c1a 100644 --- a/tests/components/metoffice/test_config_flow.py +++ b/tests/components/metoffice/test_config_flow.py @@ -8,6 +8,7 @@ import requests_mock from homeassistant import config_entries from homeassistant.components.metoffice.const import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from .const import ( METOFFICE_CONFIG_WAVERTREE, @@ -33,7 +34,7 @@ async def test_form(hass: HomeAssistant, requests_mock: requests_mock.Mocker) -> result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with patch( @@ -45,7 +46,7 @@ async def test_form(hass: HomeAssistant, requests_mock: requests_mock.Mocker) -> ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == TEST_SITE_NAME_WAVERTREE assert result2["data"] == { "api_key": TEST_API_KEY, @@ -90,7 +91,7 @@ async def test_form_already_configured( data=METOFFICE_CONFIG_WAVERTREE, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -112,7 +113,7 @@ async def test_form_cannot_connect( {"api_key": TEST_API_KEY}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "cannot_connect"} @@ -132,5 +133,5 @@ async def test_form_unknown_error( {"api_key": TEST_API_KEY}, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "unknown"} diff --git a/tests/components/microbees/test_config_flow.py b/tests/components/microbees/test_config_flow.py index 9f8ca8c7747..327d0214f7a 100644 --- a/tests/components/microbees/test_config_flow.py +++ b/tests/components/microbees/test_config_flow.py @@ -152,7 +152,7 @@ async def test_config_reauth_profile( }, data=config_entry.data, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) @@ -213,7 +213,7 @@ async def test_config_reauth_wrong_account( }, data=config_entry.data, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) diff --git a/tests/components/mikrotik/test_config_flow.py b/tests/components/mikrotik/test_config_flow.py index 0cc62b9bd8e..f34fde0c9a5 100644 --- a/tests/components/mikrotik/test_config_flow.py +++ b/tests/components/mikrotik/test_config_flow.py @@ -133,7 +133,7 @@ async def test_host_already_configured(hass: HomeAssistant, auth_error) -> None: result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input=DEMO_USER_INPUT ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -184,7 +184,7 @@ async def test_reauth_success(hass: HomeAssistant, api) -> None: data=DEMO_USER_INPUT, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" assert result["description_placeholders"] == {CONF_USERNAME: "username"} @@ -195,7 +195,7 @@ async def test_reauth_success(hass: HomeAssistant, api) -> None: }, ) - assert result2["type"] == "abort" + assert result2["type"] is FlowResultType.ABORT assert result2["reason"] == "reauth_successful" @@ -216,7 +216,7 @@ async def test_reauth_failed(hass: HomeAssistant, auth_error) -> None: data=DEMO_USER_INPUT, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" result2 = await hass.config_entries.flow.async_configure( @@ -226,7 +226,7 @@ async def test_reauth_failed(hass: HomeAssistant, auth_error) -> None: }, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == { CONF_PASSWORD: "invalid_auth", } @@ -249,7 +249,7 @@ async def test_reauth_failed_conn_error(hass: HomeAssistant, conn_error) -> None data=DEMO_USER_INPUT, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "reauth_confirm" result2 = await hass.config_entries.flow.async_configure( @@ -259,5 +259,5 @@ async def test_reauth_failed_conn_error(hass: HomeAssistant, conn_error) -> None }, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "cannot_connect"} diff --git a/tests/components/mill/test_config_flow.py b/tests/components/mill/test_config_flow.py index 23c7c3d0e67..832aaef3b19 100644 --- a/tests/components/mill/test_config_flow.py +++ b/tests/components/mill/test_config_flow.py @@ -47,7 +47,7 @@ async def test_create_entry(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == "user" assert result["data"] == { CONF_USERNAME: "user", @@ -92,7 +92,7 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -160,7 +160,7 @@ async def test_local_create_entry(hass: HomeAssistant) -> None: ) test_data[CONNECTION_TYPE] = LOCAL - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == test_data[CONF_IP_ADDRESS] assert result["data"] == test_data @@ -211,7 +211,7 @@ async def test_local_flow_entry_already_exists(hass: HomeAssistant) -> None: test_data, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" diff --git a/tests/components/monoprice/test_config_flow.py b/tests/components/monoprice/test_config_flow.py index 30d0266eeea..fafdb3c2ecf 100644 --- a/tests/components/monoprice/test_config_flow.py +++ b/tests/components/monoprice/test_config_flow.py @@ -32,7 +32,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {} with ( @@ -50,7 +50,7 @@ async def test_form(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == CONFIG[CONF_PORT] assert result2["data"] == { CONF_PORT: CONFIG[CONF_PORT], @@ -73,7 +73,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None: result["flow_id"], CONFIG ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "cannot_connect"} @@ -91,7 +91,7 @@ async def test_generic_exception(hass: HomeAssistant) -> None: result["flow_id"], CONFIG ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": "unknown"} diff --git a/tests/components/motion_blinds/test_config_flow.py b/tests/components/motion_blinds/test_config_flow.py index ac49d51f7ef..4168c3a1f63 100644 --- a/tests/components/motion_blinds/test_config_flow.py +++ b/tests/components/motion_blinds/test_config_flow.py @@ -133,7 +133,7 @@ async def test_config_flow_manual_host_success(hass: HomeAssistant) -> None: const.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -142,7 +142,7 @@ async def test_config_flow_manual_host_success(hass: HomeAssistant) -> None: {CONF_HOST: TEST_HOST}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "connect" assert result["errors"] == {} @@ -151,7 +151,7 @@ async def test_config_flow_manual_host_success(hass: HomeAssistant) -> None: {CONF_API_KEY: TEST_API_KEY}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == DEFAULT_GATEWAY_NAME assert result["data"] == { CONF_HOST: TEST_HOST, @@ -166,7 +166,7 @@ async def test_config_flow_discovery_1_success(hass: HomeAssistant) -> None: const.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -175,7 +175,7 @@ async def test_config_flow_discovery_1_success(hass: HomeAssistant) -> None: {}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "connect" assert result["errors"] == {} @@ -188,7 +188,7 @@ async def test_config_flow_discovery_1_success(hass: HomeAssistant) -> None: {CONF_API_KEY: TEST_API_KEY}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == DEFAULT_GATEWAY_NAME assert result["data"] == { CONF_HOST: TEST_HOST, @@ -203,7 +203,7 @@ async def test_config_flow_discovery_2_success(hass: HomeAssistant) -> None: const.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -216,7 +216,7 @@ async def test_config_flow_discovery_2_success(hass: HomeAssistant) -> None: {}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "select" assert result["data_schema"].schema["select_ip"].container == [ TEST_HOST, @@ -229,7 +229,7 @@ async def test_config_flow_discovery_2_success(hass: HomeAssistant) -> None: {"select_ip": TEST_HOST2}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "connect" assert result["errors"] == {} @@ -242,7 +242,7 @@ async def test_config_flow_discovery_2_success(hass: HomeAssistant) -> None: {CONF_API_KEY: TEST_API_KEY}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == DEFAULT_GATEWAY_NAME assert result["data"] == { CONF_HOST: TEST_HOST2, @@ -257,7 +257,7 @@ async def test_config_flow_connection_error(hass: HomeAssistant) -> None: const.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -266,7 +266,7 @@ async def test_config_flow_connection_error(hass: HomeAssistant) -> None: {CONF_HOST: TEST_HOST}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "connect" assert result["errors"] == {} @@ -279,7 +279,7 @@ async def test_config_flow_connection_error(hass: HomeAssistant) -> None: {CONF_API_KEY: TEST_API_KEY}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "connection_error" @@ -289,7 +289,7 @@ async def test_config_flow_discovery_fail(hass: HomeAssistant) -> None: const.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -302,7 +302,7 @@ async def test_config_flow_discovery_fail(hass: HomeAssistant) -> None: {}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {"base": "discovery_error"} @@ -313,7 +313,7 @@ async def test_config_flow_invalid_interface(hass: HomeAssistant) -> None: const.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -322,7 +322,7 @@ async def test_config_flow_invalid_interface(hass: HomeAssistant) -> None: {CONF_HOST: TEST_HOST}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "connect" assert result["errors"] == {} @@ -335,7 +335,7 @@ async def test_config_flow_invalid_interface(hass: HomeAssistant) -> None: {CONF_API_KEY: TEST_API_KEY}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == DEFAULT_GATEWAY_NAME assert result["data"] == { CONF_HOST: TEST_HOST, @@ -356,7 +356,7 @@ async def test_dhcp_flow(hass: HomeAssistant) -> None: const.DOMAIN, context={"source": config_entries.SOURCE_DHCP}, data=dhcp_data ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "connect" assert result["errors"] == {} @@ -369,7 +369,7 @@ async def test_dhcp_flow(hass: HomeAssistant) -> None: {CONF_API_KEY: TEST_API_KEY}, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == DEFAULT_GATEWAY_NAME assert result["data"] == { CONF_HOST: TEST_HOST, @@ -394,7 +394,7 @@ async def test_dhcp_flow_abort(hass: HomeAssistant) -> None: const.DOMAIN, context={"source": config_entries.SOURCE_DHCP}, data=dhcp_data ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "not_motionblinds" @@ -414,7 +414,7 @@ async def test_dhcp_flow_abort_invalid_response(hass: HomeAssistant) -> None: const.DOMAIN, context={"source": config_entries.SOURCE_DHCP}, data=dhcp_data ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "not_motionblinds" @@ -468,7 +468,7 @@ async def test_change_connection_settings(hass: HomeAssistant) -> None: const.DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "user" assert result["errors"] == {} @@ -477,7 +477,7 @@ async def test_change_connection_settings(hass: HomeAssistant) -> None: {CONF_HOST: TEST_HOST2}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "connect" assert result["errors"] == {} @@ -486,7 +486,7 @@ async def test_change_connection_settings(hass: HomeAssistant) -> None: {CONF_API_KEY: TEST_API_KEY2}, ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert config_entry.data[CONF_HOST] == TEST_HOST2 assert config_entry.data[CONF_API_KEY] == TEST_API_KEY2 assert config_entry.data[const.CONF_INTERFACE] == TEST_HOST_ANY diff --git a/tests/components/motioneye/test_config_flow.py b/tests/components/motioneye/test_config_flow.py index 404200bd01a..816fb31933a 100644 --- a/tests/components/motioneye/test_config_flow.py +++ b/tests/components/motioneye/test_config_flow.py @@ -35,7 +35,7 @@ async def test_user_success(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert not result["errors"] mock_client = create_mock_motioneye_client() @@ -62,7 +62,7 @@ async def test_user_success(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["title"] == f"{TEST_URL}" assert result["data"] == { CONF_URL: TEST_URL, @@ -160,7 +160,7 @@ async def test_user_invalid_auth(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {"base": "invalid_auth"} assert mock_client.async_client_close.called @@ -189,7 +189,7 @@ async def test_user_invalid_url(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {"base": "invalid_url"} @@ -220,7 +220,7 @@ async def test_user_cannot_connect(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {"base": "cannot_connect"} assert mock_client.async_client_close.called @@ -250,7 +250,7 @@ async def test_user_request_error(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] == {"base": "unknown"} assert mock_client.async_client_close.called @@ -272,7 +272,7 @@ async def test_reauth(hass: HomeAssistant) -> None: }, data=config_entry.data, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert not result["errors"] mock_client = create_mock_motioneye_client() @@ -329,7 +329,7 @@ async def test_duplicate(hass: HomeAssistant) -> None: DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert not result["errors"] mock_client = create_mock_motioneye_client() diff --git a/tests/components/mqtt/test_config_flow.py b/tests/components/mqtt/test_config_flow.py index f160fc0561a..bbba791137a 100644 --- a/tests/components/mqtt/test_config_flow.py +++ b/tests/components/mqtt/test_config_flow.py @@ -186,13 +186,13 @@ async def test_user_connection_works( result = await hass.config_entries.flow.async_init( "mqtt", 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"], {"broker": "127.0.0.1"} ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["result"].data == { "broker": "127.0.0.1", "port": 1883, @@ -217,7 +217,7 @@ async def test_user_v5_connection_works( "mqtt", context={"source": config_entries.SOURCE_USER, "show_advanced_options": True}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM result = await hass.config_entries.flow.async_configure( result["flow_id"], {"broker": "127.0.0.1", "advanced_options": True} @@ -233,7 +233,7 @@ async def test_user_v5_connection_works( mqtt.CONF_PROTOCOL: "5", }, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["result"].data == { "broker": "another-broker", "discovery": True, @@ -255,13 +255,13 @@ async def test_user_connection_fails( result = await hass.config_entries.flow.async_init( "mqtt", 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"], {"broker": "127.0.0.1"} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"]["base"] == "cannot_connect" # Check we tried the connection @@ -285,13 +285,13 @@ async def test_manual_config_set( result = await hass.config_entries.flow.async_init( "mqtt", 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"], {"broker": "127.0.0.1", "port": "1883"} ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["result"].data == { "broker": "127.0.0.1", "port": 1883, @@ -318,7 +318,7 @@ async def test_user_single_instance(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( "mqtt", context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "single_instance_allowed" @@ -329,7 +329,7 @@ async def test_hassio_already_configured(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( "mqtt", context={"source": config_entries.SOURCE_HASSIO} ) - assert result["type"] == "abort" + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -385,7 +385,7 @@ async def test_hassio_confirm( ), context={"source": config_entries.SOURCE_HASSIO}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "hassio_confirm" assert result["description_placeholders"] == {"addon": "Mock Addon"} @@ -394,7 +394,7 @@ async def test_hassio_confirm( result["flow_id"], {"discovery": True} ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY assert result["result"].data == { "broker": "mock-broker", "port": 1883, @@ -434,7 +434,7 @@ async def test_hassio_cannot_connect( ), context={"source": config_entries.SOURCE_HASSIO}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "hassio_confirm" assert result["description_placeholders"] == {"addon": "Mock Addon"} @@ -443,7 +443,7 @@ async def test_hassio_cannot_connect( result["flow_id"], {"discovery": True} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"]["base"] == "cannot_connect" # Check we tried the connection assert len(mock_try_connection_time_out.mock_calls) @@ -1074,7 +1074,7 @@ async def test_options_user_connection_fails( }, ) result = await hass.config_entries.options.async_init(config_entry.entry_id) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM mock_try_connection_time_out.reset_mock() result = await hass.config_entries.options.async_configure( @@ -1082,7 +1082,7 @@ async def test_options_user_connection_fails( user_input={mqtt.CONF_BROKER: "bad-broker", mqtt.CONF_PORT: 2345}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"]["base"] == "cannot_connect" # Check we tried the connection @@ -1111,21 +1111,21 @@ async def test_options_bad_birth_message_fails( mock_try_connection.return_value = True result = await hass.config_entries.options.async_init(config_entry.entry_id) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={mqtt.CONF_BROKER: "another-broker", mqtt.CONF_PORT: 2345}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options" result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={"birth_topic": "ha_state/online/#"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"]["base"] == "bad_birth" # Check config entry did not update @@ -1152,21 +1152,21 @@ async def test_options_bad_will_message_fails( mock_try_connection.return_value = True result = await hass.config_entries.options.async_init(config_entry.entry_id) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={mqtt.CONF_BROKER: "another-broker", mqtt.CONF_PORT: 2345}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options" result = await hass.config_entries.options.async_configure( result["flow_id"], user_input={"will_topic": "ha_state/offline/#"}, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"]["base"] == "bad_will" # Check config entry did not update @@ -1321,7 +1321,7 @@ async def test_setup_with_advanced_settings( result = await hass.config_entries.options.async_init( config_entry.entry_id, context={"show_advanced_options": True} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "broker" assert result["data_schema"].schema["advanced_options"] @@ -1336,7 +1336,7 @@ async def test_setup_with_advanced_settings( "advanced_options": True, }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "broker" assert "advanced_options" not in result["data_schema"].schema assert result["data_schema"].schema[mqtt.CONF_CLIENT_ID] @@ -1365,7 +1365,7 @@ async def test_setup_with_advanced_settings( mqtt.CONF_TRANSPORT: "websockets", }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "broker" assert "advanced_options" not in result["data_schema"].schema assert result["data_schema"].schema[mqtt.CONF_CLIENT_ID] @@ -1400,7 +1400,7 @@ async def test_setup_with_advanced_settings( }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "broker" assert result["errors"]["base"] == "bad_ws_headers" @@ -1425,7 +1425,7 @@ async def test_setup_with_advanced_settings( }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options" result = await hass.config_entries.options.async_configure( @@ -1435,7 +1435,7 @@ async def test_setup_with_advanced_settings( mqtt.CONF_DISCOVERY_PREFIX: "homeassistant_test", }, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY # Check config entry result assert config_entry.data == { @@ -1482,7 +1482,7 @@ async def test_change_websockets_transport_to_tcp( mock_try_connection.return_value = True 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"] == "broker" assert result["data_schema"].schema["transport"] assert result["data_schema"].schema["ws_path"] @@ -1499,7 +1499,7 @@ async def test_change_websockets_transport_to_tcp( mqtt.CONF_WS_PATH: "/some_path", }, ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["step_id"] == "options" result = await hass.config_entries.options.async_configure( @@ -1509,7 +1509,7 @@ async def test_change_websockets_transport_to_tcp( mqtt.CONF_DISCOVERY_PREFIX: "homeassistant_test", }, ) - assert result["type"] == "create_entry" + assert result["type"] is FlowResultType.CREATE_ENTRY # Check config entry result assert config_entry.data == { diff --git a/tests/components/mullvad/test_config_flow.py b/tests/components/mullvad/test_config_flow.py index a2468fbe7d2..dbf90be3416 100644 --- a/tests/components/mullvad/test_config_flow.py +++ b/tests/components/mullvad/test_config_flow.py @@ -36,7 +36,7 @@ async def test_form_user(hass: HomeAssistant) -> None: ) await hass.async_block_till_done() - assert result2["type"] == "create_entry" + assert result2["type"] is FlowResultType.CREATE_ENTRY assert result2["title"] == "Mullvad VPN" assert result2["data"] == {} assert len(mock_setup_entry.mock_calls) == 1 diff --git a/tests/components/mutesync/test_config_flow.py b/tests/components/mutesync/test_config_flow.py index f667671da74..07bcfe66f02 100644 --- a/tests/components/mutesync/test_config_flow.py +++ b/tests/components/mutesync/test_config_flow.py @@ -8,6 +8,7 @@ import pytest from homeassistant import config_entries from homeassistant.components.mutesync.const import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType async def test_form(hass: HomeAssistant) -> None: @@ -16,7 +17,7 @@ async def test_form(hass: HomeAssistant) -> None: result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["type"] == "form" + assert result["type"] is FlowResultType.FORM assert result["errors"] is None with ( @@ -37,7 +38,7 @@ async def test_form(hass: HomeAssistant) -> None: ) 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["data"] == { "host": "1.1.1.1", @@ -74,5 +75,5 @@ async def test_form_error( }, ) - assert result2["type"] == "form" + assert result2["type"] is FlowResultType.FORM assert result2["errors"] == {"base": error}