Use is in enum comparison in config flow tests P-T (#114675)

This commit is contained in:
Joost Lekkerkerker
2024-04-02 23:21:50 +02:00
committed by GitHub
parent 5d500cb74b
commit ee66f6ec8c
164 changed files with 1919 additions and 1890 deletions

View File

@@ -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