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
|
@ -5,11 +5,11 @@ from unittest.mock import Mock, patch
|
|||
import pytest
|
||||
from requests.exceptions import ConnectTimeout, HTTPError
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.solaredge.const import CONF_SITE_ID, DEFAULT_NAME, DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IGNORE, SOURCE_USER
|
||||
from homeassistant.const import CONF_API_KEY, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
@ -32,7 +32,7 @@ async def test_user(hass: HomeAssistant, test_api: Mock) -> None:
|
|||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "user"
|
||||
|
||||
# test with all provided
|
||||
|
@ -41,7 +41,7 @@ async def test_user(hass: HomeAssistant, test_api: Mock) -> None:
|
|||
context={"source": SOURCE_USER},
|
||||
data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID},
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result.get("title") == "solaredge_site_1_2_3"
|
||||
|
||||
data = result.get("data")
|
||||
|
@ -63,7 +63,7 @@ async def test_abort_if_already_setup(hass: HomeAssistant, test_api: str) -> Non
|
|||
context={"source": SOURCE_USER},
|
||||
data={CONF_NAME: "test", CONF_SITE_ID: SITE_ID, CONF_API_KEY: "test"},
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {CONF_SITE_ID: "already_configured"}
|
||||
|
||||
|
||||
|
@ -83,7 +83,7 @@ async def test_ignored_entry_does_not_cause_error(
|
|||
context={"source": SOURCE_USER},
|
||||
data={CONF_NAME: "test", CONF_SITE_ID: SITE_ID, CONF_API_KEY: "test"},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "test"
|
||||
|
||||
data = result["data"]
|
||||
|
@ -103,7 +103,7 @@ async def test_asserts(hass: HomeAssistant, test_api: Mock) -> None:
|
|||
context={"source": SOURCE_USER},
|
||||
data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID},
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {CONF_SITE_ID: "site_not_active"}
|
||||
|
||||
# test with api_failure
|
||||
|
@ -113,7 +113,7 @@ async def test_asserts(hass: HomeAssistant, test_api: Mock) -> None:
|
|||
context={"source": SOURCE_USER},
|
||||
data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID},
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {CONF_SITE_ID: "invalid_api_key"}
|
||||
|
||||
# test with ConnectionTimeout
|
||||
|
@ -123,7 +123,7 @@ async def test_asserts(hass: HomeAssistant, test_api: Mock) -> None:
|
|||
context={"source": SOURCE_USER},
|
||||
data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID},
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {CONF_SITE_ID: "could_not_connect"}
|
||||
|
||||
# test with HTTPError
|
||||
|
@ -133,5 +133,5 @@ async def test_asserts(hass: HomeAssistant, test_api: Mock) -> None:
|
|||
context={"source": SOURCE_USER},
|
||||
data={CONF_NAME: NAME, CONF_API_KEY: API_KEY, CONF_SITE_ID: SITE_ID},
|
||||
)
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {CONF_SITE_ID: "could_not_connect"}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue