Use is in enum comparison in config flow tests F-J (#114670)

* Use right enum expression F-J

* Fix
This commit is contained in:
Joost Lekkerkerker 2024-04-02 23:01:37 +02:00 committed by GitHub
parent ea2bb24484
commit 906d3198e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
93 changed files with 1240 additions and 1220 deletions

View file

@ -10,7 +10,6 @@ from fritzconnection.core.exceptions import (
)
import pytest
from homeassistant import data_entry_flow
from homeassistant.components.device_tracker import (
CONF_CONSIDER_HOME,
DEFAULT_CONSIDER_HOME,
@ -71,13 +70,13 @@ async def test_user(hass: HomeAssistant, fc_class_mock, mock_get_source_ip) -> N
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_USER_DATA
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_HOST] == "fake_host"
assert result["data"][CONF_PASSWORD] == "fake_pass"
assert result["data"][CONF_USERNAME] == "fake_user"
@ -127,13 +126,13 @@ async def test_user_already_configured(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_USER_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"]["base"] == "already_configured"
@ -150,7 +149,7 @@ async def test_exception_security(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with patch(
@ -161,7 +160,7 @@ async def test_exception_security(
result["flow_id"], user_input=MOCK_USER_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"]["base"] == ERROR_AUTH_INVALID
@ -172,7 +171,7 @@ async def test_exception_connection(hass: HomeAssistant, mock_get_source_ip) ->
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with patch(
@ -183,7 +182,7 @@ async def test_exception_connection(hass: HomeAssistant, mock_get_source_ip) ->
result["flow_id"], user_input=MOCK_USER_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"]["base"] == ERROR_CANNOT_CONNECT
@ -194,7 +193,7 @@ async def test_exception_unknown(hass: HomeAssistant, mock_get_source_ip) -> Non
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with patch(
@ -205,7 +204,7 @@ async def test_exception_unknown(hass: HomeAssistant, mock_get_source_ip) -> Non
result["flow_id"], user_input=MOCK_USER_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"]["base"] == ERROR_UNKNOWN
@ -248,7 +247,7 @@ async def test_reauth_successful(
data=mock_config.data,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
result = await hass.config_entries.flow.async_configure(
@ -259,7 +258,7 @@ async def test_reauth_successful(
},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
assert mock_setup_entry.called
@ -291,7 +290,7 @@ async def test_reauth_not_successful(
data=mock_config.data,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
result = await hass.config_entries.flow.async_configure(
@ -302,7 +301,7 @@ async def test_reauth_not_successful(
},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
assert result["errors"]["base"] == error
@ -332,7 +331,7 @@ async def test_ssdp_already_configured(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_SSDP}, data=MOCK_SSDP_DATA
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -361,7 +360,7 @@ async def test_ssdp_already_configured_host(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_SSDP}, data=MOCK_SSDP_DATA
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -390,7 +389,7 @@ async def test_ssdp_already_configured_host_uuid(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_SSDP}, data=MOCK_SSDP_DATA
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -405,7 +404,7 @@ async def test_ssdp_already_in_progress_host(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_SSDP}, data=MOCK_SSDP_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
MOCK_NO_UNIQUE_ID = dataclasses.replace(MOCK_SSDP_DATA)
@ -414,7 +413,7 @@ async def test_ssdp_already_in_progress_host(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_SSDP}, data=MOCK_NO_UNIQUE_ID
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress"
@ -441,7 +440,7 @@ async def test_ssdp(hass: HomeAssistant, fc_class_mock, mock_get_source_ip) -> N
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_SSDP}, data=MOCK_SSDP_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure(
@ -452,7 +451,7 @@ async def test_ssdp(hass: HomeAssistant, fc_class_mock, mock_get_source_ip) -> N
},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_HOST] == MOCK_IPS["fritz.box"]
assert result["data"][CONF_PASSWORD] == "fake_pass"
assert result["data"][CONF_USERNAME] == "fake_user"
@ -469,7 +468,7 @@ async def test_ssdp_exception(hass: HomeAssistant, mock_get_source_ip) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_SSDP}, data=MOCK_SSDP_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure(
@ -480,7 +479,7 @@ async def test_ssdp_exception(hass: HomeAssistant, mock_get_source_ip) -> None:
},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
@ -500,7 +499,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
CONF_OLD_DISCOVERY: False,
CONF_CONSIDER_HOME: 37,