From 05416f56aa8f136126c85f72f6d53f93b5c5c3a7 Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Wed, 6 Jul 2022 09:45:30 +0200 Subject: [PATCH] Use FlowResultType in deCONZ config flow tests (#74495) --- tests/components/deconz/test_config_flow.py | 76 ++++++++++----------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/tests/components/deconz/test_config_flow.py b/tests/components/deconz/test_config_flow.py index 1a7031a0fd6..2f21081a5ae 100644 --- a/tests/components/deconz/test_config_flow.py +++ b/tests/components/deconz/test_config_flow.py @@ -29,11 +29,7 @@ from homeassistant.config_entries import ( SOURCE_USER, ) from homeassistant.const import CONF_API_KEY, CONF_HOST, CONF_PORT, CONTENT_TYPE_JSON -from homeassistant.data_entry_flow import ( - RESULT_TYPE_ABORT, - RESULT_TYPE_CREATE_ENTRY, - RESULT_TYPE_FORM, -) +from homeassistant.data_entry_flow import FlowResultType from .test_gateway import API_KEY, BRIDGEID, setup_deconz_integration @@ -55,14 +51,14 @@ async def test_flow_discovered_bridges(hass, aioclient_mock): DECONZ_DOMAIN, context={"source": SOURCE_USER} ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "user" result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={CONF_HOST: "1.2.3.4"} ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "link" aioclient_mock.post( @@ -75,7 +71,7 @@ async def test_flow_discovered_bridges(hass, aioclient_mock): result["flow_id"], user_input={} ) - assert result["type"] == RESULT_TYPE_CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY assert result["title"] == BRIDGEID assert result["data"] == { CONF_HOST: "1.2.3.4", @@ -100,7 +96,7 @@ async def test_flow_manual_configuration_decision(hass, aioclient_mock): result["flow_id"], user_input={CONF_HOST: CONF_MANUAL_INPUT} ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "manual_input" result = await hass.config_entries.flow.async_configure( @@ -108,7 +104,7 @@ async def test_flow_manual_configuration_decision(hass, aioclient_mock): user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80}, ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "link" aioclient_mock.post( @@ -127,7 +123,7 @@ async def test_flow_manual_configuration_decision(hass, aioclient_mock): result["flow_id"], user_input={} ) - assert result["type"] == RESULT_TYPE_CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY assert result["title"] == BRIDGEID assert result["data"] == { CONF_HOST: "1.2.3.4", @@ -148,7 +144,7 @@ async def test_flow_manual_configuration(hass, aioclient_mock): DECONZ_DOMAIN, context={"source": SOURCE_USER} ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "manual_input" result = await hass.config_entries.flow.async_configure( @@ -156,7 +152,7 @@ async def test_flow_manual_configuration(hass, aioclient_mock): user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80}, ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "link" aioclient_mock.post( @@ -175,7 +171,7 @@ async def test_flow_manual_configuration(hass, aioclient_mock): result["flow_id"], user_input={} ) - assert result["type"] == RESULT_TYPE_CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY assert result["title"] == BRIDGEID assert result["data"] == { CONF_HOST: "1.2.3.4", @@ -192,7 +188,7 @@ async def test_manual_configuration_after_discovery_timeout(hass, aioclient_mock DECONZ_DOMAIN, context={"source": SOURCE_USER} ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "manual_input" assert not hass.config_entries.flow._progress[result["flow_id"]].bridges @@ -205,7 +201,7 @@ async def test_manual_configuration_after_discovery_ResponseError(hass, aioclien DECONZ_DOMAIN, context={"source": SOURCE_USER} ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "manual_input" assert not hass.config_entries.flow._progress[result["flow_id"]].bridges @@ -224,7 +220,7 @@ async def test_manual_configuration_update_configuration(hass, aioclient_mock): DECONZ_DOMAIN, context={"source": SOURCE_USER} ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "manual_input" result = await hass.config_entries.flow.async_configure( @@ -232,7 +228,7 @@ async def test_manual_configuration_update_configuration(hass, aioclient_mock): user_input={CONF_HOST: "2.3.4.5", CONF_PORT: 80}, ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "link" aioclient_mock.post( @@ -251,7 +247,7 @@ async def test_manual_configuration_update_configuration(hass, aioclient_mock): result["flow_id"], user_input={} ) - assert result["type"] == RESULT_TYPE_ABORT + assert result["type"] == FlowResultType.ABORT assert result["reason"] == "already_configured" assert config_entry.data[CONF_HOST] == "2.3.4.5" @@ -270,7 +266,7 @@ async def test_manual_configuration_dont_update_configuration(hass, aioclient_mo DECONZ_DOMAIN, context={"source": SOURCE_USER} ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "manual_input" result = await hass.config_entries.flow.async_configure( @@ -278,7 +274,7 @@ async def test_manual_configuration_dont_update_configuration(hass, aioclient_mo user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80}, ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "link" aioclient_mock.post( @@ -297,7 +293,7 @@ async def test_manual_configuration_dont_update_configuration(hass, aioclient_mo result["flow_id"], user_input={} ) - assert result["type"] == RESULT_TYPE_ABORT + assert result["type"] == FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -313,7 +309,7 @@ async def test_manual_configuration_timeout_get_bridge(hass, aioclient_mock): DECONZ_DOMAIN, context={"source": SOURCE_USER} ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "manual_input" result = await hass.config_entries.flow.async_configure( @@ -321,7 +317,7 @@ async def test_manual_configuration_timeout_get_bridge(hass, aioclient_mock): user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80}, ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "link" aioclient_mock.post( @@ -338,7 +334,7 @@ async def test_manual_configuration_timeout_get_bridge(hass, aioclient_mock): result["flow_id"], user_input={} ) - assert result["type"] == RESULT_TYPE_ABORT + assert result["type"] == FlowResultType.ABORT assert result["reason"] == "no_bridges" @@ -367,7 +363,7 @@ async def test_link_step_fails(hass, aioclient_mock, raised_error, error_string) result["flow_id"], user_input={CONF_HOST: "1.2.3.4"} ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "link" aioclient_mock.post("http://1.2.3.4:80/api", exc=raised_error) @@ -376,7 +372,7 @@ async def test_link_step_fails(hass, aioclient_mock, raised_error, error_string) result["flow_id"], user_input={} ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "link" assert result["errors"] == {"base": error_string} @@ -391,7 +387,7 @@ async def test_reauth_flow_update_configuration(hass, aioclient_mock): context={"source": SOURCE_REAUTH}, ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "link" new_api_key = "new_key" @@ -412,7 +408,7 @@ async def test_reauth_flow_update_configuration(hass, aioclient_mock): result["flow_id"], user_input={} ) - assert result["type"] == RESULT_TYPE_ABORT + assert result["type"] == FlowResultType.ABORT assert result["reason"] == "already_configured" assert config_entry.data[CONF_API_KEY] == new_api_key @@ -433,7 +429,7 @@ async def test_flow_ssdp_discovery(hass, aioclient_mock): context={"source": SOURCE_SSDP}, ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "link" flows = hass.config_entries.flow.async_progress() @@ -450,7 +446,7 @@ async def test_flow_ssdp_discovery(hass, aioclient_mock): result["flow_id"], user_input={} ) - assert result["type"] == RESULT_TYPE_CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY assert result["title"] == BRIDGEID assert result["data"] == { CONF_HOST: "1.2.3.4", @@ -482,7 +478,7 @@ async def test_ssdp_discovery_update_configuration(hass, aioclient_mock): ) await hass.async_block_till_done() - assert result["type"] == RESULT_TYPE_ABORT + assert result["type"] == FlowResultType.ABORT assert result["reason"] == "already_configured" assert config_entry.data[CONF_HOST] == "2.3.4.5" assert len(mock_setup_entry.mock_calls) == 1 @@ -506,7 +502,7 @@ async def test_ssdp_discovery_dont_update_configuration(hass, aioclient_mock): context={"source": SOURCE_SSDP}, ) - assert result["type"] == RESULT_TYPE_ABORT + assert result["type"] == FlowResultType.ABORT assert result["reason"] == "already_configured" assert config_entry.data[CONF_HOST] == "1.2.3.4" @@ -533,7 +529,7 @@ async def test_ssdp_discovery_dont_update_existing_hassio_configuration( context={"source": SOURCE_SSDP}, ) - assert result["type"] == RESULT_TYPE_ABORT + assert result["type"] == FlowResultType.ABORT assert result["reason"] == "already_configured" assert config_entry.data[CONF_HOST] == "1.2.3.4" @@ -553,7 +549,7 @@ async def test_flow_hassio_discovery(hass): ), context={"source": SOURCE_HASSIO}, ) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "hassio_confirm" assert result["description_placeholders"] == {"addon": "Mock Addon"} @@ -572,7 +568,7 @@ async def test_flow_hassio_discovery(hass): ) await hass.async_block_till_done() - assert result["type"] == RESULT_TYPE_CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY assert result["result"].data == { CONF_HOST: "mock-deconz", CONF_PORT: 80, @@ -603,7 +599,7 @@ async def test_hassio_discovery_update_configuration(hass, aioclient_mock): ) await hass.async_block_till_done() - assert result["type"] == RESULT_TYPE_ABORT + assert result["type"] == FlowResultType.ABORT assert result["reason"] == "already_configured" assert config_entry.data[CONF_HOST] == "2.3.4.5" assert config_entry.data[CONF_PORT] == 8080 @@ -628,7 +624,7 @@ async def test_hassio_discovery_dont_update_configuration(hass, aioclient_mock): context={"source": SOURCE_HASSIO}, ) - assert result["type"] == RESULT_TYPE_ABORT + assert result["type"] == FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -638,7 +634,7 @@ async def test_option_flow(hass, aioclient_mock): result = await hass.config_entries.options.async_init(config_entry.entry_id) - assert result["type"] == RESULT_TYPE_FORM + assert result["type"] == FlowResultType.FORM assert result["step_id"] == "deconz_devices" result = await hass.config_entries.options.async_configure( @@ -650,7 +646,7 @@ async def test_option_flow(hass, aioclient_mock): }, ) - assert result["type"] == RESULT_TYPE_CREATE_ENTRY + assert result["type"] == FlowResultType.CREATE_ENTRY assert result["data"] == { CONF_ALLOW_CLIP_SENSOR: False, CONF_ALLOW_DECONZ_GROUPS: False,