mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Search/replace RESULT_TYPE_* by FlowResultType enum (#74656)
This commit is contained in:
@@ -8,11 +8,7 @@ from pycfdns.exceptions import (
|
||||
from homeassistant.components.cloudflare.const import CONF_RECORDS, DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||
from homeassistant.const import CONF_API_TOKEN, CONF_SOURCE, CONF_ZONE
|
||||
from homeassistant.data_entry_flow import (
|
||||
RESULT_TYPE_ABORT,
|
||||
RESULT_TYPE_CREATE_ENTRY,
|
||||
RESULT_TYPE_FORM,
|
||||
)
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from . import (
|
||||
ENTRY_CONFIG,
|
||||
@@ -31,7 +27,7 @@ async def test_user_form(hass, cfupdate_flow):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={CONF_SOURCE: SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -41,7 +37,7 @@ async def test_user_form(hass, cfupdate_flow):
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["step_id"] == "zone"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -51,7 +47,7 @@ async def test_user_form(hass, cfupdate_flow):
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["step_id"] == "records"
|
||||
assert result["errors"] is None
|
||||
|
||||
@@ -62,7 +58,7 @@ async def test_user_form(hass, cfupdate_flow):
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == USER_INPUT_ZONE[CONF_ZONE]
|
||||
|
||||
assert result["data"]
|
||||
@@ -90,7 +86,7 @@ async def test_user_form_cannot_connect(hass, cfupdate_flow):
|
||||
USER_INPUT,
|
||||
)
|
||||
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -108,7 +104,7 @@ async def test_user_form_invalid_auth(hass, cfupdate_flow):
|
||||
USER_INPUT,
|
||||
)
|
||||
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -126,7 +122,7 @@ async def test_user_form_invalid_zone(hass, cfupdate_flow):
|
||||
USER_INPUT,
|
||||
)
|
||||
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "invalid_zone"}
|
||||
|
||||
|
||||
@@ -144,7 +140,7 @@ async def test_user_form_unexpected_exception(hass, cfupdate_flow):
|
||||
USER_INPUT,
|
||||
)
|
||||
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@@ -158,7 +154,7 @@ async def test_user_form_single_instance_allowed(hass):
|
||||
context={CONF_SOURCE: SOURCE_USER},
|
||||
data=USER_INPUT,
|
||||
)
|
||||
assert result["type"] == RESULT_TYPE_ABORT
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
@@ -176,7 +172,7 @@ async def test_reauth_flow(hass, cfupdate_flow):
|
||||
},
|
||||
data=entry.data,
|
||||
)
|
||||
assert result["type"] == RESULT_TYPE_FORM
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
with _patch_async_setup_entry() as mock_setup_entry:
|
||||
@@ -186,7 +182,7 @@ async def test_reauth_flow(hass, cfupdate_flow):
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == RESULT_TYPE_ABORT
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
|
||||
assert entry.data[CONF_API_TOKEN] == "other_token"
|
||||
|
||||
Reference in New Issue
Block a user