mirror of
https://github.com/home-assistant/core.git
synced 2025-11-12 20:40:18 +00:00
Use is in enum comparison in config flow tests P-T (#114675)
This commit is contained in:
committed by
GitHub
parent
5d500cb74b
commit
ee66f6ec8c
@@ -5,9 +5,9 @@ from unittest.mock import patch
|
||||
from api.soma_api import SomaApi
|
||||
from requests import RequestException
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.soma import DOMAIN, config_flow
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -20,7 +20,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
flow = config_flow.SomaFlowHandler()
|
||||
flow.hass = hass
|
||||
result = await flow.async_step_user()
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
|
||||
async def test_import_abort(hass: HomeAssistant) -> None:
|
||||
@@ -29,7 +29,7 @@ async def test_import_abort(hass: HomeAssistant) -> None:
|
||||
flow.hass = hass
|
||||
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
|
||||
result = await flow.async_step_import()
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_setup"
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ async def test_import_create(hass: HomeAssistant) -> None:
|
||||
flow.hass = hass
|
||||
with patch.object(SomaApi, "list_devices", return_value={"result": "success"}):
|
||||
result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT})
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_error_status(hass: HomeAssistant) -> None:
|
||||
@@ -48,7 +48,7 @@ async def test_error_status(hass: HomeAssistant) -> None:
|
||||
flow.hass = hass
|
||||
with patch.object(SomaApi, "list_devices", return_value={"result": "error"}):
|
||||
result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT})
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "result_error"
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ async def test_key_error(hass: HomeAssistant) -> None:
|
||||
flow.hass = hass
|
||||
with patch.object(SomaApi, "list_devices", return_value={}):
|
||||
result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT})
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "connection_error"
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ async def test_exception(hass: HomeAssistant) -> None:
|
||||
flow.hass = hass
|
||||
with patch.object(SomaApi, "list_devices", side_effect=RequestException()):
|
||||
result = await flow.async_step_import({"host": MOCK_HOST, "port": MOCK_PORT})
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "connection_error"
|
||||
|
||||
|
||||
@@ -79,4 +79,4 @@ async def test_full_flow(hass: HomeAssistant) -> None:
|
||||
flow.hass = hass
|
||||
with patch.object(SomaApi, "list_devices", return_value={"result": "success"}):
|
||||
result = await flow.async_step_user({"host": MOCK_HOST, "port": MOCK_PORT})
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
Reference in New Issue
Block a user