Use is in enum comparison in config flow tests P-T (#114675)
This commit is contained in:
parent
5d500cb74b
commit
ee66f6ec8c
164 changed files with 1919 additions and 1890 deletions
|
@ -4,11 +4,12 @@ from unittest.mock import patch
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.solarlog import config_flow
|
||||
from homeassistant.components.solarlog.const import DEFAULT_HOST, DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -68,12 +69,12 @@ async def test_user(hass: HomeAssistant, test_connect) -> None:
|
|||
flow = init_config_flow(hass)
|
||||
|
||||
result = await flow.async_step_user()
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
# tets with all provided
|
||||
result = await flow.async_step_user({CONF_NAME: NAME, CONF_HOST: HOST})
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "solarlog_test_1_2_3"
|
||||
assert result["data"][CONF_HOST] == HOST
|
||||
|
||||
|
@ -84,19 +85,19 @@ async def test_import(hass: HomeAssistant, test_connect) -> None:
|
|||
|
||||
# import with only host
|
||||
result = await flow.async_step_import({CONF_HOST: HOST})
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "solarlog"
|
||||
assert result["data"][CONF_HOST] == HOST
|
||||
|
||||
# import with only name
|
||||
result = await flow.async_step_import({CONF_NAME: NAME})
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "solarlog_test_1_2_3"
|
||||
assert result["data"][CONF_HOST] == DEFAULT_HOST
|
||||
|
||||
# import with host and name
|
||||
result = await flow.async_step_import({CONF_HOST: HOST, CONF_NAME: NAME})
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "solarlog_test_1_2_3"
|
||||
assert result["data"][CONF_HOST] == HOST
|
||||
|
||||
|
@ -112,19 +113,19 @@ async def test_abort_if_already_setup(hass: HomeAssistant, test_connect) -> None
|
|||
result = await flow.async_step_import(
|
||||
{CONF_HOST: HOST, CONF_NAME: "solarlog_test_7_8_9"}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
# Should fail, same HOST and NAME
|
||||
result = await flow.async_step_user({CONF_HOST: HOST, CONF_NAME: NAME})
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {CONF_HOST: "already_configured"}
|
||||
|
||||
# SHOULD pass, diff HOST (without http://), different NAME
|
||||
result = await flow.async_step_import(
|
||||
{CONF_HOST: "2.2.2.2", CONF_NAME: "solarlog_test_7_8_9"}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "solarlog_test_7_8_9"
|
||||
assert result["data"][CONF_HOST] == "http://2.2.2.2"
|
||||
|
||||
|
@ -132,6 +133,6 @@ async def test_abort_if_already_setup(hass: HomeAssistant, test_connect) -> None
|
|||
result = await flow.async_step_import(
|
||||
{CONF_HOST: "http://2.2.2.2", CONF_NAME: NAME}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "solarlog_test_1_2_3"
|
||||
assert result["data"][CONF_HOST] == "http://2.2.2.2"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue