mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Use is in enum comparison in config flow tests A-E (#114669)
This commit is contained in:
committed by
GitHub
parent
ee66f6ec8c
commit
9b41e3d124
@@ -4,10 +4,11 @@ from unittest.mock import patch
|
||||
|
||||
from pydexcom import AccountError, SessionError
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.dexcom.const import DOMAIN, MG_DL, MMOL_L
|
||||
from homeassistant.const import CONF_UNIT_OF_MEASUREMENT, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from . import CONFIG
|
||||
|
||||
@@ -20,7 +21,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -39,7 +40,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == CONFIG[CONF_USERNAME]
|
||||
assert result2["data"] == CONFIG
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -60,7 +61,7 @@ async def test_form_account_error(hass: HomeAssistant) -> None:
|
||||
CONFIG,
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -79,7 +80,7 @@ async def test_form_session_error(hass: HomeAssistant) -> None:
|
||||
CONFIG,
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -98,7 +99,7 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
|
||||
CONFIG,
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@@ -113,14 +114,14 @@ async def test_option_flow_default(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
result2 = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={},
|
||||
)
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == {
|
||||
CONF_UNIT_OF_MEASUREMENT: MG_DL,
|
||||
}
|
||||
@@ -137,14 +138,14 @@ async def test_option_flow(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={CONF_UNIT_OF_MEASUREMENT: MMOL_L},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
CONF_UNIT_OF_MEASUREMENT: MMOL_L,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user