mirror of
https://github.com/home-assistant/core.git
synced 2025-08-06 14:15:12 +02:00
Use FlowResultType enum in Plugwise tests (#74638)
This commit is contained in:
@@ -21,11 +21,7 @@ from homeassistant.const import (
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import (
|
||||
RESULT_TYPE_ABORT,
|
||||
RESULT_TYPE_CREATE_ENTRY,
|
||||
RESULT_TYPE_FORM,
|
||||
)
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -88,7 +84,7 @@ async def test_form(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={CONF_SOURCE: SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == RESULT_TYPE_FORM
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("errors") == {}
|
||||
assert result.get("step_id") == "user"
|
||||
assert "flow_id" in result
|
||||
@@ -102,7 +98,7 @@ async def test_form(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2.get("type") == RESULT_TYPE_CREATE_ENTRY
|
||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result2.get("title") == "Test Smile Name"
|
||||
assert result2.get("data") == {
|
||||
CONF_HOST: TEST_HOST,
|
||||
@@ -136,7 +132,7 @@ async def test_zeroconf_flow(
|
||||
context={CONF_SOURCE: SOURCE_ZEROCONF},
|
||||
data=discovery,
|
||||
)
|
||||
assert result.get("type") == RESULT_TYPE_FORM
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("errors") == {}
|
||||
assert result.get("step_id") == "user"
|
||||
assert "flow_id" in result
|
||||
@@ -147,7 +143,7 @@ async def test_zeroconf_flow(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2.get("type") == RESULT_TYPE_CREATE_ENTRY
|
||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result2.get("title") == "Test Smile Name"
|
||||
assert result2.get("data") == {
|
||||
CONF_HOST: TEST_HOST,
|
||||
@@ -172,7 +168,7 @@ async def test_zeroconf_flow_stretch(
|
||||
context={CONF_SOURCE: SOURCE_ZEROCONF},
|
||||
data=TEST_DISCOVERY2,
|
||||
)
|
||||
assert result.get("type") == RESULT_TYPE_FORM
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("errors") == {}
|
||||
assert result.get("step_id") == "user"
|
||||
assert "flow_id" in result
|
||||
@@ -183,7 +179,7 @@ async def test_zeroconf_flow_stretch(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2.get("type") == RESULT_TYPE_CREATE_ENTRY
|
||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result2.get("title") == "Test Smile Name"
|
||||
assert result2.get("data") == {
|
||||
CONF_HOST: TEST_HOST,
|
||||
@@ -224,7 +220,7 @@ async def test_zercoconf_discovery_update_configuration(
|
||||
context={CONF_SOURCE: SOURCE_ZEROCONF},
|
||||
data=TEST_DISCOVERY,
|
||||
)
|
||||
assert result.get("type") == RESULT_TYPE_ABORT
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
assert entry.data[CONF_HOST] == "0.0.0.0"
|
||||
|
||||
@@ -235,7 +231,7 @@ async def test_zercoconf_discovery_update_configuration(
|
||||
data=TEST_DISCOVERY,
|
||||
)
|
||||
|
||||
assert result.get("type") == RESULT_TYPE_ABORT
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
assert entry.data[CONF_HOST] == "1.1.1.1"
|
||||
|
||||
@@ -262,7 +258,7 @@ async def test_flow_errors(
|
||||
DOMAIN,
|
||||
context={CONF_SOURCE: SOURCE_USER},
|
||||
)
|
||||
assert result.get("type") == RESULT_TYPE_FORM
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("errors") == {}
|
||||
assert result.get("step_id") == "user"
|
||||
assert "flow_id" in result
|
||||
@@ -273,7 +269,7 @@ async def test_flow_errors(
|
||||
user_input={CONF_HOST: TEST_HOST, CONF_PASSWORD: TEST_PASSWORD},
|
||||
)
|
||||
|
||||
assert result2.get("type") == RESULT_TYPE_FORM
|
||||
assert result2.get("type") == FlowResultType.FORM
|
||||
assert result2.get("errors") == {"base": reason}
|
||||
assert result2.get("step_id") == "user"
|
||||
|
||||
@@ -286,7 +282,7 @@ async def test_flow_errors(
|
||||
user_input={CONF_HOST: TEST_HOST, CONF_PASSWORD: TEST_PASSWORD},
|
||||
)
|
||||
|
||||
assert result3.get("type") == RESULT_TYPE_CREATE_ENTRY
|
||||
assert result3.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result3.get("title") == "Test Smile Name"
|
||||
assert result3.get("data") == {
|
||||
CONF_HOST: TEST_HOST,
|
||||
|
Reference in New Issue
Block a user