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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
164 changed files with 1919 additions and 1890 deletions

View file

@ -8,7 +8,7 @@ from unittest.mock import AsyncMock, MagicMock, call
import pytest
from reolink_aio.exceptions import ApiError, CredentialsInvalidError, ReolinkError
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components import dhcp
from homeassistant.components.reolink import DEVICE_UPDATE_INTERVAL, const
from homeassistant.components.reolink.config_flow import DEFAULT_PROTOCOL
@ -23,6 +23,7 @@ from homeassistant.const import (
CONF_USERNAME,
)
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers.device_registry import format_mac
from homeassistant.util.dt import utcnow
@ -53,7 +54,7 @@ async def test_config_flow_manual_success(
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -66,7 +67,7 @@ async def test_config_flow_manual_success(
},
)
assert result["type"] is data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_NVR_NAME
assert result["data"] == {
CONF_HOST: TEST_HOST,
@ -88,7 +89,7 @@ async def test_config_flow_errors(
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -103,7 +104,7 @@ async def test_config_flow_errors(
},
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {CONF_USERNAME: "not_admin"}
@ -119,7 +120,7 @@ async def test_config_flow_errors(
},
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {CONF_HOST: "cannot_connect"}
@ -133,7 +134,7 @@ async def test_config_flow_errors(
},
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "webhook_exception"}
@ -149,7 +150,7 @@ async def test_config_flow_errors(
},
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {CONF_HOST: "unknown"}
@ -163,7 +164,7 @@ async def test_config_flow_errors(
},
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {CONF_HOST: "invalid_auth"}
@ -177,7 +178,7 @@ async def test_config_flow_errors(
},
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {CONF_HOST: "api_error"}
@ -193,7 +194,7 @@ async def test_config_flow_errors(
},
)
assert result["type"] is data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_NVR_NAME
assert result["data"] == {
CONF_HOST: TEST_HOST,
@ -231,7 +232,7 @@ async def test_options_flow(hass: HomeAssistant, mock_setup_entry: MagicMock) ->
result = await hass.config_entries.options.async_init(config_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(
@ -239,7 +240,7 @@ async def test_options_flow(hass: HomeAssistant, mock_setup_entry: MagicMock) ->
user_input={CONF_PROTOCOL: "rtmp"},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {
CONF_PROTOCOL: "rtmp",
}
@ -270,7 +271,7 @@ async def test_change_connection_settings(
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] is data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -283,7 +284,7 @@ async def test_change_connection_settings(
},
)
assert result["type"] is data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry.data[CONF_HOST] == TEST_HOST2
assert config_entry.data[CONF_USERNAME] == TEST_USERNAME2
@ -323,7 +324,7 @@ async def test_reauth(hass: HomeAssistant, mock_setup_entry: MagicMock) -> None:
data=config_entry.data,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
result = await hass.config_entries.flow.async_configure(
@ -331,7 +332,7 @@ async def test_reauth(hass: HomeAssistant, mock_setup_entry: MagicMock) -> None:
{},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -343,7 +344,7 @@ async def test_reauth(hass: HomeAssistant, mock_setup_entry: MagicMock) -> None:
},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
assert config_entry.data[CONF_HOST] == TEST_HOST
assert config_entry.data[CONF_USERNAME] == TEST_USERNAME2
@ -362,7 +363,7 @@ async def test_dhcp_flow(hass: HomeAssistant, mock_setup_entry: MagicMock) -> No
const.DOMAIN, context={"source": config_entries.SOURCE_DHCP}, data=dhcp_data
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -374,7 +375,7 @@ async def test_dhcp_flow(hass: HomeAssistant, mock_setup_entry: MagicMock) -> No
},
)
assert result["type"] is data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == TEST_NVR_NAME
assert result["data"] == {
CONF_HOST: TEST_HOST,
@ -489,7 +490,7 @@ async def test_dhcp_ip_update(
assert reolink_connect_class.call_args_list == expected_calls
assert result["type"] is data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
await hass.async_block_till_done()