Use is in enum comparison in config flow tests A-E (#114669)

This commit is contained in:
Joost Lekkerkerker 2024-04-02 23:22:05 +02:00 committed by GitHub
parent ee66f6ec8c
commit 9b41e3d124
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
123 changed files with 1413 additions and 1387 deletions

View File

@ -10,12 +10,12 @@ from jaraco.abode.helpers.errors import MFA_CODE_REQUIRED
import pytest
from requests.exceptions import ConnectTimeout
from homeassistant import data_entry_flow
from homeassistant.components.abode import config_flow
from homeassistant.components.abode.const import CONF_POLLING, DOMAIN
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@ -29,7 +29,7 @@ async def test_show_form(hass: HomeAssistant) -> None:
result = await flow.async_step_user(user_input=None)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
@ -45,7 +45,7 @@ async def test_one_config_allowed(hass: HomeAssistant) -> None:
step_user_result = await flow.async_step_user()
assert step_user_result["type"] == data_entry_flow.FlowResultType.ABORT
assert step_user_result["type"] is FlowResultType.ABORT
assert step_user_result["reason"] == "single_instance_allowed"
@ -107,7 +107,7 @@ async def test_step_user(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}, data=conf
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "user@email.com"
assert result["data"] == {
CONF_USERNAME: "user@email.com",
@ -128,7 +128,7 @@ async def test_step_mfa(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}, data=conf
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "mfa"
with patch(
@ -148,7 +148,7 @@ async def test_step_mfa(hass: HomeAssistant) -> None:
result["flow_id"], user_input={"mfa_code": "123456"}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "user@email.com"
assert result["data"] == {
CONF_USERNAME: "user@email.com",
@ -174,7 +174,7 @@ async def test_step_reauth(hass: HomeAssistant) -> None:
data=conf,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
with patch("homeassistant.config_entries.ConfigEntries.async_reload"):
@ -183,7 +183,7 @@ async def test_step_reauth(hass: HomeAssistant) -> None:
user_input=conf,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
assert len(hass.config_entries.async_entries()) == 1

View File

@ -4,11 +4,11 @@ from unittest.mock import PropertyMock, patch
from accuweather import ApiError, InvalidApiKeyError, RequestsExceededError
from homeassistant import data_entry_flow
from homeassistant.components.accuweather.const import CONF_FORECAST, DOMAIN
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry, load_json_object_fixture
@ -26,7 +26,7 @@ async def test_show_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
@ -134,7 +134,7 @@ async def test_create_entry(hass: HomeAssistant) -> None:
data=VALID_CONFIG,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "abcd"
assert result["data"][CONF_NAME] == "abcd"
assert result["data"][CONF_LATITUDE] == 55.55
@ -176,14 +176,14 @@ async def test_options_flow(hass: HomeAssistant) -> None:
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(
result["flow_id"], user_input={CONF_FORECAST: True}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {CONF_FORECAST: True}
await hass.async_block_till_done()

View File

@ -5,11 +5,11 @@ from unittest.mock import patch
import aiopulse
import pytest
from homeassistant import data_entry_flow
from homeassistant.components.acmeda.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@ -49,7 +49,7 @@ async def test_show_form_no_hubs(hass: HomeAssistant, mock_hub_discover) -> None
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
# Check we performed the discovery
@ -70,7 +70,7 @@ async def test_show_form_one_hub(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == dummy_hub_1.id
assert result["result"].data == {
CONF_HOST: DUMMY_HOST1,
@ -95,7 +95,7 @@ async def test_show_form_two_hubs(hass: HomeAssistant, mock_hub_discover) -> Non
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
# Check we performed the discovery
@ -123,7 +123,7 @@ async def test_create_second_entry(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == dummy_hub_2.id
assert result["result"].data == {
CONF_HOST: DUMMY_HOST2,

View File

@ -31,7 +31,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"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure(
@ -40,7 +40,7 @@ async def test_form(hass: HomeAssistant) -> None:
CONNECTION_TYPE: CLOUD,
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
with (
patch(
@ -80,7 +80,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
CONNECTION_TYPE: CLOUD,
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
with patch(
"adax.get_adax_token",
@ -90,7 +90,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
result2["flow_id"],
TEST_DATA,
)
assert result3["type"] == FlowResultType.FORM
assert result3["type"] is FlowResultType.FORM
assert result3["errors"] == {"base": "cannot_connect"}
@ -115,7 +115,7 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
CONNECTION_TYPE: CLOUD,
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
with patch("adax.get_adax_token", return_value="token"):
result3 = await hass.config_entries.flow.async_configure(
@ -136,7 +136,7 @@ async def test_local_create_entry(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure(
@ -145,7 +145,7 @@ async def test_local_create_entry(hass: HomeAssistant) -> None:
CONNECTION_TYPE: LOCAL,
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
test_data = {
WIFI_SSID: "ssid",
@ -201,7 +201,7 @@ async def test_local_flow_entry_already_exists(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure(
@ -210,7 +210,7 @@ async def test_local_flow_entry_already_exists(hass: HomeAssistant) -> None:
CONNECTION_TYPE: LOCAL,
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
test_data = {
WIFI_SSID: "ssid",
@ -239,7 +239,7 @@ async def test_local_connection_error(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure(
@ -248,7 +248,7 @@ async def test_local_connection_error(hass: HomeAssistant) -> None:
CONNECTION_TYPE: LOCAL,
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
test_data = {
WIFI_SSID: "ssid",
@ -264,7 +264,7 @@ async def test_local_connection_error(hass: HomeAssistant) -> None:
test_data,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"}
@ -274,7 +274,7 @@ async def test_local_heater_not_available(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure(
@ -283,7 +283,7 @@ async def test_local_heater_not_available(hass: HomeAssistant) -> None:
CONNECTION_TYPE: LOCAL,
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
test_data = {
WIFI_SSID: "ssid",
@ -299,7 +299,7 @@ async def test_local_heater_not_available(hass: HomeAssistant) -> None:
test_data,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "heater_not_available"
@ -309,7 +309,7 @@ async def test_local_heater_not_found(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure(
@ -318,7 +318,7 @@ async def test_local_heater_not_found(hass: HomeAssistant) -> None:
CONNECTION_TYPE: LOCAL,
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
test_data = {
WIFI_SSID: "ssid",
@ -334,7 +334,7 @@ async def test_local_heater_not_found(hass: HomeAssistant) -> None:
test_data,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "heater_not_found"
@ -344,7 +344,7 @@ async def test_local_invalid_wifi_cred(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure(
@ -353,7 +353,7 @@ async def test_local_invalid_wifi_cred(hass: HomeAssistant) -> None:
CONNECTION_TYPE: LOCAL,
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
test_data = {
WIFI_SSID: "ssid",
@ -369,5 +369,5 @@ async def test_local_invalid_wifi_cred(hass: HomeAssistant) -> None:
test_data,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_auth"

View File

@ -2,7 +2,7 @@
import aiohttp
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.adguard.const import DOMAIN
from homeassistant.components.hassio import HassioServiceInfo
from homeassistant.config_entries import SOURCE_USER
@ -16,6 +16,7 @@ from homeassistant.const import (
CONTENT_TYPE_JSON,
)
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
from tests.test_util.aiohttp import AiohttpClientMocker
@ -36,7 +37,7 @@ async def test_show_authenticate_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
@ -58,7 +59,7 @@ async def test_connection_error(
)
assert result
assert result.get("type") == data_entry_flow.FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
assert result.get("errors") == {"base": "cannot_connect"}
@ -83,14 +84,14 @@ async def test_full_flow_implementation(
assert result
assert result.get("flow_id")
assert result.get("type") == data_entry_flow.FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=FIXTURE_USER_INPUT
)
assert result2
assert result2.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == FIXTURE_USER_INPUT[CONF_HOST]
data = result2.get("data")
@ -140,7 +141,7 @@ async def test_hassio_already_configured(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_HASSIO},
)
assert result
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured"
@ -165,7 +166,7 @@ async def test_hassio_ignored(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_HASSIO},
)
assert result
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured"
@ -194,14 +195,14 @@ async def test_hassio_confirm(
context={"source": config_entries.SOURCE_HASSIO},
)
assert result
assert result.get("type") == data_entry_flow.FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "hassio_confirm"
assert result.get("description_placeholders") == {"addon": "AdGuard Home Addon"}
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result2
assert result2.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == "AdGuard Home Addon"
data = result2.get("data")
@ -240,6 +241,6 @@ async def test_hassio_connection_error(
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result
assert result.get("type") == data_entry_flow.FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "hassio_confirm"
assert result.get("errors") == {"base": "cannot_connect"}

View File

@ -4,9 +4,10 @@ from unittest.mock import AsyncMock, patch
from advantage_air import ApiError
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.advantage_air.const import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import TEST_SYSTEM_DATA, USER_INPUT
@ -17,7 +18,7 @@ async def test_form(hass: HomeAssistant) -> None:
result1 = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result1["type"] == data_entry_flow.FlowResultType.FORM
assert result1["type"] is FlowResultType.FORM
assert result1["step_id"] == "user"
assert result1["errors"] == {}
@ -39,7 +40,7 @@ async def test_form(hass: HomeAssistant) -> None:
mock_setup_entry.assert_called_once()
mock_get.assert_called_once()
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "testname"
assert result2["data"] == USER_INPUT
@ -55,7 +56,7 @@ async def test_form(hass: HomeAssistant) -> None:
result3["flow_id"],
USER_INPUT,
)
assert result4["type"] == data_entry_flow.FlowResultType.ABORT
assert result4["type"] is FlowResultType.ABORT
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
@ -74,6 +75,6 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
)
mock_get.assert_called_once()
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "user"
assert result2["errors"] == {"base": "cannot_connect"}

View File

@ -6,11 +6,11 @@ from aemet_opendata.exceptions import AuthError
from freezegun.api import FrozenDateTimeFactory
import pytest
from homeassistant import data_entry_flow
from homeassistant.components.aemet.const import CONF_STATION_UPDATES, DOMAIN
from homeassistant.config_entries import SOURCE_USER, ConfigEntryState
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .util import mock_api_call
@ -37,7 +37,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -51,7 +51,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
entry = conf_entries[0]
assert entry.state is ConfigEntryState.LOADED
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == CONFIG[CONF_NAME]
assert result["data"][CONF_LATITUDE] == CONFIG[CONF_LATITUDE]
assert result["data"][CONF_LONGITUDE] == CONFIG[CONF_LONGITUDE]
@ -89,14 +89,14 @@ async def test_form_options(
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=user_input
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert entry.options == {
CONF_STATION_UPDATES: expected,
}

View File

@ -29,7 +29,7 @@ async def test_full_user_flow(hass: HomeAssistant, mock_setup_entry) -> None:
CONF_API_KEY: "mock-api-key",
},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "AfterShip"
assert result["data"] == {
CONF_API_KEY: "mock-api-key",
@ -54,7 +54,7 @@ async def test_flow_cannot_connect(hass: HomeAssistant, mock_setup_entry) -> Non
CONF_API_KEY: "mock-api-key",
},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with patch(
@ -68,7 +68,7 @@ async def test_flow_cannot_connect(hass: HomeAssistant, mock_setup_entry) -> Non
CONF_API_KEY: "mock-api-key",
},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "AfterShip"
assert result["data"] == {
CONF_API_KEY: "mock-api-key",

View File

@ -2,12 +2,12 @@
import pytest
from homeassistant import data_entry_flow
from homeassistant.components.agent_dvr import config_flow
from homeassistant.components.agent_dvr.const import SERVER_URL
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_HOST, CONF_PORT, CONTENT_TYPE_JSON
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import init_integration
@ -25,7 +25,7 @@ async def test_show_user_form(hass: HomeAssistant) -> None:
)
assert result["step_id"] == "user"
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
async def test_user_device_exists_abort(
@ -40,7 +40,7 @@ async def test_user_device_exists_abort(
data={CONF_HOST: "example.local", CONF_PORT: 8090},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
async def test_connection_error(
@ -58,7 +58,7 @@ async def test_connection_error(
assert result["errors"]["base"] == "cannot_connect"
assert result["step_id"] == "user"
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
async def test_full_user_flow_implementation(
@ -83,7 +83,7 @@ async def test_full_user_flow_implementation(
)
assert result["step_id"] == "user"
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: "example.local", CONF_PORT: 8090}
@ -93,7 +93,7 @@ async def test_full_user_flow_implementation(
assert result["data"][CONF_PORT] == 8090
assert result["data"][SERVER_URL] == "http://example.local:8090/"
assert result["title"] == "DESKTOP"
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
entries = hass.config_entries.async_entries(config_flow.DOMAIN)
assert entries[0].unique_id == "c0715bba-c2d0-48ef-9e3e-bc81c9ea4447"

View File

@ -4,11 +4,11 @@ from http import HTTPStatus
from airly.exceptions import AirlyError
from homeassistant import data_entry_flow
from homeassistant.components.airly.const import CONF_USE_NEAREST, DOMAIN
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import API_NEAREST_URL, API_POINT_URL
@ -29,7 +29,7 @@ async def test_show_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
@ -83,7 +83,7 @@ async def test_invalid_location_for_point_and_nearest(
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "wrong_location"
@ -113,7 +113,7 @@ async def test_create_entry(
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == CONFIG[CONF_NAME]
assert result["data"][CONF_LATITUDE] == CONFIG[CONF_LATITUDE]
assert result["data"][CONF_LONGITUDE] == CONFIG[CONF_LONGITUDE]
@ -137,7 +137,7 @@ async def test_create_entry_with_nearest_method(
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == CONFIG[CONF_NAME]
assert result["data"][CONF_LATITUDE] == CONFIG[CONF_LATITUDE]
assert result["data"][CONF_LONGITUDE] == CONFIG[CONF_LONGITUDE]

View File

@ -5,10 +5,11 @@ from unittest.mock import AsyncMock, patch
from pyairnow.errors import AirNowError, EmptyResponseError, InvalidKeyError
import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.airnow.const import DOMAIN
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@ -18,11 +19,11 @@ async def test_form(hass: HomeAssistant, config, options, setup_airnow) -> 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"] == {}
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], config)
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == config
assert result2["options"] == options
@ -140,7 +141,7 @@ async def test_options_flow(hass: HomeAssistant, setup_airnow) -> None:
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"
with patch(
@ -153,7 +154,7 @@ async def test_options_flow(hass: HomeAssistant, setup_airnow) -> None:
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {
CONF_RADIUS: 25,
}

View File

@ -34,7 +34,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"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
with (
@ -47,7 +47,7 @@ async def test_form(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == TEST_DEVICE_INFO["name"]
assert result2["data"] == TEST_USER_DATA
@ -63,7 +63,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
result["flow_id"], TEST_USER_DATA | {CONF_PASSWORD: "wrong_password"}
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"}
@ -78,7 +78,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
result["flow_id"], TEST_USER_DATA
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"}
@ -101,5 +101,5 @@ async def test_duplicate_error(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], TEST_USER_DATA
)
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured"

View File

@ -24,7 +24,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"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
with (
@ -43,7 +43,7 @@ async def test_form(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Airthings"
assert result2["data"] == TEST_DATA
assert len(mock_setup_entry.mock_calls) == 1
@ -64,7 +64,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
TEST_DATA,
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"}
@ -83,7 +83,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
TEST_DATA,
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"}
@ -102,7 +102,7 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
TEST_DATA,
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"}

View File

@ -43,7 +43,7 @@ async def test_bluetooth_discovery(hass: HomeAssistant) -> None:
data=WAVE_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
assert result["description_placeholders"] == {
"name": "Airthings Wave Plus (123456)"
@ -54,7 +54,7 @@ async def test_bluetooth_discovery(hass: HomeAssistant) -> None:
result["flow_id"], user_input={"not": "empty"}
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Airthings Wave Plus (123456)"
assert result["result"].unique_id == "cc:cc:cc:cc:cc:cc"
@ -67,7 +67,7 @@ async def test_bluetooth_discovery_no_BLEDevice(hass: HomeAssistant) -> None:
context={"source": SOURCE_BLUETOOTH},
data=WAVE_SERVICE_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
@ -87,7 +87,7 @@ async def test_bluetooth_discovery_airthings_ble_update_failed(
data=WAVE_SERVICE_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == reason
@ -103,7 +103,7 @@ async def test_bluetooth_discovery_already_setup(hass: HomeAssistant) -> None:
context={"source": SOURCE_BLUETOOTH},
data=WAVE_DEVICE_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -127,7 +127,7 @@ async def test_user_setup(hass: HomeAssistant) -> None:
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"
assert result["errors"] is None
assert result["data_schema"] is not None
@ -146,7 +146,7 @@ async def test_user_setup(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Airthings Wave Plus (123456)"
assert result["result"].unique_id == "cc:cc:cc:cc:cc:cc"
@ -160,7 +160,7 @@ async def test_user_setup_no_device(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -178,7 +178,7 @@ async def test_user_setup_existing_and_unknown_device(hass: HomeAssistant) -> No
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -196,7 +196,7 @@ async def test_user_setup_unknown_error(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown"
@ -214,7 +214,7 @@ async def test_user_setup_unable_to_connect(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
@ -227,5 +227,5 @@ async def test_unsupported_device(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"

View File

@ -17,7 +17,7 @@ async def test_success(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
host = "1.1.1.1"
@ -34,7 +34,7 @@ async def test_success(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == host
assert result2["data"] == {
"host": host,
@ -59,5 +59,5 @@ async def test_cannot_connect(hass: HomeAssistant) -> None:
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"}

View File

@ -11,7 +11,6 @@ from pyairvisual.cloud_api import (
from pyairvisual.errors import AirVisualError
import pytest
from homeassistant import data_entry_flow
from homeassistant.components.airvisual import (
CONF_CITY,
CONF_INTEGRATION_TYPE,
@ -22,6 +21,7 @@ from homeassistant.components.airvisual import (
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
from homeassistant.const import CONF_API_KEY, CONF_SHOW_ON_MAP
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .conftest import (
COORDS_CONFIG,
@ -81,13 +81,13 @@ async def test_create_entry(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data={"type": integration_type}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == input_form_step
# Test errors that can arise:
@ -95,14 +95,14 @@ async def test_create_entry(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=config
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == errors
# Test that we can recover and finish the flow after errors occur:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=config
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == entry_title
assert result["data"] == {**config, CONF_INTEGRATION_TYPE: integration_type}
@ -112,7 +112,7 @@ async def test_duplicate_error(hass: HomeAssistant, config, setup_config_entry)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_init(
@ -120,13 +120,13 @@ async def test_duplicate_error(hass: HomeAssistant, config, setup_config_entry)
context={"source": SOURCE_USER},
data={"type": INTEGRATION_TYPE_GEOGRAPHY_COORDS},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "geography_by_coords"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=config
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -135,13 +135,13 @@ async def test_options_flow(
) -> None:
"""Test config flow options."""
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(
result["flow_id"], user_input={CONF_SHOW_ON_MAP: False}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {CONF_SHOW_ON_MAP: False}
@ -152,11 +152,11 @@ async def test_step_reauth(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_REAUTH}, 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(result["flow_id"])
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
new_api_key = "defgh67890"
@ -164,7 +164,7 @@ async def test_step_reauth(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_API_KEY: new_api_key}
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
assert len(hass.config_entries.async_entries()) == 1

View File

@ -9,11 +9,11 @@ from pyairvisual.node import (
)
import pytest
from homeassistant import data_entry_flow
from homeassistant.components.airvisual_pro.const import DOMAIN
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_REAUTH, SOURCE_USER
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
@ -34,7 +34,7 @@ async def test_create_entry(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
# Test errors that can arise when connecting to a Pro:
@ -42,13 +42,13 @@ async def test_create_entry(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=config
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == connect_errors
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=config
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "192.168.1.101"
assert result["data"] == {
CONF_IP_ADDRESS: "192.168.1.101",
@ -63,13 +63,13 @@ async def test_duplicate_error(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.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=config
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -78,7 +78,7 @@ async def test_step_import(hass: HomeAssistant, config, setup_airvisual_pro) ->
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=config
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "192.168.1.101"
assert result["data"] == {
CONF_IP_ADDRESS: "192.168.1.101",
@ -114,7 +114,7 @@ async def test_reauth(
},
data=config,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
# Test errors that can arise when connecting to a Pro:
@ -122,7 +122,7 @@ async def test_reauth(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_PASSWORD: "new_password"}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == connect_errors
result = await hass.config_entries.flow.async_configure(
@ -132,6 +132,6 @@ async def test_reauth(
# Allow reload to finish:
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
assert len(hass.config_entries.async_entries()) == 1

View File

@ -76,7 +76,7 @@ async def test_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -90,7 +90,7 @@ async def test_form(hass: HomeAssistant) -> None:
entry = conf_entries[0]
assert entry.state is ConfigEntryState.LOADED
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"Airzone {CONFIG[CONF_HOST]}:{CONFIG[CONF_PORT]}"
assert result["data"][CONF_HOST] == CONFIG[CONF_HOST]
assert result["data"][CONF_PORT] == CONFIG[CONF_PORT]
@ -132,7 +132,7 @@ async def test_form_invalid_system_id(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {CONF_ID: "invalid_system_id"}
@ -143,7 +143,7 @@ async def test_form_invalid_system_id(hass: HomeAssistant) -> None:
result["flow_id"], CONFIG_ID1
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
await hass.async_block_till_done()
@ -151,7 +151,7 @@ async def test_form_invalid_system_id(hass: HomeAssistant) -> None:
entry = conf_entries[0]
assert entry.state is ConfigEntryState.LOADED
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert (
result["title"]
== f"Airzone {CONFIG_ID1[CONF_HOST]}:{CONFIG_ID1[CONF_PORT]}"
@ -208,7 +208,7 @@ async def test_dhcp_flow(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_DHCP},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "discovered_connection"
with (
@ -244,7 +244,7 @@ async def test_dhcp_flow(hass: HomeAssistant) -> None:
},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == {
CONF_HOST: TEST_IP,
CONF_PORT: TEST_PORT,
@ -266,7 +266,7 @@ async def test_dhcp_flow_error(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_DHCP},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
@ -283,7 +283,7 @@ async def test_dhcp_connection_error(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_DHCP},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "discovered_connection"
with patch(
@ -338,7 +338,7 @@ async def test_dhcp_connection_error(hass: HomeAssistant) -> None:
entry = conf_entries[0]
assert entry.state is ConfigEntryState.LOADED
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"Airzone {short_mac(HVAC_WEBSERVER_MOCK[API_MAC])}"
assert result["data"][CONF_HOST] == TEST_IP
assert result["data"][CONF_PORT] == TEST_PORT
@ -359,7 +359,7 @@ async def test_dhcp_invalid_system_id(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_DHCP},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "discovered_connection"
with (
@ -395,7 +395,7 @@ async def test_dhcp_invalid_system_id(hass: HomeAssistant) -> None:
},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "discovered_connection"
assert result["errors"] == {CONF_ID: "invalid_system_id"}
@ -416,7 +416,7 @@ async def test_dhcp_invalid_system_id(hass: HomeAssistant) -> None:
entry = conf_entries[0]
assert entry.state is ConfigEntryState.LOADED
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"Airzone {short_mac(DHCP_SERVICE_INFO.macaddress)}"
assert result["data"][CONF_HOST] == TEST_IP
assert result["data"][CONF_PORT] == TEST_PORT

View File

@ -4,11 +4,11 @@ from unittest.mock import patch
from aioairzone_cloud.exceptions import AirzoneCloudError, LoginError
from homeassistant import data_entry_flow
from homeassistant.components.airzone_cloud.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER, ConfigEntryState
from homeassistant.const import CONF_ID, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .util import (
CONFIG,
@ -53,7 +53,7 @@ async def test_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -65,7 +65,7 @@ async def test_form(hass: HomeAssistant) -> None:
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -82,7 +82,7 @@ async def test_form(hass: HomeAssistant) -> None:
entry = conf_entries[0]
assert entry.state is ConfigEntryState.LOADED
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"House {WS_ID} ({CONFIG[CONF_ID]})"
assert result["data"][CONF_ID] == CONFIG[CONF_ID]
assert result["data"][CONF_USERNAME] == CONFIG[CONF_USERNAME]
@ -120,7 +120,7 @@ async def test_installations_list_error(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -132,7 +132,7 @@ async def test_installations_list_error(hass: HomeAssistant) -> None:
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"}

View File

@ -20,7 +20,7 @@ async def test_form(hass: HomeAssistant, mock_aladdinconnect_api: MagicMock) ->
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
with (
@ -42,7 +42,7 @@ async def test_form(hass: HomeAssistant, mock_aladdinconnect_api: MagicMock) ->
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Aladdin Connect"
assert result2["data"] == {
CONF_USERNAME: "test-username",
@ -73,7 +73,7 @@ async def test_form_failed_auth(
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"}
@ -97,7 +97,7 @@ async def test_form_connection_timeout(
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"}
@ -159,7 +159,7 @@ async def test_reauth_flow(
)
assert result["step_id"] == "reauth_confirm"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
with (
@ -178,7 +178,7 @@ async def test_reauth_flow(
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "reauth_successful"
assert mock_entry.data == {
CONF_USERNAME: "test-username",
@ -209,7 +209,7 @@ async def test_reauth_flow_auth_error(
)
assert result["step_id"] == "reauth_confirm"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
mock_aladdinconnect_api.login.return_value = False
mock_aladdinconnect_api.login.side_effect = InvalidPasswordError
@ -233,7 +233,7 @@ async def test_reauth_flow_auth_error(
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"}
@ -260,7 +260,7 @@ async def test_reauth_flow_connnection_error(
)
assert result["step_id"] == "reauth_confirm"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
mock_aladdinconnect_api.login.side_effect = ClientConnectionError
@ -274,5 +274,5 @@ async def test_reauth_flow_connnection_error(
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"}

View File

@ -5,7 +5,7 @@ from unittest.mock import patch
from alarmdecoder.util import NoDeviceError
import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.alarmdecoder import config_flow
from homeassistant.components.alarmdecoder.const import (
CONF_ALT_NIGHT_MODE,
@ -31,6 +31,7 @@ from homeassistant.components.alarmdecoder.const import (
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_PROTOCOL
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@ -63,7 +64,7 @@ async def test_setups(hass: HomeAssistant, protocol, connection, title) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
@ -71,7 +72,7 @@ async def test_setups(hass: HomeAssistant, protocol, connection, title) -> None:
{CONF_PROTOCOL: protocol},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "protocol"
with (
@ -85,7 +86,7 @@ async def test_setups(hass: HomeAssistant, protocol, connection, title) -> None:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], connection
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == title
assert result["data"] == {
**connection,
@ -108,7 +109,7 @@ async def test_setup_connection_error(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
@ -116,7 +117,7 @@ async def test_setup_connection_error(hass: HomeAssistant) -> None:
{CONF_PROTOCOL: protocol},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "protocol"
with (
@ -129,7 +130,7 @@ async def test_setup_connection_error(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], connection_settings
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"}
with (
@ -142,7 +143,7 @@ async def test_setup_connection_error(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], connection_settings
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "unknown"}
@ -161,7 +162,7 @@ async def test_options_arm_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(
@ -169,7 +170,7 @@ async def test_options_arm_flow(hass: HomeAssistant) -> None:
user_input={"edit_selection": "Arming Settings"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "arm_settings"
with patch(
@ -180,7 +181,7 @@ async def test_options_arm_flow(hass: HomeAssistant) -> None:
user_input=user_input,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert entry.options == {
OPTIONS_ARM: user_input,
OPTIONS_ZONES: DEFAULT_ZONE_OPTIONS,
@ -202,7 +203,7 @@ async def test_options_zone_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(
@ -210,7 +211,7 @@ async def test_options_zone_flow(hass: HomeAssistant) -> None:
user_input={"edit_selection": "Zones"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zone_select"
result = await hass.config_entries.options.async_configure(
@ -226,7 +227,7 @@ async def test_options_zone_flow(hass: HomeAssistant) -> None:
user_input=zone_settings,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert entry.options == {
OPTIONS_ARM: DEFAULT_ARM_OPTIONS,
OPTIONS_ZONES: {zone_number: zone_settings},
@ -235,7 +236,7 @@ async def test_options_zone_flow(hass: HomeAssistant) -> None:
# Make sure zone can be removed...
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(
@ -243,7 +244,7 @@ async def test_options_zone_flow(hass: HomeAssistant) -> None:
user_input={"edit_selection": "Zones"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zone_select"
result = await hass.config_entries.options.async_configure(
@ -259,7 +260,7 @@ async def test_options_zone_flow(hass: HomeAssistant) -> None:
user_input={},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert entry.options == {
OPTIONS_ARM: DEFAULT_ARM_OPTIONS,
OPTIONS_ZONES: {},
@ -281,7 +282,7 @@ async def test_options_zone_flow_validation(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(
@ -289,7 +290,7 @@ async def test_options_zone_flow_validation(hass: HomeAssistant) -> None:
user_input={"edit_selection": "Zones"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zone_select"
# Zone Number must be int
@ -298,7 +299,7 @@ async def test_options_zone_flow_validation(hass: HomeAssistant) -> None:
user_input={CONF_ZONE_NUMBER: "asd"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zone_select"
assert result["errors"] == {CONF_ZONE_NUMBER: "int"}
@ -307,7 +308,7 @@ async def test_options_zone_flow_validation(hass: HomeAssistant) -> None:
user_input={CONF_ZONE_NUMBER: zone_number},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zone_details"
# CONF_RELAY_ADDR & CONF_RELAY_CHAN are inclusive
@ -316,7 +317,7 @@ async def test_options_zone_flow_validation(hass: HomeAssistant) -> None:
user_input={**zone_settings, CONF_RELAY_ADDR: "1"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zone_details"
assert result["errors"] == {"base": "relay_inclusive"}
@ -325,7 +326,7 @@ async def test_options_zone_flow_validation(hass: HomeAssistant) -> None:
user_input={**zone_settings, CONF_RELAY_CHAN: "1"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zone_details"
assert result["errors"] == {"base": "relay_inclusive"}
@ -335,7 +336,7 @@ async def test_options_zone_flow_validation(hass: HomeAssistant) -> None:
user_input={**zone_settings, CONF_RELAY_ADDR: "abc", CONF_RELAY_CHAN: "abc"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zone_details"
assert result["errors"] == {
CONF_RELAY_ADDR: "int",
@ -348,7 +349,7 @@ async def test_options_zone_flow_validation(hass: HomeAssistant) -> None:
user_input={**zone_settings, CONF_ZONE_LOOP: "1"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zone_details"
assert result["errors"] == {CONF_ZONE_LOOP: "loop_rfid"}
@ -358,7 +359,7 @@ async def test_options_zone_flow_validation(hass: HomeAssistant) -> None:
user_input={**zone_settings, CONF_ZONE_RFID: "rfid123", CONF_ZONE_LOOP: "ab"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zone_details"
assert result["errors"] == {CONF_ZONE_LOOP: "int"}
@ -368,7 +369,7 @@ async def test_options_zone_flow_validation(hass: HomeAssistant) -> None:
user_input={**zone_settings, CONF_ZONE_RFID: "rfid123", CONF_ZONE_LOOP: "5"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zone_details"
assert result["errors"] == {CONF_ZONE_LOOP: "loop_range"}
@ -387,7 +388,7 @@ async def test_options_zone_flow_validation(hass: HomeAssistant) -> None:
},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert entry.options == {
OPTIONS_ARM: DEFAULT_ARM_OPTIONS,
OPTIONS_ZONES: {
@ -435,7 +436,7 @@ async def test_one_device_allowed(hass: HomeAssistant, protocol, connection) ->
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_configure(
@ -443,11 +444,11 @@ async def test_one_device_allowed(hass: HomeAssistant, protocol, connection) ->
{CONF_PROTOCOL: protocol},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "protocol"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], connection
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"

View File

@ -8,7 +8,6 @@ from amberelectric import ApiException
from amberelectric.model.site import Site, SiteStatus
import pytest
from homeassistant import data_entry_flow
from homeassistant.components.amberelectric.config_flow import filter_sites
from homeassistant.components.amberelectric.const import (
CONF_SITE_ID,
@ -18,6 +17,7 @@ from homeassistant.components.amberelectric.const import (
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_API_TOKEN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
API_KEY = "psk_123456789"
@ -131,7 +131,7 @@ async def test_single_pending_site(
initial_result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert initial_result.get("type") == data_entry_flow.FlowResultType.FORM
assert initial_result.get("type") is FlowResultType.FORM
assert initial_result.get("step_id") == "user"
# Test filling in API key
@ -140,7 +140,7 @@ async def test_single_pending_site(
context={"source": SOURCE_USER},
data={CONF_API_TOKEN: API_KEY},
)
assert enter_api_key_result.get("type") == data_entry_flow.FlowResultType.FORM
assert enter_api_key_result.get("type") is FlowResultType.FORM
assert enter_api_key_result.get("step_id") == "site"
select_site_result = await hass.config_entries.flow.async_configure(
@ -149,7 +149,7 @@ async def test_single_pending_site(
)
# Show available sites
assert select_site_result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
assert select_site_result.get("type") is FlowResultType.CREATE_ENTRY
assert select_site_result.get("title") == "Home"
data = select_site_result.get("data")
assert data
@ -162,7 +162,7 @@ async def test_single_site(hass: HomeAssistant, single_site_api: Mock) -> None:
initial_result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert initial_result.get("type") == data_entry_flow.FlowResultType.FORM
assert initial_result.get("type") is FlowResultType.FORM
assert initial_result.get("step_id") == "user"
# Test filling in API key
@ -171,7 +171,7 @@ async def test_single_site(hass: HomeAssistant, single_site_api: Mock) -> None:
context={"source": SOURCE_USER},
data={CONF_API_TOKEN: API_KEY},
)
assert enter_api_key_result.get("type") == data_entry_flow.FlowResultType.FORM
assert enter_api_key_result.get("type") is FlowResultType.FORM
assert enter_api_key_result.get("step_id") == "site"
select_site_result = await hass.config_entries.flow.async_configure(
@ -180,7 +180,7 @@ async def test_single_site(hass: HomeAssistant, single_site_api: Mock) -> None:
)
# Show available sites
assert select_site_result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
assert select_site_result.get("type") is FlowResultType.CREATE_ENTRY
assert select_site_result.get("title") == "Home"
data = select_site_result.get("data")
assert data
@ -195,7 +195,7 @@ async def test_single_site_rejoin(
initial_result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert initial_result.get("type") == data_entry_flow.FlowResultType.FORM
assert initial_result.get("type") is FlowResultType.FORM
assert initial_result.get("step_id") == "user"
# Test filling in API key
@ -204,7 +204,7 @@ async def test_single_site_rejoin(
context={"source": SOURCE_USER},
data={CONF_API_TOKEN: API_KEY},
)
assert enter_api_key_result.get("type") == data_entry_flow.FlowResultType.FORM
assert enter_api_key_result.get("type") is FlowResultType.FORM
assert enter_api_key_result.get("step_id") == "site"
select_site_result = await hass.config_entries.flow.async_configure(
@ -213,7 +213,7 @@ async def test_single_site_rejoin(
)
# Show available sites
assert select_site_result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
assert select_site_result.get("type") is FlowResultType.CREATE_ENTRY
assert select_site_result.get("title") == "Home"
data = select_site_result.get("data")
assert data
@ -229,7 +229,7 @@ async def test_no_site(hass: HomeAssistant, no_site_api: Mock) -> None:
data={CONF_API_TOKEN: "psk_123456789"},
)
assert result.get("type") == data_entry_flow.FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
# Goes back to the user step
assert result.get("step_id") == "user"
assert result.get("errors") == {"api_token": "no_site"}
@ -240,7 +240,7 @@ async def test_invalid_key(hass: HomeAssistant, invalid_key_api: Mock) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result.get("type") == data_entry_flow.FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
# Test filling in API key
@ -249,7 +249,7 @@ async def test_invalid_key(hass: HomeAssistant, invalid_key_api: Mock) -> None:
context={"source": SOURCE_USER},
data={CONF_API_TOKEN: "psk_123456789"},
)
assert result.get("type") == data_entry_flow.FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
# Goes back to the user step
assert result.get("step_id") == "user"
assert result.get("errors") == {"api_token": "invalid_api_token"}
@ -260,7 +260,7 @@ async def test_unknown_error(hass: HomeAssistant, api_error: Mock) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result.get("type") == data_entry_flow.FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
# Test filling in API key
@ -269,7 +269,7 @@ async def test_unknown_error(hass: HomeAssistant, api_error: Mock) -> None:
context={"source": SOURCE_USER},
data={CONF_API_TOKEN: "psk_123456789"},
)
assert result.get("type") == data_entry_flow.FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
# Goes back to the user step
assert result.get("step_id") == "user"
assert result.get("errors") == {"api_token": "unknown_error"}

View File

@ -5,12 +5,13 @@ from unittest.mock import AsyncMock, patch
import ambiclimate
import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.ambiclimate import config_flow
from homeassistant.components.http import KEY_HASS
from homeassistant.config import async_process_ha_core_config
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import AbortFlow, FlowResultType
from homeassistant.setup import async_setup_component
from homeassistant.util import aiohttp
@ -38,7 +39,7 @@ async def test_abort_if_no_implementation_registered(hass: HomeAssistant) -> Non
flow.hass = hass
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "missing_configuration"
@ -51,12 +52,12 @@ async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
config_flow.DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
with pytest.raises(data_entry_flow.AbortFlow):
with pytest.raises(AbortFlow):
result = await flow.async_step_code()
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -66,7 +67,7 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None:
flow = await init_config_flow(hass)
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "auth"
assert (
result["description_placeholders"]["cb_url"]
@ -81,7 +82,7 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None:
with patch("ambiclimate.AmbiclimateOAuth.get_access_token", return_value="test"):
result = await flow.async_step_code("123ABC")
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Ambiclimate"
assert result["data"]["callback_url"] == "https://example.com/api/ambiclimate"
assert result["data"][CONF_CLIENT_SECRET] == "secret"
@ -89,14 +90,14 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None:
with patch("ambiclimate.AmbiclimateOAuth.get_access_token", return_value=None):
result = await flow.async_step_code("123ABC")
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
with patch(
"ambiclimate.AmbiclimateOAuth.get_access_token",
side_effect=ambiclimate.AmbiclimateOauthError(),
):
result = await flow.async_step_code("123ABC")
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
async def test_abort_invalid_code(hass: HomeAssistant) -> None:
@ -106,7 +107,7 @@ async def test_abort_invalid_code(hass: HomeAssistant) -> None:
with patch("ambiclimate.AmbiclimateOAuth.get_access_token", return_value=None):
result = await flow.async_step_code("invalid")
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "access_token"
@ -118,7 +119,7 @@ async def test_already_setup(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"

View File

@ -5,11 +5,11 @@ from unittest.mock import AsyncMock, patch
from aioambient.errors import AmbientError
import pytest
from homeassistant import data_entry_flow
from homeassistant.components.ambient_station import CONF_APP_KEY, DOMAIN
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_API_KEY
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
@pytest.mark.parametrize(
@ -26,7 +26,7 @@ async def test_create_entry(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
# Test errors that can arise:
@ -34,14 +34,14 @@ async def test_create_entry(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=config
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == errors
# Test that we can recover and finish the flow after errors occur:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=config
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "67890fghij67"
assert result["data"] == {
CONF_API_KEY: "12345abcde12345abcde",
@ -56,5 +56,5 @@ async def test_duplicate_error(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=config
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"

View File

@ -63,7 +63,7 @@ async def test_form(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
@ -71,7 +71,7 @@ async def test_form(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Home Assistant Analytics Insights"
assert result["data"] == {}
assert result["options"] == expected_options
@ -98,7 +98,7 @@ async def test_submitting_empty_form(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
@ -106,7 +106,7 @@ async def test_submitting_empty_form(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "no_integrations_selected"}
result = await hass.config_entries.flow.async_configure(
@ -118,7 +118,7 @@ async def test_submitting_empty_form(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Home Assistant Analytics Insights"
assert result["data"] == {}
assert result["options"] == {
@ -140,7 +140,7 @@ async def test_form_cannot_connect(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
@ -161,7 +161,7 @@ async def test_form_already_configured(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "single_instance_allowed"
@ -209,7 +209,7 @@ async def test_options_flow(
await setup_integration(hass, mock_config_entry)
result = await hass.config_entries.options.async_init(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
mock_analytics_client.get_integrations.reset_mock()
result = await hass.config_entries.options.async_configure(
@ -218,7 +218,7 @@ async def test_options_flow(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == expected_options
await hass.async_block_till_done()
mock_analytics_client.get_integrations.assert_called_once()
@ -244,7 +244,7 @@ async def test_submitting_empty_options_flow(
await setup_integration(hass, mock_config_entry)
result = await hass.config_entries.options.async_init(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.options.async_configure(
result["flow_id"],
@ -252,7 +252,7 @@ async def test_submitting_empty_options_flow(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "no_integrations_selected"}
result = await hass.config_entries.options.async_configure(
@ -264,7 +264,7 @@ async def test_submitting_empty_options_flow(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
CONF_TRACKED_INTEGRATIONS: ["youtube", "hue"],
CONF_TRACKED_CUSTOM_INTEGRATIONS: ["hacs"],
@ -285,5 +285,5 @@ async def test_options_flow_cannot_connect(
mock_config_entry.add_to_hass(hass)
result = await hass.config_entries.options.async_init(mock_config_entry.entry_id)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"

View File

@ -20,7 +20,7 @@ async def test_form(hass: HomeAssistant, aioclient_mock_fixture) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
with patch(
@ -36,7 +36,7 @@ async def test_form(hass: HomeAssistant, aioclient_mock_fixture) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "1.1.1.1"
assert result2["data"] == {
"host": "1.1.1.1",
@ -55,7 +55,7 @@ async def test_device_already_configured(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
@ -66,7 +66,7 @@ async def test_device_already_configured(
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured"
@ -87,7 +87,7 @@ async def test_form_invalid_auth(
{"host": "1.1.1.1", "port": 8080, "username": "user", "password": "wrong-pass"},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"username": "invalid_auth", "password": "invalid_auth"}
@ -110,5 +110,5 @@ async def test_form_cannot_connect(
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"}

View File

@ -5,7 +5,6 @@ from unittest.mock import patch
import pytest
from homeassistant import data_entry_flow
from homeassistant.components.androidtv.config_flow import (
APPS_NEW_ID,
CONF_APP_DELETE,
@ -37,6 +36,7 @@ from homeassistant.components.androidtv.const import (
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_DEVICE_CLASS, CONF_HOST, CONF_PORT
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .patchers import PATCH_ACCESS, PATCH_ISFILE, PATCH_SETUP_ENTRY
@ -104,7 +104,7 @@ async def test_user(
flow_result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER, "show_advanced_options": True}
)
assert flow_result["type"] == data_entry_flow.FlowResultType.FORM
assert flow_result["type"] is FlowResultType.FORM
assert flow_result["step_id"] == "user"
# test with all provided
@ -120,7 +120,7 @@ async def test_user(
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == HOST
assert result["data"] == config
@ -148,7 +148,7 @@ async def test_user_adbkey(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["title"] == HOST
assert result["data"] == config_data
@ -166,7 +166,7 @@ async def test_error_both_key_server(hass: HomeAssistant) -> None:
data=config_data,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "key_and_server"}
with (
@ -181,7 +181,7 @@ async def test_error_both_key_server(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"] == HOST
assert result2["data"] == CONFIG_ADB_SERVER
@ -196,7 +196,7 @@ async def test_error_invalid_key(hass: HomeAssistant) -> None:
data=config_data,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "adbkey_not_file"}
with (
@ -211,7 +211,7 @@ async def test_error_invalid_key(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"] == HOST
assert result2["data"] == CONFIG_ADB_SERVER
@ -244,7 +244,7 @@ async def test_invalid_mac(
data=config,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_unique_id"
@ -262,7 +262,7 @@ async def test_abort_if_host_exist(hass: HomeAssistant) -> None:
data=config_data,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -285,7 +285,7 @@ async def test_abort_if_unique_exist(hass: HomeAssistant) -> None:
data=CONFIG_ADB_SERVER,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -300,7 +300,7 @@ async def test_on_connect_failed(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure(
flow_result["flow_id"], user_input=CONFIG_ADB_SERVER
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"}
with patch(
@ -310,7 +310,7 @@ async def test_on_connect_failed(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=CONFIG_ADB_SERVER
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"}
with (
@ -325,7 +325,7 @@ async def test_on_connect_failed(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result3["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == HOST
assert result3["data"] == CONFIG_ADB_SERVER
@ -348,7 +348,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
await hass.async_block_till_done()
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"
# test app form with existing app
@ -358,7 +358,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_APPS: "app1",
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "apps"
# test change value in apps form
@ -368,7 +368,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_APP_NAME: "Appl1",
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
# test app form with new app
@ -378,7 +378,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_APPS: APPS_NEW_ID,
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "apps"
# test save value for new app
@ -389,7 +389,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_APP_NAME: "Appl2",
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
# test app form for delete
@ -399,7 +399,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_APPS: "app1",
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "apps"
# test delete app1
@ -410,7 +410,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_APP_DELETE: True,
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
# test rules form with existing rule
@ -420,7 +420,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_STATE_DETECTION_RULES: "com.plexapp.android",
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "rules"
# test change value in rule form with invalid json rule
@ -430,7 +430,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_RULE_VALUES: "a",
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "rules"
assert result["errors"] == {"base": "invalid_det_rules"}
@ -441,7 +441,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_RULE_VALUES: {"a": "b"},
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "rules"
assert result["errors"] == {"base": "invalid_det_rules"}
@ -452,7 +452,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_RULE_VALUES: ["standby"],
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
# test rule form with new rule
@ -462,7 +462,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_STATE_DETECTION_RULES: RULES_NEW_ID,
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "rules"
# test save value for new rule
@ -473,7 +473,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_RULE_VALUES: VALID_DETECT_RULE,
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
# test rules form with delete existing rule
@ -483,7 +483,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_STATE_DETECTION_RULES: "com.plexapp.android",
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "rules"
# test delete rule
@ -493,7 +493,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
CONF_RULE_DELETE: True,
},
)
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(
@ -507,7 +507,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
apps_options = config_entry.options[CONF_APPS]
assert apps_options.get("app1") is None

View File

@ -25,7 +25,7 @@ async def test_user_flow_success(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert "host" in result["data_schema"].schema
assert not result["errors"]
@ -44,7 +44,7 @@ async def test_user_flow_success(
result["flow_id"], {"host": host}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair"
assert "pin" in result["data_schema"].schema
assert not result["errors"]
@ -58,7 +58,7 @@ async def test_user_flow_success(
result["flow_id"], {"pin": pin}
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == name
assert result["data"] == {"host": host, "name": name, "mac": mac}
assert result["context"]["source"] == "user"
@ -85,7 +85,7 @@ async def test_user_flow_cannot_connect(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert "host" in result["data_schema"].schema
assert not result["errors"]
@ -99,7 +99,7 @@ async def test_user_flow_cannot_connect(
result["flow_id"], {"host": host}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert "host" in result["data_schema"].schema
assert result["errors"] == {"base": "cannot_connect"}
@ -127,7 +127,7 @@ async def test_user_flow_pairing_invalid_auth(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert "host" in result["data_schema"].schema
assert not result["errors"]
@ -145,7 +145,7 @@ async def test_user_flow_pairing_invalid_auth(
result["flow_id"], {"host": host}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair"
assert "pin" in result["data_schema"].schema
assert not result["errors"]
@ -159,7 +159,7 @@ async def test_user_flow_pairing_invalid_auth(
result["flow_id"], {"pin": pin}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair"
assert "pin" in result["data_schema"].schema
assert result["errors"] == {"base": "invalid_auth"}
@ -189,7 +189,7 @@ async def test_user_flow_pairing_connection_closed(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert "host" in result["data_schema"].schema
assert not result["errors"]
@ -207,7 +207,7 @@ async def test_user_flow_pairing_connection_closed(
result["flow_id"], {"host": host}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair"
assert "pin" in result["data_schema"].schema
assert not result["errors"]
@ -221,7 +221,7 @@ async def test_user_flow_pairing_connection_closed(
result["flow_id"], {"pin": pin}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair"
assert "pin" in result["data_schema"].schema
assert not result["errors"]
@ -251,7 +251,7 @@ async def test_user_flow_pairing_connection_closed_followed_by_cannot_connect(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert "host" in result["data_schema"].schema
assert not result["errors"]
@ -269,7 +269,7 @@ async def test_user_flow_pairing_connection_closed_followed_by_cannot_connect(
result["flow_id"], {"host": host}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair"
assert "pin" in result["data_schema"].schema
assert not result["errors"]
@ -283,7 +283,7 @@ async def test_user_flow_pairing_connection_closed_followed_by_cannot_connect(
result["flow_id"], {"pin": pin}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
mock_api.async_finish_pairing.assert_called_with(pin)
@ -328,7 +328,7 @@ async def test_user_flow_already_configured_host_changed_reloads_entry(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert "host" in result["data_schema"].schema
assert not result["errors"]
@ -340,7 +340,7 @@ async def test_user_flow_already_configured_host_changed_reloads_entry(
result["flow_id"], {"host": host}
)
assert result.get("type") == FlowResultType.ABORT
assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured"
mock_api.async_generate_cert_if_missing.assert_called()
@ -387,7 +387,7 @@ async def test_user_flow_already_configured_host_not_changed_no_reload_entry(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert "host" in result["data_schema"].schema
assert not result["errors"]
@ -399,7 +399,7 @@ async def test_user_flow_already_configured_host_not_changed_no_reload_entry(
result["flow_id"], {"host": host}
)
assert result.get("type") == FlowResultType.ABORT
assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured"
mock_api.async_generate_cert_if_missing.assert_called()
@ -442,7 +442,7 @@ async def test_zeroconf_flow_success(
properties={"bt": mac},
),
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zeroconf_confirm"
assert not result["data_schema"]
@ -461,7 +461,7 @@ async def test_zeroconf_flow_success(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair"
assert "pin" in result["data_schema"].schema
assert not result["errors"]
@ -475,7 +475,7 @@ async def test_zeroconf_flow_success(
result["flow_id"], {"pin": pin}
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == name
assert result["data"] == {
"host": host,
@ -520,7 +520,7 @@ async def test_zeroconf_flow_cannot_connect(
properties={"bt": mac},
),
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zeroconf_confirm"
assert not result["data_schema"]
@ -531,7 +531,7 @@ async def test_zeroconf_flow_cannot_connect(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
mock_api.async_generate_cert_if_missing.assert_called()
@ -571,7 +571,7 @@ async def test_zeroconf_flow_pairing_invalid_auth(
properties={"bt": mac},
),
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zeroconf_confirm"
assert not result["data_schema"]
@ -582,7 +582,7 @@ async def test_zeroconf_flow_pairing_invalid_auth(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair"
assert "pin" in result["data_schema"].schema
assert not result["errors"]
@ -596,7 +596,7 @@ async def test_zeroconf_flow_pairing_invalid_auth(
result["flow_id"], {"pin": pin}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair"
assert "pin" in result["data_schema"].schema
assert result["errors"] == {"base": "invalid_auth"}
@ -654,7 +654,7 @@ async def test_zeroconf_flow_already_configured_host_changed_reloads_entry(
properties={"bt": mac},
),
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
await hass.async_block_till_done()
@ -707,7 +707,7 @@ async def test_zeroconf_flow_already_configured_host_not_changed_no_reload_entry
properties={"bt": mac},
),
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
await hass.async_block_till_done()
@ -740,7 +740,7 @@ async def test_zeroconf_flow_abort_if_mac_is_missing(
properties={},
),
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
@ -785,7 +785,7 @@ async def test_reauth_flow_success(
mock_api.async_start_pairing = AsyncMock(return_value=None)
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pair"
assert "pin" in result["data_schema"].schema
assert not result["errors"]
@ -799,7 +799,7 @@ async def test_reauth_flow_success(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"pin": pin}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
mock_api.async_finish_pairing.assert_called_with(pin)
@ -854,7 +854,7 @@ async def test_reauth_flow_cannot_connect(
mock_api.async_start_pairing = AsyncMock(side_effect=CannotConnect())
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
assert result["errors"] == {"base": "cannot_connect"}

View File

@ -4,10 +4,11 @@ from unittest.mock import patch
from anova_wifi import AnovaPrecisionCooker, InvalidLogin, NoDevicesFound
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.anova.const import DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import CONF_INPUT, DEVICE_UNIQUE_ID, create_entry
@ -41,7 +42,7 @@ async def test_flow_user(
result["flow_id"],
user_input=CONF_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
CONF_USERNAME: "sample@gmail.com",
CONF_PASSWORD: "sample",
@ -76,7 +77,7 @@ async def test_flow_user_already_configured(hass: HomeAssistant) -> None:
result["flow_id"],
user_input=CONF_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -94,7 +95,7 @@ async def test_flow_wrong_login(hass: HomeAssistant) -> None:
result["flow_id"],
user_input=CONF_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "invalid_auth"}
@ -112,7 +113,7 @@ async def test_flow_unknown_error(hass: HomeAssistant) -> None:
result["flow_id"],
user_input=CONF_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "unknown"}
@ -133,5 +134,5 @@ async def test_flow_no_devices(hass: HomeAssistant) -> None:
result["flow_id"],
user_input=CONF_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "no_devices_found"}

View File

@ -19,7 +19,7 @@ async def test_form_with_valid_connection(
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["errors"] is None
with patch(
@ -36,7 +36,7 @@ async def test_form_with_valid_connection(
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Anthem AV"
assert result2["data"] == {
"host": "1.1.1.1",
@ -67,7 +67,7 @@ async def test_form_device_info_error(hass: HomeAssistant) -> None:
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_receive_deviceinfo"}
@ -91,7 +91,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"}
@ -112,5 +112,5 @@ async def test_device_already_configured(
DOMAIN, context={"source": SOURCE_USER}, data=config
)
assert result.get("type") == FlowResultType.ABORT
assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured"

View File

@ -27,7 +27,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
with patch(
@ -40,7 +40,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == FIXTURE_USER_INPUT[CONF_EMAIL]
assert result2["data"] == FIXTURE_USER_INPUT
assert len(mock_setup_entry.mock_calls) == 1
@ -63,7 +63,7 @@ async def test_form_exception(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
with patch(
@ -74,7 +74,7 @@ async def test_form_exception(
result["flow_id"],
FIXTURE_USER_INPUT,
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": expected_error_key}
with patch(
@ -87,7 +87,7 @@ async def test_form_exception(
)
await hass.async_block_till_done()
assert result3["type"] == FlowResultType.CREATE_ENTRY
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == FIXTURE_USER_INPUT[CONF_EMAIL]
assert result3["data"] == FIXTURE_USER_INPUT
assert len(mock_setup_entry.mock_calls) == 1
@ -141,7 +141,7 @@ async def test_reauth_flow(
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "reauth_successful"
@ -178,7 +178,7 @@ async def test_reauth_flow_retry(
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"}
# Second attempt at reauth - authentication succeeds
@ -195,5 +195,5 @@ async def test_reauth_flow_retry(
)
await hass.async_block_till_done()
assert result3["type"] == FlowResultType.ABORT
assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "reauth_successful"

View File

@ -33,7 +33,7 @@ async def test_config_flow_cannot_connect(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER},
data=CONF_DATA,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"]["base"] == "cannot_connect"
@ -63,7 +63,7 @@ async def test_config_flow_duplicate(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER},
data=CONF_DATA,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
# Then, we create the integration once again using a different port. However,
@ -78,7 +78,7 @@ async def test_config_flow_duplicate(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER},
data=another_host,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
# Now we change the serial number and add it again. This should be successful.
@ -91,7 +91,7 @@ async def test_config_flow_duplicate(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER},
data=another_host,
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == another_host
@ -105,14 +105,14 @@ async def test_flow_works(hass: HomeAssistant) -> None:
DOMAIN,
context={CONF_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=CONF_DATA
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_STATUS["UPSNAME"]
assert result["data"] == CONF_DATA
@ -147,7 +147,7 @@ async def test_flow_minimal_status(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=CONF_DATA
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == CONF_DATA
assert result["title"] == expected_title
mock_setup.assert_called_once()

View File

@ -7,7 +7,7 @@ from pyatv import exceptions
from pyatv.const import PairingRequirement, Protocol
import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.components.apple_tv import CONF_ADDRESS, config_flow
from homeassistant.components.apple_tv.const import (
@ -16,6 +16,7 @@ from homeassistant.components.apple_tv.const import (
DOMAIN,
)
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .common import airplay_service, create_conf, mrp_service, raop_service
@ -72,7 +73,7 @@ async def test_user_input_device_not_found(hass: HomeAssistant, mrp_device) -> N
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["step_id"] == "user"
result2 = await hass.config_entries.flow.async_configure(
@ -80,7 +81,7 @@ async def test_user_input_device_not_found(hass: HomeAssistant, mrp_device) -> N
{"device_input": "none"},
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "no_devices_found"}
@ -96,7 +97,7 @@ async def test_user_input_unexpected_error(hass: HomeAssistant, mock_scan) -> No
{"device_input": "dummy"},
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"}
@ -105,31 +106,31 @@ async def test_user_adds_full_device(hass: HomeAssistant, full_device, pairing)
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"] == {}
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{"device_input": "MRP Device"},
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["description_placeholders"] == {
"name": "MRP Device",
"type": "Unknown",
}
result3 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result3["type"] == data_entry_flow.FlowResultType.FORM
assert result3["type"] is FlowResultType.FORM
assert result3["description_placeholders"] == {"protocol": "MRP"}
result4 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"pin": 1111}
)
assert result4["type"] == data_entry_flow.FlowResultType.FORM
assert result4["type"] is FlowResultType.FORM
assert result4["description_placeholders"] == {"protocol": "DMAP", "pin": "1111"}
result5 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result5["type"] == data_entry_flow.FlowResultType.FORM
assert result5["type"] is FlowResultType.FORM
assert result5["description_placeholders"] == {"protocol": "AirPlay"}
result6 = await hass.config_entries.flow.async_configure(
@ -160,14 +161,14 @@ async def test_user_adds_dmap_device(
result["flow_id"],
{"device_input": "DMAP Device"},
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["description_placeholders"] == {
"name": "DMAP Device",
"type": "Unknown",
}
result3 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result3["type"] == data_entry_flow.FlowResultType.FORM
assert result3["type"] is FlowResultType.FORM
assert result3["description_placeholders"] == {"pin": "1111", "protocol": "DMAP"}
result6 = await hass.config_entries.flow.async_configure(
@ -200,7 +201,7 @@ async def test_user_adds_dmap_device_failed(
await hass.config_entries.flow.async_configure(result["flow_id"], {})
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "device_did_not_pair"
@ -216,7 +217,7 @@ async def test_user_adds_device_with_ip_filter(
result["flow_id"],
{"device_input": "127.0.0.1"},
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["description_placeholders"] == {
"name": "DMAP Device",
"type": "Unknown",
@ -277,7 +278,7 @@ async def test_user_adds_existing_device(hass: HomeAssistant, mrp_device) -> Non
result["flow_id"],
{"device_input": "127.0.0.1"},
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "already_configured"}
@ -305,7 +306,7 @@ async def test_user_connection_failed(
result["flow_id"],
{},
)
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "setup_failed"
@ -328,7 +329,7 @@ async def test_user_start_pair_error_failed(
result["flow_id"],
{},
)
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "invalid_auth"
@ -349,14 +350,14 @@ async def test_user_pair_service_with_password(
result["flow_id"],
{},
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "password"
result3 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{},
)
assert result3["type"] == data_entry_flow.FlowResultType.ABORT
assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "setup_failed"
@ -378,14 +379,14 @@ async def test_user_pair_disabled_service(
result["flow_id"],
{},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "protocol_disabled"
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{},
)
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "setup_failed"
@ -407,7 +408,7 @@ async def test_user_pair_ignore_unsupported(
result["flow_id"],
{},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "setup_failed"
@ -435,7 +436,7 @@ async def test_user_pair_invalid_pin(
result["flow_id"],
{"pin": 1111},
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"}
@ -463,7 +464,7 @@ async def test_user_pair_unexpected_error(
result["flow_id"],
{"pin": 1111},
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"}
@ -486,7 +487,7 @@ async def test_user_pair_backoff_error(
result["flow_id"],
{},
)
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "backoff"
@ -509,7 +510,7 @@ async def test_user_pair_begin_unexpected_error(
result["flow_id"],
{},
)
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "unknown"
@ -526,14 +527,14 @@ async def test_ignores_disabled_service(
result["flow_id"],
{"device_input": "mrpid"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["description_placeholders"] == {
"name": "AirPlay Device",
"type": "Unknown",
}
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["description_placeholders"] == {"protocol": "AirPlay"}
result3 = await hass.config_entries.flow.async_configure(
@ -568,7 +569,7 @@ async def test_zeroconf_unsupported_service_aborts(hass: HomeAssistant) -> None:
properties={},
),
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown"
@ -589,7 +590,7 @@ async def test_zeroconf_add_mrp_device(
type="_mediaremotetv._tcp.local.",
),
)
assert unrelated_result["type"] == data_entry_flow.FlowResultType.FORM
assert unrelated_result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -604,7 +605,7 @@ async def test_zeroconf_add_mrp_device(
type="_mediaremotetv._tcp.local.",
),
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["description_placeholders"] == {
"name": "MRP Device",
"type": "Unknown",
@ -614,7 +615,7 @@ async def test_zeroconf_add_mrp_device(
result["flow_id"],
{},
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["description_placeholders"] == {"protocol": "MRP"}
result3 = await hass.config_entries.flow.async_configure(
@ -636,7 +637,7 @@ async def test_zeroconf_add_dmap_device(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=DMAP_SERVICE
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["description_placeholders"] == {
"name": "DMAP Device",
"type": "Unknown",
@ -646,7 +647,7 @@ async def test_zeroconf_add_dmap_device(
result["flow_id"],
{},
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["description_placeholders"] == {"protocol": "DMAP", "pin": "1111"}
result3 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
@ -685,7 +686,7 @@ async def test_zeroconf_ip_change(hass: HomeAssistant, mock_scan) -> None:
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert len(mock_async_setup.mock_calls) == 2
assert entry.data[CONF_ADDRESS] == "127.0.0.1"
@ -723,7 +724,7 @@ async def test_zeroconf_ip_change_after_ip_conflict_with_ignored_entry(
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert len(mock_async_setup.mock_calls) == 1
assert entry.data[CONF_ADDRESS] == "127.0.0.1"
@ -764,7 +765,7 @@ async def test_zeroconf_ip_change_via_secondary_identifier(
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert len(mock_async_setup.mock_calls) == 2
assert entry.data[CONF_ADDRESS] == "127.0.0.1"
@ -807,7 +808,7 @@ async def test_zeroconf_updates_identifiers_for_ignored_entries(
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert (
len(mock_async_setup.mock_calls) == 0
@ -826,7 +827,7 @@ async def test_zeroconf_add_existing_aborts(hass: HomeAssistant, dmap_device) ->
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=DMAP_SERVICE
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress"
@ -837,7 +838,7 @@ async def test_zeroconf_add_but_device_not_found(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=DMAP_SERVICE
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -848,7 +849,7 @@ async def test_zeroconf_add_existing_device(hass: HomeAssistant, dmap_device) ->
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=DMAP_SERVICE
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -859,7 +860,7 @@ async def test_zeroconf_unexpected_error(hass: HomeAssistant, mock_scan) -> None
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=DMAP_SERVICE
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown"
@ -885,7 +886,7 @@ async def test_zeroconf_abort_if_other_in_progress(
),
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
mock_scan.result = [
@ -907,7 +908,7 @@ async def test_zeroconf_abort_if_other_in_progress(
properties={"UniqueIdentifier": "mrpid", "Name": "Kitchen"},
),
)
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_in_progress"
@ -965,7 +966,7 @@ async def test_zeroconf_missing_device_during_protocol_resolve(
result["flow_id"],
{},
)
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "device_not_found"
@ -1025,7 +1026,7 @@ async def test_zeroconf_additional_protocol_resolve_failure(
result["flow_id"],
{},
)
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "inconsistent_device"
@ -1051,7 +1052,7 @@ async def test_zeroconf_pair_additionally_found_protocols(
properties={"deviceid": "airplayid"},
),
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
await hass.async_block_till_done()
mock_scan.result = [
@ -1102,7 +1103,7 @@ async def test_zeroconf_pair_additionally_found_protocols(
{},
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "pair_no_pin"
assert result2["description_placeholders"] == {"pin": ANY, "protocol": "RAOP"}
@ -1112,7 +1113,7 @@ async def test_zeroconf_pair_additionally_found_protocols(
{},
)
assert result3["type"] == data_entry_flow.FlowResultType.FORM
assert result3["type"] is FlowResultType.FORM
assert result3["step_id"] == "pair_with_pin"
assert result3["description_placeholders"] == {"protocol": "MRP"}
@ -1120,7 +1121,7 @@ async def test_zeroconf_pair_additionally_found_protocols(
result["flow_id"],
{"pin": 1234},
)
assert result4["type"] == data_entry_flow.FlowResultType.FORM
assert result4["type"] is FlowResultType.FORM
assert result4["step_id"] == "pair_with_pin"
assert result4["description_placeholders"] == {"protocol": "AirPlay"}
@ -1128,7 +1129,7 @@ async def test_zeroconf_pair_additionally_found_protocols(
result["flow_id"],
{"pin": 1234},
)
assert result5["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result5["type"] is FlowResultType.CREATE_ENTRY
async def test_zeroconf_mismatch(
@ -1157,14 +1158,14 @@ async def test_zeroconf_mismatch(
properties={"deviceid": "airplayid"},
),
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
await hass.async_block_till_done()
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "setup_failed"
@ -1190,13 +1191,13 @@ async def test_reconfigure_update_credentials(
result["flow_id"],
{},
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["description_placeholders"] == {"protocol": "MRP"}
result3 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"pin": 1111}
)
assert result3["type"] == data_entry_flow.FlowResultType.ABORT
assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "reauth_successful"
assert config_entry.data == {
@ -1218,7 +1219,7 @@ async def test_option_start_off(hass: HomeAssistant) -> None:
config_entry.add_to_hass(hass)
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
result2 = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={CONF_START_OFF: True}
@ -1243,5 +1244,5 @@ async def test_zeroconf_rejects_ipv6(hass: HomeAssistant) -> None:
properties={"CtlN": "Apple TV"},
),
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "ipv6_not_supported"

View File

@ -24,13 +24,13 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH},
data=VALID_DATA_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
with patch("homeassistant.components.aranet.async_setup_entry", return_value=True):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Aranet4 12345"
assert result2["data"] == {}
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
@ -43,7 +43,7 @@ async def test_async_step_bluetooth_not_aranet4(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH},
data=NOT_ARANET4_SERVICE_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
async def test_async_step_bluetooth_devices_already_setup(hass: HomeAssistant) -> None:
@ -59,7 +59,7 @@ async def test_async_step_bluetooth_devices_already_setup(hass: HomeAssistant) -
context={"source": config_entries.SOURCE_BLUETOOTH},
data=VALID_DATA_SERVICE_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -70,7 +70,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
context={"source": config_entries.SOURCE_BLUETOOTH},
data=VALID_DATA_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
result = await hass.config_entries.flow.async_init(
@ -78,7 +78,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
context={"source": config_entries.SOURCE_BLUETOOTH},
data=VALID_DATA_SERVICE_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress"
@ -91,7 +91,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
context={"source": config_entries.SOURCE_BLUETOOTH},
data=VALID_DATA_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
with patch(
@ -102,14 +102,14 @@ async def test_async_step_user_takes_precedence_over_discovery(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
with patch("homeassistant.components.aranet.async_setup_entry", return_value=True):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={"address": "aa:bb:cc:dd:ee:ff"},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Aranet4 12345"
assert result2["data"] == {}
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
@ -124,7 +124,7 @@ async def test_async_step_user_no_devices_found(hass: HomeAssistant) -> None:
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -138,7 +138,7 @@ async def test_async_step_user_only_other_devices_found(hass: HomeAssistant) ->
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -152,14 +152,14 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with patch("homeassistant.components.aranet.async_setup_entry", return_value=True):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={"address": "aa:bb:cc:dd:ee:ff"},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Aranet4 12345"
assert result2["data"] == {}
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
@ -175,7 +175,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
entry = MockConfigEntry(
@ -189,7 +189,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
result["flow_id"],
user_input={"address": "aa:bb:cc:dd:ee:ff"},
)
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured"
@ -211,7 +211,7 @@ async def test_async_step_user_with_found_devices_already_setup(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -225,14 +225,14 @@ async def test_async_step_user_old_firmware(hass: HomeAssistant) -> None:
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with patch("homeassistant.components.aranet.async_setup_entry", return_value=True):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={"address": "aa:bb:cc:dd:ee:ff"},
)
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "outdated_version"
@ -246,12 +246,12 @@ async def test_async_step_user_integrations_disabled(hass: HomeAssistant) -> Non
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with patch("homeassistant.components.aranet.async_setup_entry", return_value=True):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={"address": "aa:bb:cc:dd:ee:ff"},
)
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "integrations_disabled"

View File

@ -6,13 +6,13 @@ from unittest.mock import AsyncMock, patch
from arcam.fmj.client import ConnectionFailed
import pytest
from homeassistant import data_entry_flow
from homeassistant.components import ssdp
from homeassistant.components.arcam_fmj.config_flow import get_entry_client
from homeassistant.components.arcam_fmj.const import DOMAIN, DOMAIN_DATA_ENTRIES
from homeassistant.config_entries import SOURCE_SSDP, SOURCE_USER
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_SOURCE
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .conftest import (
MOCK_CONFIG_ENTRY,
@ -68,11 +68,11 @@ async def test_ssdp(hass: HomeAssistant, dummy_client) -> None:
context={CONF_SOURCE: SOURCE_SSDP},
data=MOCK_DISCOVER,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"Arcam FMJ ({MOCK_HOST})"
assert result["data"] == MOCK_CONFIG_ENTRY
@ -89,7 +89,7 @@ async def test_ssdp_abort(hass: HomeAssistant) -> None:
context={CONF_SOURCE: SOURCE_SSDP},
data=MOCK_DISCOVER,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -102,11 +102,11 @@ async def test_ssdp_unable_to_connect(hass: HomeAssistant, dummy_client) -> None
context={CONF_SOURCE: SOURCE_SSDP},
data=MOCK_DISCOVER,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
@ -121,7 +121,7 @@ async def test_ssdp_invalid_id(hass: HomeAssistant, dummy_client) -> None:
context={CONF_SOURCE: SOURCE_SSDP},
data=discover,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
@ -140,7 +140,7 @@ async def test_ssdp_update(hass: HomeAssistant) -> None:
context={CONF_SOURCE: SOURCE_SSDP},
data=MOCK_DISCOVER,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert entry.data[CONF_HOST] == MOCK_HOST
@ -155,7 +155,7 @@ async def test_user(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker) ->
data=None,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
user_input = {
@ -167,7 +167,7 @@ async def test_user(hass: HomeAssistant, aioclient_mock: AiohttpClientMocker) ->
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"Arcam FMJ ({MOCK_HOST})"
assert result["data"] == MOCK_CONFIG_ENTRY
assert result["result"].unique_id == MOCK_UUID
@ -188,7 +188,7 @@ async def test_invalid_ssdp(
context={CONF_SOURCE: SOURCE_USER},
data=user_input,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"Arcam FMJ ({MOCK_HOST})"
assert result["data"] == MOCK_CONFIG_ENTRY
assert result["result"].unique_id is None
@ -209,7 +209,7 @@ async def test_user_wrong(
context={CONF_SOURCE: SOURCE_USER},
data=user_input,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"Arcam FMJ ({MOCK_HOST})"
assert result["result"].unique_id is None

View File

@ -19,7 +19,7 @@ async def test_async_step_user_form(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
@ -48,7 +48,7 @@ async def test_async_step_user_success(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "aseko@example.com"
assert result2["data"] == {
CONF_EMAIL: "aseko@example.com",
@ -86,7 +86,7 @@ async def test_async_step_user_exception(
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": reason}
@ -119,7 +119,7 @@ async def test_get_account_info_exceptions(
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": reason}
@ -141,7 +141,7 @@ async def test_async_step_reauth_success(hass: HomeAssistant) -> None:
},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
assert result["errors"] == {}
@ -154,7 +154,7 @@ async def test_async_step_reauth_success(hass: HomeAssistant) -> None:
{CONF_EMAIL: "aseko@example.com", CONF_PASSWORD: "passw0rd"},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
assert len(mock_setup_entry.mock_calls) == 1
@ -200,5 +200,5 @@ async def test_async_step_reauth_exception(
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": reason}

View File

@ -6,7 +6,6 @@ from unittest.mock import patch
from pyasuswrt import AsusWrtError
import pytest
from homeassistant import data_entry_flow
from homeassistant.components.asuswrt.const import (
CONF_DNSMASQ,
CONF_INTERFACE,
@ -32,6 +31,7 @@ from homeassistant.const import (
CONF_USERNAME,
)
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .common import ASUSWRT_BASE, HOST, ROUTER_MAC_ADDR
@ -90,7 +90,7 @@ async def test_user_legacy(
flow_result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER, "show_advanced_options": True}
)
assert flow_result["type"] == data_entry_flow.FlowResultType.FORM
assert flow_result["type"] is FlowResultType.FORM
assert flow_result["step_id"] == "user"
connect_legacy.return_value.async_get_nvram.return_value = unique_id
@ -101,7 +101,7 @@ async def test_user_legacy(
)
await hass.async_block_till_done()
assert legacy_result["type"] == data_entry_flow.FlowResultType.FORM
assert legacy_result["type"] is FlowResultType.FORM
assert legacy_result["step_id"] == "legacy"
# complete configuration
@ -110,7 +110,7 @@ async def test_user_legacy(
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == HOST
assert result["data"] == {**CONFIG_DATA_TELNET, CONF_MODE: MODE_AP}
@ -125,7 +125,7 @@ async def test_user_http(
flow_result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER, "show_advanced_options": True}
)
assert flow_result["type"] == data_entry_flow.FlowResultType.FORM
assert flow_result["type"] is FlowResultType.FORM
assert flow_result["step_id"] == "user"
connect_http.return_value.mac = unique_id
@ -136,7 +136,7 @@ async def test_user_http(
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == HOST
assert result["data"] == CONFIG_DATA_HTTP
@ -153,7 +153,7 @@ async def test_error_pwd_required(hass: HomeAssistant, config) -> None:
data=config_data,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {CONF_BASE: "pwd_required"}
@ -166,7 +166,7 @@ async def test_error_no_password_ssh(hass: HomeAssistant) -> None:
data=config_data,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {CONF_BASE: "pwd_or_ssh"}
@ -182,7 +182,7 @@ async def test_error_invalid_ssh(hass: HomeAssistant, patch_is_file) -> None:
data=config_data,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {CONF_BASE: "ssh_not_file"}
@ -195,7 +195,7 @@ async def test_error_invalid_host(hass: HomeAssistant, patch_get_host) -> None:
data=CONFIG_DATA_TELNET,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {CONF_BASE: "invalid_host"}
@ -211,7 +211,7 @@ async def test_abort_if_not_unique_id_setup(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER},
data=CONFIG_DATA_TELNET,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_unique_id"
@ -233,7 +233,7 @@ async def test_update_uniqueid_exist(
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == HOST
assert result["data"] == CONFIG_DATA_HTTP
prev_entry = hass.config_entries.async_get_entry(existing_entry.entry_id)
@ -255,7 +255,7 @@ async def test_abort_invalid_unique_id(hass: HomeAssistant, connect_legacy) -> N
context={"source": SOURCE_USER},
data=CONFIG_DATA_TELNET,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "invalid_unique_id"
@ -285,7 +285,7 @@ async def test_on_connect_legacy_failed(
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {CONF_BASE: error}
@ -314,7 +314,7 @@ async def test_on_connect_http_failed(
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {CONF_BASE: error}
@ -331,7 +331,7 @@ async def test_options_flow_ap(hass: HomeAssistant, patch_setup_entry) -> None:
await hass.async_block_till_done()
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"
assert CONF_REQUIRE_IP in result["data_schema"].schema
@ -346,7 +346,7 @@ async def test_options_flow_ap(hass: HomeAssistant, patch_setup_entry) -> None:
},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {
CONF_CONSIDER_HOME: 20,
CONF_TRACK_UNKNOWN: True,
@ -368,7 +368,7 @@ async def test_options_flow_router(hass: HomeAssistant, patch_setup_entry) -> No
await hass.async_block_till_done()
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"
assert CONF_REQUIRE_IP not in result["data_schema"].schema
@ -382,7 +382,7 @@ async def test_options_flow_router(hass: HomeAssistant, patch_setup_entry) -> No
},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {
CONF_CONSIDER_HOME: 20,
CONF_TRACK_UNKNOWN: True,
@ -403,7 +403,7 @@ async def test_options_flow_http(hass: HomeAssistant, patch_setup_entry) -> None
await hass.async_block_till_done()
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"
assert CONF_INTERFACE not in result["data_schema"].schema
assert CONF_DNSMASQ not in result["data_schema"].schema
@ -417,7 +417,7 @@ async def test_options_flow_http(hass: HomeAssistant, patch_setup_entry) -> None
},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {
CONF_CONSIDER_HOME: 20,
CONF_TRACK_UNKNOWN: True,

View File

@ -4,9 +4,10 @@ from unittest.mock import PropertyMock, patch
import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.atag import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import UID, USER_INPUT, init_integration, mock_connection
@ -24,7 +25,7 @@ async def test_show_form(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
@ -38,7 +39,7 @@ async def test_adding_second_device(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
with patch(
"pyatag.AtagOne.id",
@ -47,7 +48,7 @@ async def test_adding_second_device(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
async def test_connection_error(
@ -61,7 +62,7 @@ async def test_connection_error(
data=USER_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"}
@ -76,7 +77,7 @@ async def test_unauthorized(
context={"source": config_entries.SOURCE_USER},
data=USER_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "unauthorized"}
@ -91,6 +92,6 @@ async def test_full_flow_implementation(
context={"source": config_entries.SOURCE_USER},
data=USER_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == UID
assert result["result"].unique_id == UID

View File

@ -4,9 +4,10 @@ from unittest.mock import patch
from aiohttp import ClientError
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.aurora.const import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@ -104,7 +105,7 @@ async def test_option_flow(hass: HomeAssistant) -> None:
data=None,
)
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(
@ -112,5 +113,5 @@ async def test_option_flow(hass: HomeAssistant) -> None:
user_input={"forecast_threshold": 65},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"]["forecast_threshold"] == 65

View File

@ -5,7 +5,7 @@ from unittest.mock import patch
from aurorapy.client import AuroraError, AuroraTimeoutError
from serial.tools import list_ports_common
from homeassistant import config_entries, data_entry_flow, setup
from homeassistant import config_entries, setup
from homeassistant.components.aurora_abb_powerone.const import (
ATTR_FIRMWARE,
ATTR_MODEL,
@ -13,6 +13,7 @@ from homeassistant.components.aurora_abb_powerone.const import (
)
from homeassistant.const import ATTR_SERIAL_NUMBER, CONF_ADDRESS, CONF_PORT
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
TEST_DATA = {"device": "/dev/ttyUSB7", "address": 3, "name": "MyAuroraPV"}
@ -64,7 +65,7 @@ async def test_form(hass: HomeAssistant) -> None:
{CONF_PORT: "/dev/ttyUSB7", CONF_ADDRESS: 7},
)
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == {
CONF_PORT: "/dev/ttyUSB7",

View File

@ -22,7 +22,7 @@ async def test_form(hass: HomeAssistant) -> None:
result1 = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result1["type"] == FlowResultType.FORM
assert result1["type"] is FlowResultType.FORM
assert result1["errors"] is None
with (
@ -40,7 +40,7 @@ async def test_form(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == TEST_USERNAME
assert result2["data"] == FAKE_DATA
assert len(mock_setup_entry.mock_calls) == 1
@ -91,7 +91,7 @@ async def test_already_configured(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result4["type"] == FlowResultType.ABORT
assert result4["type"] is FlowResultType.ABORT
assert len(mock_setup_entry.mock_calls) == 0
@ -100,7 +100,7 @@ async def test_no_services(hass: HomeAssistant) -> None:
result1 = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result1["type"] == FlowResultType.FORM
assert result1["type"] is FlowResultType.FORM
assert result1["errors"] is None
with (
@ -118,7 +118,7 @@ async def test_no_services(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "no_services_found"
assert len(mock_setup_entry.mock_calls) == 0
@ -138,7 +138,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
FAKE_DATA,
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "invalid_auth"}
@ -157,7 +157,7 @@ async def test_form_network_issue(hass: HomeAssistant) -> None:
FAKE_DATA,
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"}
@ -188,7 +188,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == TEST_USERNAME
assert result2["data"] == FAKE_DATA

View File

@ -6,11 +6,11 @@ from unittest.mock import Mock, patch
from aiohttp.client_exceptions import ClientConnectorError
from python_awair.exceptions import AuthError, AwairError
from homeassistant import data_entry_flow
from homeassistant.components.awair.const import DOMAIN
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER, SOURCE_ZEROCONF
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .const import (
CLOUD_CONFIG,
@ -29,7 +29,7 @@ async def test_show_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.MENU
assert result["type"] is FlowResultType.MENU
assert result["step_id"] == "user"
@ -72,7 +72,7 @@ async def test_unexpected_api_error(hass: HomeAssistant) -> None:
CLOUD_CONFIG,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown"
@ -101,7 +101,7 @@ async def test_duplicate_error(hass: HomeAssistant, user, cloud_devices) -> None
CLOUD_CONFIG,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured_account"
@ -123,7 +123,7 @@ async def test_no_devices_error(hass: HomeAssistant, user, no_devices) -> None:
CLOUD_CONFIG,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -141,7 +141,7 @@ async def test_reauth(hass: HomeAssistant, user, cloud_devices) -> None:
context={"source": SOURCE_REAUTH, "unique_id": CLOUD_UNIQUE_ID},
data={**CLOUD_CONFIG, CONF_ACCESS_TOKEN: "blah"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
assert result["errors"] == {}
@ -151,7 +151,7 @@ async def test_reauth(hass: HomeAssistant, user, cloud_devices) -> None:
user_input=CLOUD_CONFIG,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
assert result["errors"] == {CONF_ACCESS_TOKEN: "invalid_access_token"}
@ -167,7 +167,7 @@ async def test_reauth(hass: HomeAssistant, user, cloud_devices) -> None:
user_input=CLOUD_CONFIG,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
@ -185,7 +185,7 @@ async def test_reauth_error(hass: HomeAssistant) -> None:
context={"source": SOURCE_REAUTH, "unique_id": CLOUD_UNIQUE_ID},
data={**CLOUD_CONFIG, CONF_ACCESS_TOKEN: "blah"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
assert result["errors"] == {}
@ -195,7 +195,7 @@ async def test_reauth_error(hass: HomeAssistant) -> None:
user_input=CLOUD_CONFIG,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown"
@ -226,7 +226,7 @@ async def test_create_cloud_entry(hass: HomeAssistant, user, cloud_devices) -> N
CLOUD_CONFIG,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "foo@bar.com"
assert result["data"][CONF_ACCESS_TOKEN] == CLOUD_CONFIG[CONF_ACCESS_TOKEN]
assert result["result"].unique_id == CLOUD_UNIQUE_ID
@ -262,7 +262,7 @@ async def test_create_local_entry(hass: HomeAssistant, local_devices) -> None:
LOCAL_CONFIG,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Awair Element (24947)"
assert result["data"][CONF_HOST] == LOCAL_CONFIG[CONF_HOST]
assert result["result"].unique_id == LOCAL_UNIQUE_ID
@ -308,7 +308,7 @@ async def test_create_local_entry_from_discovery(
{"device": LOCAL_CONFIG[CONF_HOST]},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Awair Element (24947)"
assert result["data"][CONF_HOST] == LOCAL_CONFIG[CONF_HOST]
assert result["result"].unique_id == LOCAL_UNIQUE_ID
@ -342,7 +342,7 @@ async def test_create_local_entry_awair_error(hass: HomeAssistant) -> None:
)
# User is returned to form to try again
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "local_pick"
@ -365,7 +365,7 @@ async def test_create_zeroconf_entry(hass: HomeAssistant, local_devices) -> None
{},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Awair Element (24947)"
assert result["data"][CONF_HOST] == ZEROCONF_DISCOVERY.host
assert result["result"].unique_id == LOCAL_UNIQUE_ID
@ -382,7 +382,7 @@ async def test_unsuccessful_create_zeroconf_entry(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=ZEROCONF_DISCOVERY
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
async def test_zeroconf_discovery_update_configuration(
@ -414,7 +414,7 @@ async def test_zeroconf_discovery_update_configuration(
data=ZEROCONF_DISCOVERY,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured_device"
assert config_entry.data[CONF_HOST] == ZEROCONF_DISCOVERY.host
@ -440,7 +440,7 @@ async def test_zeroconf_during_onboarding(
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=ZEROCONF_DISCOVERY
)
assert result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == "Awair Element (24947)"
assert "data" in result
assert result["data"][CONF_HOST] == ZEROCONF_DISCOVERY.host

View File

@ -61,7 +61,7 @@ async def test_flow_manual_configuration(
AXIS_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(
@ -75,7 +75,7 @@ async def test_flow_manual_configuration(
},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"M1065-LW - {MAC}"
assert result["data"] == {
CONF_PROTOCOL: "http",
@ -98,7 +98,7 @@ async def test_manual_configuration_update_configuration(
AXIS_DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
mock_vapix_requests("2.3.4.5")
@ -114,7 +114,7 @@ async def test_manual_configuration_update_configuration(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert mock_config_entry.data[CONF_HOST] == "2.3.4.5"
@ -125,7 +125,7 @@ async def test_flow_fails_faulty_credentials(hass: HomeAssistant) -> None:
AXIS_DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with patch(
@ -152,7 +152,7 @@ async def test_flow_fails_cannot_connect(hass: HomeAssistant) -> None:
AXIS_DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with patch(
@ -192,7 +192,7 @@ async def test_flow_create_entry_multiple_existing_entries_of_same_model(
AXIS_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(
@ -206,7 +206,7 @@ async def test_flow_create_entry_multiple_existing_entries_of_same_model(
},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"M1065-LW - {MAC}"
assert result["data"] == {
CONF_PROTOCOL: "http",
@ -235,7 +235,7 @@ async def test_reauth_flow_update_configuration(
data=mock_config_entry.data,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
mock_vapix_requests("2.3.4.5")
@ -251,7 +251,7 @@ async def test_reauth_flow_update_configuration(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert mock_config_entry.data[CONF_PROTOCOL] == "https"
assert mock_config_entry.data[CONF_HOST] == "2.3.4.5"
@ -276,7 +276,7 @@ async def test_reconfiguration_flow_update_configuration(
},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
mock_vapix_requests("2.3.4.5")
@ -289,7 +289,7 @@ async def test_reconfiguration_flow_update_configuration(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert mock_config_entry.data[CONF_PROTOCOL] == "http"
assert mock_config_entry.data[CONF_HOST] == "2.3.4.5"
@ -374,7 +374,7 @@ async def test_discovery_flow(
AXIS_DOMAIN, data=discovery_info, context={"source": source}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
flows = hass.config_entries.flow.async_progress()
@ -392,7 +392,7 @@ async def test_discovery_flow(
},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == f"M1065-LW - {MAC}"
assert result["data"] == {
CONF_PROTOCOL: "http",
@ -454,7 +454,7 @@ async def test_discovered_device_already_configured(
AXIS_DOMAIN, data=discovery_info, context={"source": source}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert mock_config_entry.data[CONF_HOST] == DEFAULT_HOST
@ -523,7 +523,7 @@ async def test_discovery_flow_updated_configuration(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert mock_config_entry.data == {
CONF_HOST: "2.3.4.5",
@ -580,7 +580,7 @@ async def test_discovery_flow_ignore_non_axis_device(
AXIS_DOMAIN, data=discovery_info, context={"source": source}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_axis_device"
@ -629,7 +629,7 @@ async def test_discovery_flow_ignore_link_local_address(
AXIS_DOMAIN, data=discovery_info, context={"source": source}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "link_local_address"
@ -640,7 +640,7 @@ async def test_option_flow(hass: HomeAssistant, setup_config_entry) -> None:
result = await hass.config_entries.options.async_init(setup_config_entry.entry_id)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "configure_stream"
assert set(result["data_schema"].schema[CONF_STREAM_PROFILE].container) == {
DEFAULT_STREAM_PROFILE,
@ -657,7 +657,7 @@ async def test_option_flow(hass: HomeAssistant, setup_config_entry) -> None:
user_input={CONF_STREAM_PROFILE: "profile_1", CONF_VIDEO_SOURCE: 1},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
CONF_STREAM_PROFILE: "profile_1",
CONF_VIDEO_SOURCE: 1,

View File

@ -5,9 +5,10 @@ from unittest.mock import AsyncMock
from aioazuredevops.core import DevOpsProject
import aiohttp
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.azure_devops.const import CONF_ORG, CONF_PROJECT, DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import FIXTURE_REAUTH_INPUT, FIXTURE_USER_INPUT
@ -20,7 +21,7 @@ async def test_show_user_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
@ -37,7 +38,7 @@ async def test_authorization_error(
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result2 = await hass.config_entries.flow.async_configure(
@ -46,7 +47,7 @@ async def test_authorization_error(
)
await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "user"
assert result2["errors"] == {"base": "invalid_auth"}
@ -65,7 +66,7 @@ async def test_reauth_authorization_error(
data=FIXTURE_USER_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth"
result2 = await hass.config_entries.flow.async_configure(
@ -74,7 +75,7 @@ async def test_reauth_authorization_error(
)
await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "reauth"
assert result2["errors"] == {"base": "invalid_auth"}
@ -92,7 +93,7 @@ async def test_connection_error(
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result2 = await hass.config_entries.flow.async_configure(
@ -101,7 +102,7 @@ async def test_connection_error(
)
await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "user"
assert result2["errors"] == {"base": "cannot_connect"}
@ -120,7 +121,7 @@ async def test_reauth_connection_error(
data=FIXTURE_USER_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth"
result2 = await hass.config_entries.flow.async_configure(
@ -129,7 +130,7 @@ async def test_reauth_connection_error(
)
await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "reauth"
assert result2["errors"] == {"base": "cannot_connect"}
@ -148,7 +149,7 @@ async def test_project_error(
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result2 = await hass.config_entries.flow.async_configure(
@ -157,7 +158,7 @@ async def test_project_error(
)
await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "user"
assert result2["errors"] == {"base": "project_error"}
@ -180,7 +181,7 @@ async def test_reauth_project_error(
data=FIXTURE_USER_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth"
result2 = await hass.config_entries.flow.async_configure(
@ -189,7 +190,7 @@ async def test_reauth_project_error(
)
await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "reauth"
assert result2["errors"] == {"base": "project_error"}
@ -211,7 +212,7 @@ async def test_reauth_flow(
data=FIXTURE_USER_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth"
assert result["errors"] == {"base": "invalid_auth"}
@ -227,7 +228,7 @@ async def test_reauth_flow(
)
await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "reauth_successful"
@ -242,7 +243,7 @@ async def test_full_flow_implementation(
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result2 = await hass.config_entries.flow.async_configure(
@ -252,7 +253,7 @@ async def test_full_flow_implementation(
await hass.async_block_till_done()
assert len(mock_setup_entry.mock_calls) == 1
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert (
result2["title"]
== f"{FIXTURE_USER_INPUT[CONF_ORG]}/{FIXTURE_USER_INPUT[CONF_PROJECT]}"

View File

@ -6,7 +6,7 @@ from unittest.mock import AsyncMock
from azure.eventhub.exceptions import EventHubError
import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.azure_event_hub.const import (
CONF_MAX_DELAY,
CONF_SEND_INTERVAL,
@ -15,6 +15,7 @@ from homeassistant.components.azure_event_hub.const import (
STEP_SAS,
)
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .const import (
BASE_CONFIG_CS,
@ -68,7 +69,7 @@ async def test_form(
result2["flow_id"],
step2_config.copy(),
)
assert result3["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "test-instance"
assert result3["data"] == data_config
mock_setup_entry.assert_called_once()
@ -84,7 +85,7 @@ async def test_import(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
data=IMPORT_CONFIG.copy(),
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "test-instance"
options = {
CONF_SEND_INTERVAL: import_config.pop(CONF_SEND_INTERVAL),
@ -114,7 +115,7 @@ async def test_single_instance(hass: HomeAssistant, source) -> None:
context={"source": source},
data=BASE_CONFIG_CS.copy(),
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "single_instance_allowed"
@ -143,7 +144,7 @@ async def test_connection_error_sas(
result["flow_id"],
SAS_CONFIG.copy(),
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": error_message}
@ -173,7 +174,7 @@ async def test_connection_error_cs(
result["flow_id"],
CS_CONFIG.copy(),
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": error_message}
@ -181,13 +182,13 @@ async def test_options_flow(hass: HomeAssistant, entry) -> None:
"""Test options flow."""
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"
assert result["last_step"]
updated = await hass.config_entries.options.async_configure(
result["flow_id"], UPDATE_OPTIONS
)
assert updated["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert updated["type"] is FlowResultType.CREATE_ENTRY
assert updated["data"] == UPDATE_OPTIONS
await hass.async_block_till_done()

View File

@ -46,7 +46,7 @@ async def test_form_user(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == MOCK_NAME
assert result2["data"] == {CONF_IP_ADDRESS: "127.0.0.1"}
assert len(mock_setup_entry.mock_calls) == 1
@ -64,7 +64,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
{CONF_IP_ADDRESS: "127.0.0.1"},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {CONF_IP_ADDRESS: "cannot_connect"}
@ -80,7 +80,7 @@ async def test_form_unknown_exception(hass: HomeAssistant) -> None:
{CONF_IP_ADDRESS: "127.0.0.1"},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"}
@ -100,7 +100,7 @@ async def test_zeroconf_discovery(hass: HomeAssistant) -> None:
type="mock_type",
),
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
with patch(
@ -138,7 +138,7 @@ async def test_zeroconf_updates_existing_ip(hass: HomeAssistant) -> None:
type="mock_type",
),
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert entry.data[CONF_IP_ADDRESS] == "127.0.0.1"
@ -158,7 +158,7 @@ async def test_zeroconf_rejects_ipv6(hass: HomeAssistant) -> None:
type="mock_type",
),
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "ipv6_not_supported"
@ -177,7 +177,7 @@ async def test_user_flow_is_not_blocked_by_discovery(hass: HomeAssistant) -> Non
type="mock_type",
),
)
assert discovery_result["type"] == FlowResultType.FORM
assert discovery_result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
@ -198,7 +198,7 @@ async def test_user_flow_is_not_blocked_by_discovery(hass: HomeAssistant) -> Non
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == MOCK_NAME
assert result2["data"] == {CONF_IP_ADDRESS: "127.0.0.1"}
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -4,7 +4,7 @@ from unittest.mock import MagicMock, patch
from pybalboa.exceptions import SpaConnectionError
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.balboa.const import CONF_SYNC_TIME, DOMAIN
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
@ -23,7 +23,7 @@ async def test_form(hass: HomeAssistant, client: MagicMock) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
with (
@ -42,7 +42,7 @@ async def test_form(hass: HomeAssistant, client: MagicMock) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == TEST_DATA
assert len(mock_setup_entry.mock_calls) == 1
@ -62,7 +62,7 @@ async def test_form_cannot_connect(hass: HomeAssistant, client: MagicMock) -> No
result["flow_id"], TEST_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"}
@ -81,7 +81,7 @@ async def test_form_spa_not_configured(hass: HomeAssistant, client: MagicMock) -
result["flow_id"], TEST_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"}
@ -101,7 +101,7 @@ async def test_unknown_error(hass: HomeAssistant, client: MagicMock) -> None:
TEST_DATA,
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"}
@ -113,7 +113,7 @@ async def test_already_configured(hass: HomeAssistant, client: MagicMock) -> Non
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with (
@ -132,7 +132,7 @@ async def test_already_configured(hass: HomeAssistant, client: MagicMock) -> Non
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured"
@ -146,7 +146,7 @@ async def test_options_flow(hass: HomeAssistant, client: MagicMock) -> None:
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"
with patch(
@ -159,5 +159,5 @@ async def test_options_flow(hass: HomeAssistant, client: MagicMock) -> None:
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert dict(config_entry.options) == {CONF_SYNC_TIME: True}

View File

@ -35,7 +35,7 @@ async def test_config_flow_timeout_error(
context={CONF_SOURCE: SOURCE_USER},
data=TEST_DATA_USER,
)
assert result_user["type"] == FlowResultType.FORM
assert result_user["type"] is FlowResultType.FORM
assert result_user["errors"] == {"base": "timeout_error"}
assert mock_mozart_client.get_beolink_self.call_count == 1
@ -54,7 +54,7 @@ async def test_config_flow_client_connector_error(
context={CONF_SOURCE: SOURCE_USER},
data=TEST_DATA_USER,
)
assert result_user["type"] == FlowResultType.FORM
assert result_user["type"] is FlowResultType.FORM
assert result_user["errors"] == {"base": "client_connector_error"}
assert mock_mozart_client.get_beolink_self.call_count == 1
@ -68,7 +68,7 @@ async def test_config_flow_invalid_ip(hass: HomeAssistant) -> None:
context={CONF_SOURCE: SOURCE_USER},
data=TEST_DATA_USER_INVALID,
)
assert result_user["type"] == FlowResultType.FORM
assert result_user["type"] is FlowResultType.FORM
assert result_user["errors"] == {"base": "invalid_ip"}
@ -83,7 +83,7 @@ async def test_config_flow_api_exception(
context={CONF_SOURCE: SOURCE_USER},
data=TEST_DATA_USER,
)
assert result_user["type"] == FlowResultType.FORM
assert result_user["type"] is FlowResultType.FORM
assert result_user["errors"] == {"base": "api_exception"}
assert mock_mozart_client.get_beolink_self.call_count == 1
@ -98,7 +98,7 @@ async def test_config_flow(hass: HomeAssistant, mock_mozart_client) -> None:
data=None,
)
assert result_init["type"] == FlowResultType.FORM
assert result_init["type"] is FlowResultType.FORM
assert result_init["step_id"] == "user"
result_user = await hass.config_entries.flow.async_configure(
@ -106,7 +106,7 @@ async def test_config_flow(hass: HomeAssistant, mock_mozart_client) -> None:
user_input=TEST_DATA_USER,
)
assert result_user["type"] == FlowResultType.CREATE_ENTRY
assert result_user["type"] is FlowResultType.CREATE_ENTRY
assert result_user["data"] == TEST_DATA_CREATE_ENTRY
assert mock_mozart_client.get_beolink_self.call_count == 1
@ -121,7 +121,7 @@ async def test_config_flow_zeroconf(hass: HomeAssistant, mock_mozart_client) ->
data=TEST_DATA_ZEROCONF,
)
assert result_zeroconf["type"] == FlowResultType.FORM
assert result_zeroconf["type"] is FlowResultType.FORM
assert result_zeroconf["step_id"] == "zeroconf_confirm"
result_confirm = await hass.config_entries.flow.async_configure(
@ -129,7 +129,7 @@ async def test_config_flow_zeroconf(hass: HomeAssistant, mock_mozart_client) ->
user_input=TEST_DATA_USER,
)
assert result_confirm["type"] == FlowResultType.CREATE_ENTRY
assert result_confirm["type"] is FlowResultType.CREATE_ENTRY
assert result_confirm["data"] == TEST_DATA_CREATE_ENTRY
assert mock_mozart_client.get_beolink_self.call_count == 0
@ -144,7 +144,7 @@ async def test_config_flow_zeroconf_not_mozart_device(hass: HomeAssistant) -> No
data=TEST_DATA_ZEROCONF_NOT_MOZART,
)
assert result_user["type"] == FlowResultType.ABORT
assert result_user["type"] is FlowResultType.ABORT
assert result_user["reason"] == "not_mozart_device"
@ -157,5 +157,5 @@ async def test_config_flow_zeroconf_ipv6(hass: HomeAssistant) -> None:
data=TEST_DATA_ZEROCONF_IPV6,
)
assert result_user["type"] == FlowResultType.ABORT
assert result_user["type"] is FlowResultType.ABORT
assert result_user["reason"] == "ipv6_address"

View File

@ -6,7 +6,7 @@ from unittest.mock import DEFAULT, AsyncMock, PropertyMock, patch
import blebox_uniapi
import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.components.blebox import config_flow
from homeassistant.const import CONF_IP_ADDRESS
@ -189,7 +189,7 @@ async def test_already_configured(hass: HomeAssistant, valid_feature_mock) -> No
context={"source": config_entries.SOURCE_USER},
data={config_flow.CONF_HOST: "172.2.3.4", config_flow.CONF_PORT: 80},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "address_already_configured"
@ -238,13 +238,13 @@ async def test_flow_with_zeroconf(hass: HomeAssistant) -> None:
),
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
with patch("homeassistant.components.blebox.async_setup_entry", return_value=True):
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == {"host": "172.100.123.4", "port": 80}
@ -278,7 +278,7 @@ async def test_flow_with_zeroconf_when_already_configured(hass: HomeAssistant) -
),
)
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured"
@ -301,7 +301,7 @@ async def test_flow_with_zeroconf_when_device_unsupported(hass: HomeAssistant) -
properties={"_raw": {}},
),
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unsupported_device_version"
@ -327,5 +327,5 @@ async def test_flow_with_zeroconf_when_device_response_unsupported(
properties={"_raw": {}},
),
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unsupported_device_response"

View File

@ -5,9 +5,10 @@ from unittest.mock import patch
from blinkpy.auth import LoginError
from blinkpy.blinkpy import BlinkSetupError
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.blink import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
async def test_form(hass: HomeAssistant) -> None:
@ -295,5 +296,5 @@ async def test_reauth_shows_user_step(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_REAUTH},
data={"username": "blink@example.com", "password": "invalid_password"},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"

View File

@ -24,7 +24,7 @@ async def test_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["errors"] == {}
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
async def test_user(hass: HomeAssistant) -> None:
@ -34,7 +34,7 @@ async def test_user(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["errors"] == {}
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
with (
patch(
@ -60,7 +60,7 @@ async def test_user(hass: HomeAssistant) -> None:
assert result2["title"] == "test@email.com"
assert result2["data"] == {"api_token": "123"}
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
@pytest.mark.parametrize(
@ -85,7 +85,7 @@ async def test_flow_fails(hass: HomeAssistant, error: Exception, message: str) -
data={"api_token": "123"},
)
assert result["errors"]["base"] == message
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
with (
patch(
@ -111,7 +111,7 @@ async def test_flow_fails(hass: HomeAssistant, error: Exception, message: str) -
assert result2["title"] == "test@email.com"
assert result2["data"] == {"api_token": "123"}
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
@pytest.mark.parametrize(
@ -157,14 +157,14 @@ async def test_reauth(
data={"api_token": "123"},
)
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={"api_token": "1234567890"},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == reason
assert config_entry.data["api_token"] == expected_api_token

View File

@ -19,7 +19,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH},
data=BLUEMAESTRO_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
with patch(
"homeassistant.components.bluemaestro.async_setup_entry", return_value=True
@ -27,7 +27,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Tempo Disc THD EEFF"
assert result2["data"] == {}
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
@ -40,7 +40,7 @@ async def test_async_step_bluetooth_not_bluemaestro(hass: HomeAssistant) -> None
context={"source": config_entries.SOURCE_BLUETOOTH},
data=NOT_BLUEMAESTRO_SERVICE_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported"
@ -50,7 +50,7 @@ async def test_async_step_user_no_devices_found(hass: HomeAssistant) -> None:
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -64,7 +64,7 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with patch(
"homeassistant.components.bluemaestro.async_setup_entry", return_value=True
@ -73,7 +73,7 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
result["flow_id"],
user_input={"address": "aa:bb:cc:dd:ee:ff"},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Tempo Disc THD EEFF"
assert result2["data"] == {}
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"
@ -89,7 +89,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
entry = MockConfigEntry(
@ -105,7 +105,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
result["flow_id"],
user_input={"address": "aa:bb:cc:dd:ee:ff"},
)
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured"
@ -127,7 +127,7 @@ async def test_async_step_user_with_found_devices_already_setup(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -144,7 +144,7 @@ async def test_async_step_bluetooth_devices_already_setup(hass: HomeAssistant) -
context={"source": config_entries.SOURCE_BLUETOOTH},
data=BLUEMAESTRO_SERVICE_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -155,7 +155,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
context={"source": config_entries.SOURCE_BLUETOOTH},
data=BLUEMAESTRO_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
result = await hass.config_entries.flow.async_init(
@ -163,7 +163,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
context={"source": config_entries.SOURCE_BLUETOOTH},
data=BLUEMAESTRO_SERVICE_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress"
@ -176,7 +176,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
context={"source": config_entries.SOURCE_BLUETOOTH},
data=BLUEMAESTRO_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
with patch(
@ -187,7 +187,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
with patch(
"homeassistant.components.bluemaestro.async_setup_entry", return_value=True
@ -196,7 +196,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
result["flow_id"],
user_input={"address": "aa:bb:cc:dd:ee:ff"},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Tempo Disc THD EEFF"
assert result2["data"] == {}
assert result2["result"].unique_id == "aa:bb:cc:dd:ee:ff"

View File

@ -53,7 +53,7 @@ async def test_async_step_user_macos(hass: HomeAssistant, macos_adapter: None) -
context={"source": config_entries.SOURCE_USER},
data={},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "single_adapter"
with (
patch("homeassistant.components.bluetooth.async_setup", return_value=True),
@ -64,7 +64,7 @@ async def test_async_step_user_macos(hass: HomeAssistant, macos_adapter: None) -
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Core Bluetooth"
assert result2["data"] == {}
assert len(mock_setup_entry.mock_calls) == 1
@ -79,7 +79,7 @@ async def test_async_step_user_linux_one_adapter(
context={"source": config_entries.SOURCE_USER},
data={},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "single_adapter"
with (
patch("homeassistant.components.bluetooth.async_setup", return_value=True),
@ -90,7 +90,7 @@ async def test_async_step_user_linux_one_adapter(
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "00:00:00:00:00:01"
assert result2["data"] == {}
assert len(mock_setup_entry.mock_calls) == 1
@ -105,7 +105,7 @@ async def test_async_step_user_linux_two_adapters(
context={"source": config_entries.SOURCE_USER},
data={},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "multiple_adapters"
with (
patch("homeassistant.components.bluetooth.async_setup", return_value=True),
@ -116,7 +116,7 @@ async def test_async_step_user_linux_two_adapters(
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_ADAPTER: "hci1"}
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "00:00:00:00:00:02"
assert result2["data"] == {}
assert len(mock_setup_entry.mock_calls) == 1
@ -133,7 +133,7 @@ async def test_async_step_user_only_allows_one(
context={"source": config_entries.SOURCE_USER},
data={},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_adapters"
@ -152,7 +152,7 @@ async def test_async_step_integration_discovery(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_INTEGRATION_DISCOVERY},
data={CONF_ADAPTER: "hci0", CONF_DETAILS: details},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "single_adapter"
with (
patch("homeassistant.components.bluetooth.async_setup", return_value=True),
@ -163,7 +163,7 @@ async def test_async_step_integration_discovery(hass: HomeAssistant) -> None:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "00:00:00:00:00:01"
assert result2["data"] == {}
assert len(mock_setup_entry.mock_calls) == 1
@ -195,7 +195,7 @@ async def test_async_step_integration_discovery_during_onboarding_one_adapter(
context={"source": config_entries.SOURCE_INTEGRATION_DISCOVERY},
data={CONF_ADAPTER: "hci0", CONF_DETAILS: details},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "00:00:00:00:00:01"
assert result["data"] == {}
assert len(mock_setup_entry.mock_calls) == 1
@ -239,11 +239,11 @@ async def test_async_step_integration_discovery_during_onboarding_two_adapters(
context={"source": config_entries.SOURCE_INTEGRATION_DISCOVERY},
data={CONF_ADAPTER: "hci1", CONF_DETAILS: details2},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "00:00:00:00:00:01"
assert result["data"] == {}
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "00:00:00:00:00:02"
assert result2["data"] == {}
@ -277,7 +277,7 @@ async def test_async_step_integration_discovery_during_onboarding(
context={"source": config_entries.SOURCE_INTEGRATION_DISCOVERY},
data={CONF_ADAPTER: "Core Bluetooth", CONF_DETAILS: details},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Core Bluetooth"
assert result["data"] == {}
assert len(mock_setup_entry.mock_calls) == 1
@ -302,7 +302,7 @@ async def test_async_step_integration_discovery_already_exists(
context={"source": config_entries.SOURCE_INTEGRATION_DISCOVERY},
data={CONF_ADAPTER: "hci0", CONF_DETAILS: details},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -325,7 +325,7 @@ async def test_options_flow_linux(
await hass.async_block_till_done()
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
assert result["errors"] is None
@ -337,13 +337,13 @@ async def test_options_flow_linux(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_PASSIVE] is True
# Verify we can change it to False
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
assert result["errors"] is None
@ -355,7 +355,7 @@ async def test_options_flow_linux(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_PASSIVE] is False
await hass.config_entries.async_unload(entry.entry_id)
@ -438,6 +438,6 @@ async def test_async_step_user_linux_adapter_is_ignored(
context={"source": config_entries.SOURCE_USER},
data={},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_adapters"
assert result["description_placeholders"] == {"ignored_adapters": "1"}

View File

@ -7,7 +7,7 @@ from bimmer_connected.api.authentication import MyBMWAuthentication
from bimmer_connected.models import MyBMWAPIError, MyBMWAuthError
from httpx import RequestError
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.bmw_connected_drive.config_flow import DOMAIN
from homeassistant.components.bmw_connected_drive.const import (
CONF_READ_ONLY,
@ -15,6 +15,7 @@ from homeassistant.components.bmw_connected_drive.const import (
)
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import (
FIXTURE_CONFIG_ENTRY,
@ -41,7 +42,7 @@ async def test_show_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
@ -58,7 +59,7 @@ async def test_authentication_error(hass: HomeAssistant) -> None:
data=FIXTURE_USER_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "invalid_auth"}
@ -76,7 +77,7 @@ async def test_connection_error(hass: HomeAssistant) -> None:
data=FIXTURE_USER_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"}
@ -94,7 +95,7 @@ async def test_api_error(hass: HomeAssistant) -> None:
data=FIXTURE_USER_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"}
@ -117,7 +118,7 @@ async def test_full_user_flow_implementation(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_USER},
data=FIXTURE_USER_INPUT,
)
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == FIXTURE_COMPLETE_ENTRY[CONF_USERNAME]
assert result2["data"] == FIXTURE_COMPLETE_ENTRY
@ -143,7 +144,7 @@ async def test_options_flow_implementation(hass: HomeAssistant) -> None:
await hass.async_block_till_done()
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"] == "account_options"
result = await hass.config_entries.options.async_configure(
@ -152,7 +153,7 @@ async def test_options_flow_implementation(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_READ_ONLY: True,
}
@ -195,7 +196,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -204,7 +205,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "reauth_successful"
assert config_entry.data == FIXTURE_COMPLETE_ENTRY

View File

@ -10,7 +10,6 @@ from pybravia import (
)
import pytest
from homeassistant import data_entry_flow
from homeassistant.components import ssdp
from homeassistant.components.braviatv.const import (
CONF_NICKNAME,
@ -21,6 +20,7 @@ from homeassistant.components.braviatv.const import (
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_SSDP, SOURCE_USER
from homeassistant.const import CONF_CLIENT_ID, CONF_HOST, CONF_MAC, CONF_PIN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from homeassistant.helpers import instance_id
from tests.common import MockConfigEntry
@ -93,7 +93,7 @@ async def test_show_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
@ -105,7 +105,7 @@ async def test_ssdp_discovery(hass: HomeAssistant) -> None:
context={"source": SOURCE_SSDP},
data=BRAVIA_SSDP,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
with (
@ -122,21 +122,21 @@ async def test_ssdp_discovery(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "authorize"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_USE_PSK: False}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pin"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_PIN: "1234"}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["result"].unique_id == "very_unique_string"
assert result["title"] == "TV-Model"
assert result["data"] == {
@ -157,7 +157,7 @@ async def test_ssdp_discovery_fake(hass: HomeAssistant) -> None:
data=FAKE_BRAVIA_SSDP,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_bravia_device"
@ -181,7 +181,7 @@ async def test_ssdp_discovery_exist(hass: HomeAssistant) -> None:
data=BRAVIA_SSDP,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -261,7 +261,7 @@ async def test_no_ip_control(hass: HomeAssistant) -> None:
result["flow_id"], user_input={CONF_USE_PSK: False}
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_ip_control"
@ -298,7 +298,7 @@ async def test_duplicate_error(hass: HomeAssistant) -> None:
result["flow_id"], user_input={CONF_PIN: "1234"}
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -319,21 +319,21 @@ async def test_create_entry(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: "bravia-host"}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "authorize"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_USE_PSK: False}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "pin"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_PIN: "1234"}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["result"].unique_id == "very_unique_string"
assert result["title"] == "TV-Model"
assert result["data"] == {
@ -360,21 +360,21 @@ async def test_create_entry_psk(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}, data={CONF_HOST: "bravia-host"}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "authorize"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_USE_PSK: True}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "psk"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_PIN: "mypsk"}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["result"].unique_id == "very_unique_string"
assert result["title"] == "TV-Model"
assert result["data"] == {
@ -427,7 +427,7 @@ async def test_reauth_successful(hass: HomeAssistant, use_psk, new_pin) -> None:
data=config_entry.data,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "authorize"
result = await hass.config_entries.flow.async_configure(
@ -437,6 +437,6 @@ async def test_reauth_successful(hass: HomeAssistant, use_psk, new_pin) -> None:
result["flow_id"], user_input={CONF_PIN: new_pin}
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
assert config_entry.data[CONF_PIN] == new_pin

View File

@ -32,7 +32,7 @@ async def test_form(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
result = await hass.config_entries.flow.async_init(
@ -44,7 +44,7 @@ async def test_form(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DATA_STEP["email"]
assert result["data"] == MOCK_DATA_STEP
assert len(mock_setup_entry.mock_calls) == 1
@ -73,7 +73,7 @@ async def test_flow_user_init_data_unknown_error_and_recover(
user_input=MOCK_DATA_STEP,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"]["base"] == text_error
# Recover
@ -110,5 +110,5 @@ async def test_flow_user_init_data_already_configured(
user_input=MOCK_DATA_STEP,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"

View File

@ -7,12 +7,12 @@ from unittest.mock import patch
from brother import SnmpError, UnsupportedModelError
import pytest
from homeassistant import data_entry_flow
from homeassistant.components import zeroconf
from homeassistant.components.brother.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
from homeassistant.const import CONF_HOST, CONF_TYPE
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry, load_fixture
@ -27,7 +27,7 @@ async def test_show_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
@ -46,7 +46,7 @@ async def test_create_entry_with_hostname(hass: HomeAssistant) -> None:
data={CONF_HOST: "example.local", CONF_TYPE: "laser"},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "HL-L2340DW 0123456789"
assert result["data"][CONF_HOST] == "example.local"
assert result["data"][CONF_TYPE] == "laser"
@ -65,7 +65,7 @@ async def test_create_entry_with_ipv4_address(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "HL-L2340DW 0123456789"
assert result["data"][CONF_HOST] == "127.0.0.1"
assert result["data"][CONF_TYPE] == "laser"
@ -86,7 +86,7 @@ async def test_create_entry_with_ipv6_address(hass: HomeAssistant) -> None:
data={CONF_HOST: "2001:db8::1428:57ab", CONF_TYPE: "laser"},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "HL-L2340DW 0123456789"
assert result["data"][CONF_HOST] == "2001:db8::1428:57ab"
assert result["data"][CONF_TYPE] == "laser"
@ -140,7 +140,7 @@ async def test_unsupported_model_error(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unsupported_model"
@ -160,7 +160,7 @@ async def test_device_exists_abort(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -185,7 +185,7 @@ async def test_zeroconf_exception(hass: HomeAssistant, exc: Exception) -> None:
),
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
@ -209,7 +209,7 @@ async def test_zeroconf_unsupported_model(hass: HomeAssistant) -> None:
),
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unsupported_model"
assert len(mock_get_data.mock_calls) == 0
@ -244,7 +244,7 @@ async def test_zeroconf_device_exists_abort(hass: HomeAssistant) -> None:
),
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
# Test config entry got updated with latest IP
@ -274,7 +274,7 @@ async def test_zeroconf_no_probe_existing_device(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert len(mock_get_data.mock_calls) == 0
@ -305,13 +305,13 @@ async def test_zeroconf_confirm_create_entry(hass: HomeAssistant) -> None:
assert result["step_id"] == "zeroconf_confirm"
assert result["description_placeholders"]["model"] == "HL-L2340DW"
assert result["description_placeholders"]["serial_number"] == "0123456789"
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_TYPE: "laser"}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "HL-L2340DW 0123456789"
assert result["data"][CONF_HOST] == "127.0.0.1"
assert result["data"][CONF_TYPE] == "laser"

View File

@ -19,7 +19,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"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
result2 = await hass.config_entries.flow.async_configure(
@ -28,7 +28,7 @@ async def test_form(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Brottsplatskartan HOME"
assert result2["data"] == {
"area": None,
@ -44,7 +44,7 @@ async def test_form_location(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
result2 = await hass.config_entries.flow.async_configure(
@ -58,7 +58,7 @@ async def test_form_location(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Brottsplatskartan 59.32, 18.06"
assert result2["data"] == {
"area": None,
@ -74,7 +74,7 @@ async def test_form_area(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
result2 = await hass.config_entries.flow.async_configure(
@ -89,7 +89,7 @@ async def test_form_area(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "Brottsplatskartan Stockholms län"
assert result2["data"] == {
"latitude": None,

View File

@ -6,10 +6,11 @@ from aiohttp import ClientResponseError
from aiohttp.client_exceptions import ServerDisconnectedError
import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.brunt.const import DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@ -36,7 +37,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> 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"] == "test-username"
assert result2["data"] == CONFIG
assert len(mock_setup_entry.mock_calls) == 1
@ -58,7 +59,7 @@ async def test_form_duplicate_login(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=CONFIG
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -81,17 +82,17 @@ async def test_form_error(hass: HomeAssistant, side_effect, error_message) -> No
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=CONFIG
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": error_message}
@pytest.mark.parametrize(
("side_effect", "result_type", "password", "step_id", "reason"),
[
(None, data_entry_flow.FlowResultType.ABORT, "test", None, "reauth_successful"),
(None, FlowResultType.ABORT, "test", None, "reauth_successful"),
(
Exception,
data_entry_flow.FlowResultType.FORM,
FlowResultType.FORM,
CONFIG[CONF_PASSWORD],
"reauth_confirm",
None,
@ -118,7 +119,7 @@ async def test_reauth(
},
data=None,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
with patch(
"homeassistant.components.brunt.config_flow.BruntClientAsync.async_login",

View File

@ -26,7 +26,7 @@ async def test_full_user_flow_implementation(
context={"source": SOURCE_USER},
)
assert result.get("type") == FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
result2 = await hass.config_entries.flow.async_configure(
@ -40,7 +40,7 @@ async def test_full_user_flow_implementation(
},
)
assert result2.get("type") == FlowResultType.CREATE_ENTRY
assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == format_mac("00:80:41:19:69:90")
assert result2.get("data") == {
CONF_HOST: "127.0.0.1",
@ -64,7 +64,7 @@ async def test_show_user_form(hass: HomeAssistant) -> None:
)
assert result["step_id"] == "user"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
async def test_connection_error(
@ -86,7 +86,7 @@ async def test_connection_error(
},
)
assert result.get("type") == FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert result.get("errors") == {"base": "cannot_connect"}
assert result.get("step_id") == "user"
@ -110,5 +110,5 @@ async def test_user_device_exists_abort(
},
)
assert result.get("type") == FlowResultType.ABORT
assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured"

View File

@ -27,13 +27,13 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH},
data=TEMP_HUMI_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
with patch("homeassistant.components.bthome.async_setup_entry", return_value=True):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "ATC 18B2"
assert result2["data"] == {}
assert result2["result"].unique_id == "A4:C1:38:8D:18:B2"
@ -56,7 +56,7 @@ async def test_async_step_bluetooth_during_onboarding(hass: HomeAssistant) -> No
data=TEMP_HUMI_SERVICE_INFO,
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "ATC 18B2"
assert result["data"] == {}
assert result["result"].unique_id == "A4:C1:38:8D:18:B2"
@ -73,7 +73,7 @@ async def test_async_step_bluetooth_valid_device_with_encryption(
context={"source": config_entries.SOURCE_BLUETOOTH},
data=TEMP_HUMI_ENCRYPTED_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "get_encryption_key"
with patch("homeassistant.components.bthome.async_setup_entry", return_value=True):
@ -81,7 +81,7 @@ async def test_async_step_bluetooth_valid_device_with_encryption(
result["flow_id"],
user_input={"bindkey": "231d39c1d7cc1ab1aee224cd096db932"},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "TEST DEVICE 80A5"
assert result2["data"] == {"bindkey": "231d39c1d7cc1ab1aee224cd096db932"}
assert result2["result"].unique_id == "54:48:E6:8F:80:A5"
@ -96,14 +96,14 @@ async def test_async_step_bluetooth_valid_device_encryption_wrong_key(
context={"source": config_entries.SOURCE_BLUETOOTH},
data=TEMP_HUMI_ENCRYPTED_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "get_encryption_key"
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={"bindkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "get_encryption_key"
assert result2["errors"]["bindkey"] == "decryption_failed"
@ -113,7 +113,7 @@ async def test_async_step_bluetooth_valid_device_encryption_wrong_key(
result["flow_id"],
user_input={"bindkey": "231d39c1d7cc1ab1aee224cd096db932"},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "TEST DEVICE 80A5"
assert result2["data"] == {"bindkey": "231d39c1d7cc1ab1aee224cd096db932"}
assert result2["result"].unique_id == "54:48:E6:8F:80:A5"
@ -128,7 +128,7 @@ async def test_async_step_bluetooth_valid_device_encryption_wrong_key_length(
context={"source": config_entries.SOURCE_BLUETOOTH},
data=TEMP_HUMI_ENCRYPTED_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "get_encryption_key"
result2 = await hass.config_entries.flow.async_configure(
@ -136,7 +136,7 @@ async def test_async_step_bluetooth_valid_device_encryption_wrong_key_length(
user_input={"bindkey": "aa"},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "get_encryption_key"
assert result2["errors"]["bindkey"] == "expected_32_characters"
@ -146,7 +146,7 @@ async def test_async_step_bluetooth_valid_device_encryption_wrong_key_length(
result["flow_id"],
user_input={"bindkey": "231d39c1d7cc1ab1aee224cd096db932"},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "TEST DEVICE 80A5"
assert result2["data"] == {"bindkey": "231d39c1d7cc1ab1aee224cd096db932"}
assert result2["result"].unique_id == "54:48:E6:8F:80:A5"
@ -159,7 +159,7 @@ async def test_async_step_bluetooth_not_supported(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH},
data=NOT_BTHOME_SERVICE_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_supported"
@ -169,7 +169,7 @@ async def test_async_step_user_no_devices_found(hass: HomeAssistant) -> None:
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -186,7 +186,7 @@ async def test_async_step_user_no_devices_found_2(hass: HomeAssistant) -> None:
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -200,14 +200,14 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with patch("homeassistant.components.bthome.async_setup_entry", return_value=True):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={"address": "54:48:E6:8F:80:A5"},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "b-parasite 80A5"
assert result2["data"] == {}
assert result2["result"].unique_id == "54:48:E6:8F:80:A5"
@ -225,14 +225,14 @@ async def test_async_step_user_with_found_devices_encryption(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
result1 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={"address": "54:48:E6:8F:80:A5"},
)
assert result1["type"] == FlowResultType.FORM
assert result1["type"] is FlowResultType.FORM
assert result1["step_id"] == "get_encryption_key"
with patch("homeassistant.components.bthome.async_setup_entry", return_value=True):
@ -241,7 +241,7 @@ async def test_async_step_user_with_found_devices_encryption(
user_input={"bindkey": "231d39c1d7cc1ab1aee224cd096db932"},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "TEST DEVICE 80A5"
assert result2["data"] == {"bindkey": "231d39c1d7cc1ab1aee224cd096db932"}
assert result2["result"].unique_id == "54:48:E6:8F:80:A5"
@ -260,7 +260,7 @@ async def test_async_step_user_with_found_devices_encryption_wrong_key(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
# Pick a device
@ -268,7 +268,7 @@ async def test_async_step_user_with_found_devices_encryption_wrong_key(
result["flow_id"],
user_input={"address": "54:48:E6:8F:80:A5"},
)
assert result1["type"] == FlowResultType.FORM
assert result1["type"] is FlowResultType.FORM
assert result1["step_id"] == "get_encryption_key"
# Try an incorrect key
@ -276,7 +276,7 @@ async def test_async_step_user_with_found_devices_encryption_wrong_key(
result["flow_id"],
user_input={"bindkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "get_encryption_key"
assert result2["errors"]["bindkey"] == "decryption_failed"
@ -287,7 +287,7 @@ async def test_async_step_user_with_found_devices_encryption_wrong_key(
user_input={"bindkey": "231d39c1d7cc1ab1aee224cd096db932"},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "TEST DEVICE 80A5"
assert result2["data"] == {"bindkey": "231d39c1d7cc1ab1aee224cd096db932"}
assert result2["result"].unique_id == "54:48:E6:8F:80:A5"
@ -306,7 +306,7 @@ async def test_async_step_user_with_found_devices_encryption_wrong_key_length(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
# Select a single device
@ -314,7 +314,7 @@ async def test_async_step_user_with_found_devices_encryption_wrong_key_length(
result["flow_id"],
user_input={"address": "54:48:E6:8F:80:A5"},
)
assert result1["type"] == FlowResultType.FORM
assert result1["type"] is FlowResultType.FORM
assert result1["step_id"] == "get_encryption_key"
# Try an incorrect key
@ -323,7 +323,7 @@ async def test_async_step_user_with_found_devices_encryption_wrong_key_length(
user_input={"bindkey": "aa"},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "get_encryption_key"
assert result2["errors"]["bindkey"] == "expected_32_characters"
@ -334,7 +334,7 @@ async def test_async_step_user_with_found_devices_encryption_wrong_key_length(
user_input={"bindkey": "231d39c1d7cc1ab1aee224cd096db932"},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "TEST DEVICE 80A5"
assert result2["data"] == {"bindkey": "231d39c1d7cc1ab1aee224cd096db932"}
assert result2["result"].unique_id == "54:48:E6:8F:80:A5"
@ -350,7 +350,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
entry = MockConfigEntry(
@ -364,7 +364,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
result["flow_id"],
user_input={"address": "A4:C1:38:8D:18:B2"},
)
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured"
@ -386,7 +386,7 @@ async def test_async_step_user_with_found_devices_already_setup(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -403,7 +403,7 @@ async def test_async_step_bluetooth_devices_already_setup(hass: HomeAssistant) -
context={"source": config_entries.SOURCE_BLUETOOTH},
data=PRST_SERVICE_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -414,7 +414,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
context={"source": config_entries.SOURCE_BLUETOOTH},
data=PRST_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
result = await hass.config_entries.flow.async_init(
@ -422,7 +422,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
context={"source": config_entries.SOURCE_BLUETOOTH},
data=PRST_SERVICE_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress"
@ -435,7 +435,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
context={"source": config_entries.SOURCE_BLUETOOTH},
data=PRST_SERVICE_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
with patch(
@ -446,14 +446,14 @@ async def test_async_step_user_takes_precedence_over_discovery(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
with patch("homeassistant.components.bthome.async_setup_entry", return_value=True):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={"address": "54:48:E6:8F:80:A5"},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "b-parasite 80A5"
assert result2["data"] == {}
assert result2["result"].unique_id == "54:48:E6:8F:80:A5"
@ -498,7 +498,7 @@ async def test_async_step_reauth(hass: HomeAssistant) -> None:
result["flow_id"],
user_input={"bindkey": "231d39c1d7cc1ab1aee224cd096db932"},
)
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "reauth_successful"
@ -538,7 +538,7 @@ async def test_async_step_reauth_wrong_key(hass: HomeAssistant) -> None:
result["flow_id"],
user_input={"bindkey": "5b51a7c91cde6707c9ef18dada143a58"},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "get_encryption_key"
assert result2["errors"]["bindkey"] == "decryption_failed"
@ -546,7 +546,7 @@ async def test_async_step_reauth_wrong_key(hass: HomeAssistant) -> None:
result["flow_id"],
user_input={"bindkey": "231d39c1d7cc1ab1aee224cd096db932"},
)
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "reauth_successful"
@ -574,5 +574,5 @@ async def test_async_step_reauth_abort_early(hass: HomeAssistant) -> None:
data=entry.data | {"device": device},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"

View File

@ -2,10 +2,11 @@
import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.buienradar.const import DOMAIN
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@ -92,7 +93,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
user_input={"country_code": "BE", "delta": 450, "timeframe": 30},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
await hass.async_block_till_done()

View File

@ -35,7 +35,7 @@ async def test_form(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result.get("type") == FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert not result.get("errors")
result2 = await hass.config_entries.flow.async_configure(
@ -49,7 +49,7 @@ async def test_form(
)
await hass.async_block_till_done()
assert result2.get("type") == FlowResultType.CREATE_ENTRY
assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == TEST_USERNAME
assert result2.get("data") == {
CONF_URL: TEST_URL,
@ -93,7 +93,7 @@ async def test_caldav_client_error(
)
await hass.async_block_till_done()
assert result2.get("type") == FlowResultType.FORM
assert result2.get("type") is FlowResultType.FORM
assert result2.get("errors") == {"base": expected_error}
@ -124,7 +124,7 @@ async def test_reauth_success(
)
await hass.async_block_till_done()
assert result2.get("type") == FlowResultType.ABORT
assert result2.get("type") is FlowResultType.ABORT
assert result2.get("reason") == "reauth_successful"
# Verify updated configuration entry
@ -167,7 +167,7 @@ async def test_reauth_failure(
)
await hass.async_block_till_done()
assert result2.get("type") == FlowResultType.FORM
assert result2.get("type") is FlowResultType.FORM
assert result2.get("errors") == {"base": "cannot_connect"}
# Complete the form and it succeeds this time
@ -180,7 +180,7 @@ async def test_reauth_failure(
)
await hass.async_block_till_done()
assert result2.get("type") == FlowResultType.ABORT
assert result2.get("type") is FlowResultType.ABORT
assert result2.get("reason") == "reauth_successful"
# Verify updated configuration entry
@ -223,7 +223,7 @@ async def test_multiple_config_entries(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result.get("type") == FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert not result.get("errors")
result2 = await hass.config_entries.flow.async_configure(
@ -232,7 +232,7 @@ async def test_multiple_config_entries(
)
await hass.async_block_till_done()
assert result2.get("type") == FlowResultType.CREATE_ENTRY
assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == user_input[CONF_USERNAME]
assert result2.get("data") == {
**user_input,
@ -271,7 +271,7 @@ async def test_duplicate_config_entries(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result.get("type") == FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert not result.get("errors")
result2 = await hass.config_entries.flow.async_configure(
@ -280,5 +280,5 @@ async def test_duplicate_config_entries(
)
await hass.async_block_till_done()
assert result2.get("type") == FlowResultType.ABORT
assert result2.get("type") is FlowResultType.ABORT
assert result2.get("reason") == "already_configured"

View File

@ -24,7 +24,7 @@ async def test_user_form(hass: HomeAssistant, canary_config_flow) -> None:
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["errors"] == {}
with (
@ -37,7 +37,7 @@ async def test_user_form(hass: HomeAssistant, canary_config_flow) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "test-username"
assert result["data"] == {**USER_INPUT, CONF_TIMEOUT: DEFAULT_TIMEOUT}
@ -60,7 +60,7 @@ async def test_user_form_cannot_connect(
USER_INPUT,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"}
canary_config_flow.side_effect = ConnectTimeout()
@ -70,7 +70,7 @@ async def test_user_form_cannot_connect(
USER_INPUT,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"}
@ -89,7 +89,7 @@ async def test_user_form_unexpected_exception(
USER_INPUT,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown"
@ -104,7 +104,7 @@ async def test_user_form_single_instance_allowed(
context={"source": SOURCE_USER},
data=USER_INPUT,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "single_instance_allowed"
@ -117,7 +117,7 @@ async def test_options_flow(hass: HomeAssistant, canary) -> None:
assert entry.options[CONF_TIMEOUT] == DEFAULT_TIMEOUT
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
with _patch_async_setup(), _patch_async_setup_entry():
@ -127,6 +127,6 @@ async def test_options_flow(hass: HomeAssistant, canary) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_FFMPEG_ARGUMENTS] == "-v"
assert result["data"][CONF_TIMEOUT] == 7

View File

@ -4,10 +4,11 @@ from unittest.mock import ANY, patch
import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components import cast
from homeassistant.components.cast.home_assistant_cast import CAST_USER_NAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@ -29,10 +30,10 @@ async def test_creating_entry_sets_up_media_player(hass: HomeAssistant) -> None:
)
# Confirmation form
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
await hass.async_block_till_done()
@ -194,7 +195,7 @@ async def test_option_flow(hass: HomeAssistant, parameter_data) -> None:
# Test ignore_cec and uuid options are hidden if advanced options are disabled
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"] == "basic_options"
data_schema = result["data_schema"].schema
assert set(data_schema) == {"known_hosts"}
@ -205,7 +206,7 @@ async def test_option_flow(hass: HomeAssistant, parameter_data) -> None:
result = await hass.config_entries.options.async_init(
config_entry.entry_id, context=context
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "basic_options"
data_schema = result["data_schema"].schema
for other_param in basic_parameters:
@ -222,7 +223,7 @@ async def test_option_flow(hass: HomeAssistant, parameter_data) -> None:
result["flow_id"],
user_input=user_input_dict,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "advanced_options"
for other_param in basic_parameters:
if other_param == parameter:
@ -247,7 +248,7 @@ async def test_option_flow(hass: HomeAssistant, parameter_data) -> None:
result["flow_id"],
user_input=user_input_dict,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] is None
for other_param in advanced_parameters:
if other_param == parameter:
@ -261,7 +262,7 @@ async def test_option_flow(hass: HomeAssistant, parameter_data) -> None:
result["flow_id"],
user_input={"known_hosts": ""},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] is None
expected_data = {**orig_data, "known_hosts": []}
if parameter in advanced_parameters:

View File

@ -16,7 +16,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
with patch(
@ -31,7 +31,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "1.1.1.1"
assert result2["data"] == {
CONF_HOST: "1.1.1.1",
@ -47,7 +47,7 @@ async def test_form_invalid_host(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
with patch(
@ -62,7 +62,7 @@ async def test_form_invalid_host(
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"}
assert len(mock_setup_entry.mock_calls) == 0
@ -76,7 +76,7 @@ async def test_form_invalid_host(
},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
async def test_form_cannot_connect(hass: HomeAssistant) -> None:
@ -95,7 +95,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"}
with patch(
@ -108,7 +108,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
async def test_form_unexpected_error(hass: HomeAssistant) -> None:
@ -128,7 +128,7 @@ async def test_form_unexpected_error(hass: HomeAssistant) -> None:
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "unknown"}
with patch(
@ -141,7 +141,7 @@ async def test_form_unexpected_error(hass: HomeAssistant) -> None:
},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
async def test_duplicate_host(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
@ -168,5 +168,5 @@ async def test_duplicate_host(hass: HomeAssistant, mock_setup_entry: AsyncMock)
},
)
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured"

View File

@ -6,10 +6,11 @@ from unittest.mock import patch
import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.cert_expiry.const import DEFAULT_PORT, DOMAIN
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .const import HOST, PORT
from .helpers import future_timestamp
@ -24,7 +25,7 @@ async def test_user(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["step_id"] == "user"
with patch(
@ -33,7 +34,7 @@ async def test_user(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: HOST, CONF_PORT: PORT}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == HOST
assert result["data"][CONF_HOST] == HOST
assert result["data"][CONF_PORT] == PORT
@ -45,7 +46,7 @@ async def test_user_with_bad_cert(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["step_id"] == "user"
with patch(
@ -56,7 +57,7 @@ async def test_user_with_bad_cert(hass: HomeAssistant) -> None:
result["flow_id"], user_input={CONF_HOST: HOST, CONF_PORT: PORT}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == HOST
assert result["data"][CONF_HOST] == HOST
assert result["data"][CONF_PORT] == PORT
@ -81,7 +82,7 @@ async def test_import_host_only(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["title"] == HOST
assert result["data"][CONF_HOST] == HOST
assert result["data"][CONF_PORT] == DEFAULT_PORT
@ -106,7 +107,7 @@ async def test_import_host_and_port(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["title"] == HOST
assert result["data"][CONF_HOST] == HOST
assert result["data"][CONF_PORT] == PORT
@ -131,7 +132,7 @@ async def test_import_non_default_port(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["title"] == f"{HOST}:888"
assert result["data"][CONF_HOST] == HOST
assert result["data"][CONF_PORT] == 888
@ -156,7 +157,7 @@ async def test_import_with_name(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["title"] == HOST
assert result["data"][CONF_HOST] == HOST
assert result["data"][CONF_PORT] == PORT
@ -175,7 +176,7 @@ async def test_bad_import(hass: HomeAssistant) -> None:
data={CONF_HOST: HOST},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "import_failed"
@ -192,7 +193,7 @@ async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_IMPORT},
data={CONF_HOST: HOST, CONF_PORT: PORT},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
result = await hass.config_entries.flow.async_init(
@ -200,7 +201,7 @@ async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_USER},
data={CONF_HOST: HOST, CONF_PORT: PORT},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -217,7 +218,7 @@ async def test_abort_on_socket_failed(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: HOST}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {CONF_HOST: "resolve_failed"}
with patch(
@ -227,7 +228,7 @@ async def test_abort_on_socket_failed(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: HOST}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {CONF_HOST: "connection_timeout"}
with patch(
@ -237,5 +238,5 @@ async def test_abort_on_socket_failed(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: HOST}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {CONF_HOST: "connection_refused"}

View File

@ -25,7 +25,7 @@ async def test_user_form(hass: HomeAssistant, cfupdate_flow) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -35,7 +35,7 @@ async def test_user_form(hass: HomeAssistant, cfupdate_flow) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "zone"
assert result["errors"] == {}
@ -45,7 +45,7 @@ async def test_user_form(hass: HomeAssistant, cfupdate_flow) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "records"
assert result["errors"] is None
@ -56,7 +56,7 @@ async def test_user_form(hass: HomeAssistant, cfupdate_flow) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == USER_INPUT_ZONE[CONF_ZONE]
assert result["data"]
@ -84,7 +84,7 @@ async def test_user_form_cannot_connect(hass: HomeAssistant, cfupdate_flow) -> N
USER_INPUT,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"}
@ -102,7 +102,7 @@ async def test_user_form_invalid_auth(hass: HomeAssistant, cfupdate_flow) -> Non
USER_INPUT,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "invalid_auth"}
@ -122,7 +122,7 @@ async def test_user_form_unexpected_exception(
USER_INPUT,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "unknown"}
@ -136,7 +136,7 @@ async def test_user_form_single_instance_allowed(hass: HomeAssistant) -> None:
context={CONF_SOURCE: SOURCE_USER},
data=USER_INPUT,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "single_instance_allowed"
@ -154,7 +154,7 @@ async def test_reauth_flow(hass: HomeAssistant, cfupdate_flow) -> None:
},
data=entry.data,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
with _patch_async_setup_entry() as mock_setup_entry:
@ -164,7 +164,7 @@ async def test_reauth_flow(hass: HomeAssistant, cfupdate_flow) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
assert entry.data[CONF_API_TOKEN] == "other_token"

View File

@ -26,7 +26,7 @@ async def test_form_home(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
with patch(
@ -42,7 +42,7 @@ async def test_form_home(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "CO2 Signal"
assert result2["data"] == {
"api_key": "api_key",
@ -57,7 +57,7 @@ async def test_form_coordinates(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure(
@ -67,7 +67,7 @@ async def test_form_coordinates(hass: HomeAssistant) -> None:
"api_key": "api_key",
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
with patch(
"homeassistant.components.co2signal.async_setup_entry",
@ -82,7 +82,7 @@ async def test_form_coordinates(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result3["type"] == FlowResultType.CREATE_ENTRY
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "12.3, 45.6"
assert result3["data"] == {
"latitude": 12.3,
@ -99,7 +99,7 @@ async def test_form_country(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
result2 = await hass.config_entries.flow.async_configure(
@ -109,7 +109,7 @@ async def test_form_country(hass: HomeAssistant) -> None:
"api_key": "api_key",
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
with patch(
"homeassistant.components.co2signal.async_setup_entry",
@ -123,7 +123,7 @@ async def test_form_country(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result3["type"] == FlowResultType.CREATE_ENTRY
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == "fr"
assert result3["data"] == {
"country_code": "fr",
@ -167,7 +167,7 @@ async def test_form_error_handling(
},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": err_code}
# reset mock and test if now succeeds
@ -183,7 +183,7 @@ async def test_form_error_handling(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "CO2 Signal"
assert result["data"] == {
"api_key": "api_key",
@ -207,7 +207,7 @@ async def test_reauth(
data=None,
)
assert init_result["type"] == FlowResultType.FORM
assert init_result["type"] is FlowResultType.FORM
assert init_result["step_id"] == "reauth"
with patch(
@ -222,6 +222,6 @@ async def test_reauth(
)
await hass.async_block_till_done()
assert configure_result["type"] == FlowResultType.ABORT
assert configure_result["type"] is FlowResultType.ABORT
assert configure_result["reason"] == "reauth_successful"
assert len(mock_setup_entry.mock_calls) == 1

View File

@ -18,7 +18,7 @@ async def test_full_user_flow(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result.get("type") == FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
with patch(
@ -30,7 +30,7 @@ async def test_full_user_flow(hass: HomeAssistant) -> None:
user_input={},
)
assert result.get("type") == FlowResultType.CREATE_ENTRY
assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == "Color extractor"
assert result.get("data") == {}
assert result.get("options") == {}
@ -51,7 +51,7 @@ async def test_single_instance_allowed(
DOMAIN, context={"source": source}, data={}
)
assert result.get("type") == FlowResultType.ABORT
assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "single_instance_allowed"
@ -65,7 +65,7 @@ async def test_import_flow(
data={},
)
assert result.get("type") == FlowResultType.CREATE_ENTRY
assert result.get("type") is FlowResultType.CREATE_ENTRY
assert result.get("title") == "Color extractor"
assert result.get("data") == {}
assert result.get("options") == {}

View File

@ -40,13 +40,13 @@ async def test_full_flow(
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=user_input
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"][CONF_HOST] == user_input[CONF_HOST]
assert result["data"][CONF_PORT] == user_input[CONF_PORT]
assert result["data"][CONF_PIN] == user_input[CONF_PIN]
@ -70,7 +70,7 @@ async def test_exception_connection(hass: HomeAssistant, side_effect, error) ->
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result.get("type") == FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
with (
@ -89,7 +89,7 @@ async def test_exception_connection(hass: HomeAssistant, side_effect, error) ->
result["flow_id"], user_input=MOCK_USER_BRIDGE_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] is not None
assert result["errors"]["base"] == error
@ -119,7 +119,7 @@ async def test_reauth_successful(hass: HomeAssistant) -> None:
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(
@ -130,7 +130,7 @@ async def test_reauth_successful(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
@ -161,7 +161,7 @@ async def test_reauth_not_successful(hass: HomeAssistant, side_effect, error) ->
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(
@ -171,7 +171,7 @@ async def test_reauth_not_successful(hass: HomeAssistant, side_effect, error) ->
},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
assert result["errors"] is not None
assert result["errors"]["base"] == error

View File

@ -20,7 +20,7 @@ async def test_full_user_flow(
DOMAIN, context={"source": SOURCE_USER}
)
assert result.get("type") == FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
result2 = await hass.config_entries.flow.async_configure(
@ -28,7 +28,7 @@ async def test_full_user_flow(
user_input={},
)
assert result2.get("type") == FlowResultType.CREATE_ENTRY
assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == "CPU Speed"
assert result2.get("data") == {}
@ -49,7 +49,7 @@ async def test_already_configured(
DOMAIN, context={"source": SOURCE_USER}
)
assert result.get("type") == FlowResultType.ABORT
assert result.get("type") is FlowResultType.ABORT
assert result.get("reason") == "already_configured"
assert len(mock_setup_entry.mock_calls) == 0
@ -66,7 +66,7 @@ async def test_not_compatible(
DOMAIN, context={"source": SOURCE_USER}
)
assert result.get("type") == FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
mock_cpuinfo_config_flow.return_value = {}
@ -75,7 +75,7 @@ async def test_not_compatible(
user_input={},
)
assert result2.get("type") == FlowResultType.ABORT
assert result2.get("type") is FlowResultType.ABORT
assert result2.get("reason") == "not_compatible"
assert len(mock_setup_entry.mock_calls) == 0

View File

@ -14,7 +14,6 @@ from crownstone_cloud.exceptions import (
import pytest
from serial.tools.list_ports_common import ListPortInfo
from homeassistant import data_entry_flow
from homeassistant.components import usb
from homeassistant.components.crownstone.const import (
CONF_USB_MANUAL_PATH,
@ -28,6 +27,7 @@ from homeassistant.components.crownstone.const import (
)
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@ -186,7 +186,7 @@ async def test_no_user_input(
DOMAIN, context={"source": "user"}
)
# show the login form
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert crownstone_setup.call_count == 0
@ -216,7 +216,7 @@ async def test_abort_if_configured(
result = await start_config_flow(hass, get_mocked_crownstone_cloud())
# test if we abort if we try to configure the same entry
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert crownstone_setup.call_count == 0
@ -233,7 +233,7 @@ async def test_authentication_errors(
result = await start_config_flow(hass, cloud)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "invalid_auth"}
# side effect: auth error account not verified
@ -243,7 +243,7 @@ async def test_authentication_errors(
result = await start_config_flow(hass, cloud)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "account_not_verified"}
assert crownstone_setup.call_count == 0
@ -258,7 +258,7 @@ async def test_unknown_error(
result = await start_config_flow(hass, cloud)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "unknown_error"}
assert crownstone_setup.call_count == 0
@ -278,14 +278,14 @@ async def test_successful_login_no_usb(
result = await start_config_flow(hass, get_mocked_crownstone_cloud())
# should show usb form
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "usb_config"
# don't setup USB dongle, create entry
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_USB_PATH: DONT_USE_USB}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == entry_data_without_usb
assert result["options"] == entry_options_without_usb
assert crownstone_setup.call_count == 1
@ -311,7 +311,7 @@ async def test_successful_login_with_usb(
hass, get_mocked_crownstone_cloud(create_mocked_spheres(2))
)
# should show usb form
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "usb_config"
assert pyserial_comports_none_types.call_count == 1
@ -331,7 +331,7 @@ async def test_successful_login_with_usb(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_USB_PATH: port_select}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "usb_sphere_config"
assert pyserial_comports_none_types.call_count == 2
assert usb_path.call_count == 1
@ -340,7 +340,7 @@ async def test_successful_login_with_usb(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_USB_SPHERE: "sphere_name_1"}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == entry_data_with_usb
assert result["options"] == entry_options_with_usb
assert crownstone_setup.call_count == 1
@ -363,7 +363,7 @@ async def test_successful_login_with_manual_usb_path(
hass, get_mocked_crownstone_cloud(create_mocked_spheres(1))
)
# should show usb form
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "usb_config"
assert pyserial_comports.call_count == 1
@ -372,7 +372,7 @@ async def test_successful_login_with_manual_usb_path(
result["flow_id"], user_input={CONF_USB_PATH: MANUAL_PATH}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "usb_manual_config"
assert pyserial_comports.call_count == 2
@ -384,7 +384,7 @@ async def test_successful_login_with_manual_usb_path(
# since we only have 1 sphere here, test that it's automatically selected and
# creating entry without asking for user input
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == entry_data_with_manual_usb
assert result["options"] == entry_options_with_manual_usb
assert crownstone_setup.call_count == 1
@ -420,7 +420,7 @@ async def test_options_flow_setup_usb(
),
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
schema = result["data_schema"].schema
@ -434,7 +434,7 @@ async def test_options_flow_setup_usb(
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={CONF_USE_USB_OPTION: True}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "usb_config"
assert pyserial_comports.call_count == 1
@ -454,7 +454,7 @@ async def test_options_flow_setup_usb(
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={CONF_USB_PATH: port_select}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "usb_sphere_config"
assert pyserial_comports.call_count == 2
assert usb_path.call_count == 1
@ -463,7 +463,7 @@ async def test_options_flow_setup_usb(
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={CONF_USB_SPHERE: "sphere_name_1"}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == create_mocked_entry_options_conf(
usb_path="/dev/serial/by-id/crownstone-usb", usb_sphere="sphere_id_1"
)
@ -497,7 +497,7 @@ async def test_options_flow_remove_usb(hass: HomeAssistant) -> None:
),
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
schema = result["data_schema"].schema
@ -514,7 +514,7 @@ async def test_options_flow_remove_usb(hass: HomeAssistant) -> None:
CONF_USB_SPHERE_OPTION: "sphere_name_0",
},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == create_mocked_entry_options_conf(
usb_path=None, usb_sphere=None
)
@ -550,13 +550,13 @@ async def test_options_flow_manual_usb_path(
),
)
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_USE_USB_OPTION: True}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "usb_config"
assert pyserial_comports.call_count == 1
@ -565,7 +565,7 @@ async def test_options_flow_manual_usb_path(
result["flow_id"], user_input={CONF_USB_PATH: MANUAL_PATH}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "usb_manual_config"
assert pyserial_comports.call_count == 2
@ -575,7 +575,7 @@ async def test_options_flow_manual_usb_path(
result["flow_id"], user_input={CONF_USB_MANUAL_PATH: path}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == create_mocked_entry_options_conf(
usb_path=path, usb_sphere="sphere_id_0"
)
@ -609,14 +609,14 @@ async def test_options_flow_change_usb_sphere(hass: HomeAssistant) -> None:
),
)
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_USE_USB_OPTION: True, CONF_USB_SPHERE_OPTION: "sphere_name_2"},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == create_mocked_entry_options_conf(
usb_path="/dev/serial/by-id/crownstone-usb", usb_sphere="sphere_id_2"
)

View File

@ -51,7 +51,7 @@ async def test_user(hass: HomeAssistant, mock_daikin) -> None:
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_init(
@ -59,7 +59,7 @@ async def test_user(hass: HomeAssistant, mock_daikin) -> None:
context={"source": SOURCE_USER},
data={CONF_HOST: HOST},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == HOST
assert result["data"][CONF_HOST] == HOST
assert result["data"][KEY_MAC] == MAC
@ -74,7 +74,7 @@ async def test_abort_if_already_setup(hass: HomeAssistant, mock_daikin) -> None:
data={CONF_HOST: HOST, KEY_MAC: MAC},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -97,7 +97,7 @@ async def test_device_abort(hass: HomeAssistant, mock_daikin, s_effect, reason)
context={"source": SOURCE_USER},
data={CONF_HOST: HOST, KEY_MAC: MAC},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": reason}
assert result["step_id"] == "user"
@ -109,7 +109,7 @@ async def test_api_password_abort(hass: HomeAssistant) -> None:
context={"source": SOURCE_USER},
data={CONF_HOST: HOST, CONF_API_KEY: "aa", CONF_PASSWORD: "aa"},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "api_password"}
assert result["step_id"] == "user"
@ -141,7 +141,7 @@ async def test_discovery_zeroconf(
context={"source": source},
data=data,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
MockConfigEntry(domain="daikin", unique_id=unique_id).add_to_hass(hass)
@ -151,7 +151,7 @@ async def test_discovery_zeroconf(
data={CONF_HOST: HOST},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
result = await hass.config_entries.flow.async_init(
@ -160,5 +160,5 @@ async def test_discovery_zeroconf(
data=data,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress"

View File

@ -57,14 +57,14 @@ async def test_flow_discovered_bridges(
DECONZ_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={CONF_HOST: "1.2.3.4"}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link"
aioclient_mock.post(
@ -77,7 +77,7 @@ async def test_flow_discovered_bridges(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == BRIDGEID
assert result["data"] == {
CONF_HOST: "1.2.3.4",
@ -104,7 +104,7 @@ async def test_flow_manual_configuration_decision(
result["flow_id"], user_input={CONF_HOST: CONF_MANUAL_INPUT}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_input"
result = await hass.config_entries.flow.async_configure(
@ -112,7 +112,7 @@ async def test_flow_manual_configuration_decision(
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link"
aioclient_mock.post(
@ -131,7 +131,7 @@ async def test_flow_manual_configuration_decision(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == BRIDGEID
assert result["data"] == {
CONF_HOST: "1.2.3.4",
@ -155,7 +155,7 @@ async def test_flow_manual_configuration(
DECONZ_DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_input"
result = await hass.config_entries.flow.async_configure(
@ -163,7 +163,7 @@ async def test_flow_manual_configuration(
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link"
aioclient_mock.post(
@ -182,7 +182,7 @@ async def test_flow_manual_configuration(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == BRIDGEID
assert result["data"] == {
CONF_HOST: "1.2.3.4",
@ -201,7 +201,7 @@ async def test_manual_configuration_after_discovery_timeout(
DECONZ_DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_input"
assert not hass.config_entries.flow._progress[result["flow_id"]].bridges
@ -216,7 +216,7 @@ async def test_manual_configuration_after_discovery_ResponseError(
DECONZ_DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_input"
assert not hass.config_entries.flow._progress[result["flow_id"]].bridges
@ -237,7 +237,7 @@ async def test_manual_configuration_update_configuration(
DECONZ_DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_input"
result = await hass.config_entries.flow.async_configure(
@ -245,7 +245,7 @@ async def test_manual_configuration_update_configuration(
user_input={CONF_HOST: "2.3.4.5", CONF_PORT: 80},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link"
aioclient_mock.post(
@ -264,7 +264,7 @@ async def test_manual_configuration_update_configuration(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry.data[CONF_HOST] == "2.3.4.5"
@ -285,7 +285,7 @@ async def test_manual_configuration_dont_update_configuration(
DECONZ_DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_input"
result = await hass.config_entries.flow.async_configure(
@ -293,7 +293,7 @@ async def test_manual_configuration_dont_update_configuration(
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link"
aioclient_mock.post(
@ -312,7 +312,7 @@ async def test_manual_configuration_dont_update_configuration(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -330,7 +330,7 @@ async def test_manual_configuration_timeout_get_bridge(
DECONZ_DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_input"
result = await hass.config_entries.flow.async_configure(
@ -338,7 +338,7 @@ async def test_manual_configuration_timeout_get_bridge(
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link"
aioclient_mock.post(
@ -353,7 +353,7 @@ async def test_manual_configuration_timeout_get_bridge(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_bridges"
@ -384,7 +384,7 @@ async def test_link_step_fails(
result["flow_id"], user_input={CONF_HOST: "1.2.3.4"}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link"
aioclient_mock.post("http://1.2.3.4:80/api", exc=raised_error)
@ -393,7 +393,7 @@ async def test_link_step_fails(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link"
assert result["errors"] == {"base": error_string}
@ -410,7 +410,7 @@ async def test_reauth_flow_update_configuration(
context={"source": SOURCE_REAUTH},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link"
new_api_key = "new_key"
@ -431,7 +431,7 @@ async def test_reauth_flow_update_configuration(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry.data[CONF_API_KEY] == new_api_key
@ -454,7 +454,7 @@ async def test_flow_ssdp_discovery(
context={"source": SOURCE_SSDP},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "link"
flows = hass.config_entries.flow.async_progress()
@ -471,7 +471,7 @@ async def test_flow_ssdp_discovery(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == BRIDGEID
assert result["data"] == {
CONF_HOST: "1.2.3.4",
@ -505,7 +505,7 @@ async def test_ssdp_discovery_update_configuration(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry.data[CONF_HOST] == "2.3.4.5"
assert len(mock_setup_entry.mock_calls) == 1
@ -531,7 +531,7 @@ async def test_ssdp_discovery_dont_update_configuration(
context={"source": SOURCE_SSDP},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry.data[CONF_HOST] == "1.2.3.4"
@ -558,7 +558,7 @@ async def test_ssdp_discovery_dont_update_existing_hassio_configuration(
context={"source": SOURCE_SSDP},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry.data[CONF_HOST] == "1.2.3.4"
@ -581,7 +581,7 @@ async def test_flow_hassio_discovery(hass: HomeAssistant) -> None:
),
context={"source": SOURCE_HASSIO},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "hassio_confirm"
assert result["description_placeholders"] == {"addon": "Mock Addon"}
@ -600,7 +600,7 @@ async def test_flow_hassio_discovery(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["result"].data == {
CONF_HOST: "mock-deconz",
CONF_PORT: 80,
@ -636,7 +636,7 @@ async def test_hassio_discovery_update_configuration(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry.data[CONF_HOST] == "2.3.4.5"
assert config_entry.data[CONF_PORT] == 8080
@ -666,7 +666,7 @@ async def test_hassio_discovery_dont_update_configuration(
context={"source": SOURCE_HASSIO},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -678,7 +678,7 @@ async def test_option_flow(
result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "deconz_devices"
result = await hass.config_entries.options.async_configure(
@ -690,7 +690,7 @@ async def test_option_flow(
},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
CONF_ALLOW_CLIP_SENSOR: False,
CONF_ALLOW_DECONZ_GROUPS: False,

View File

@ -62,7 +62,7 @@ async def test_flow_user(hass: HomeAssistant, api) -> None:
context={"source": SOURCE_USER},
data=CONF_DATA,
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == DEFAULT_NAME
assert result["data"] == CONF_DATA
@ -80,7 +80,7 @@ async def test_flow_user_already_configured(hass: HomeAssistant, api) -> None:
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=CONF_DATA
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -89,7 +89,7 @@ async def test_flow_user_cannot_connect(hass: HomeAssistant, conn_error) -> None
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=CONF_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"}
@ -99,7 +99,7 @@ async def test_flow_user_unknown_error(hass: HomeAssistant, unknown_error) -> No
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=CONF_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "unknown"}
@ -123,13 +123,13 @@ async def test_flow_reauth(hass: HomeAssistant, api) -> None:
data=CONF_DATA,
)
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=CONF_DATA,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
assert entry.data == CONF_DATA

View File

@ -4,7 +4,7 @@ from unittest.mock import patch
import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components import ssdp
from homeassistant.components.denonavr.config_flow import (
CONF_MANUFACTURER,
@ -20,6 +20,7 @@ from homeassistant.components.denonavr.config_flow import (
)
from homeassistant.const import CONF_HOST, CONF_MODEL
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@ -436,7 +437,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
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(
@ -449,7 +450,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {
CONF_SHOW_ALL_SOURCES: True,
CONF_ZONE2: True,

View File

@ -20,7 +20,7 @@ async def test_config_flow(hass: HomeAssistant, platform) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
with patch(
@ -39,7 +39,7 @@ async def test_config_flow(hass: HomeAssistant, platform) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "My derivative"
assert result["data"] == {}
assert result["options"] == {
@ -96,7 +96,7 @@ async def test_options(hass: HomeAssistant, platform) -> None:
await hass.async_block_till_done()
result = await hass.config_entries.options.async_init(config_entry.entry_id)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
schema = result["data_schema"].schema
assert get_suggested(schema, "round") == 1.0
@ -112,7 +112,7 @@ async def test_options(hass: HomeAssistant, platform) -> None:
"unit_time": "h",
},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
"name": "My derivative",
"round": 2.0,

View File

@ -31,7 +31,7 @@ async def test_show_user_form(hass: HomeAssistant) -> None:
)
assert result["step_id"] == "user"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
async def test_cannot_connect(
@ -49,7 +49,7 @@ async def test_cannot_connect(
data=user_input,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"}
@ -67,7 +67,7 @@ async def test_user_device_exists_abort(
data=user_input,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -82,7 +82,7 @@ async def test_full_user_flow_implementation(
context={CONF_SOURCE: SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
user_input = MOCK_USER_INPUT.copy()
@ -94,7 +94,7 @@ async def test_full_user_flow_implementation(
user_input=user_input,
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == NAME
assert result["data"]
@ -150,6 +150,6 @@ async def test_async_step_confirm(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=MOCK_USER_INPUT.copy()
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
assert result["errors"] == {"base": "cannot_connect"}

View File

@ -25,7 +25,7 @@ async def test_form(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["step_id"] == "user"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
await _setup(hass, result)
@ -39,7 +39,7 @@ async def test_form_invalid_credentials_user(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["step_id"] == "user"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
result = await hass.config_entries.flow.async_configure(
@ -62,7 +62,7 @@ async def test_form_already_configured(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_USER},
data={"username": "test-username", "password": "test-password"},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -72,7 +72,7 @@ async def test_form_advanced_options(hass: HomeAssistant) -> None:
DOMAIN,
context={"source": config_entries.SOURCE_USER, "show_advanced_options": True},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
with (
@ -115,7 +115,7 @@ async def test_form_zeroconf(hass: HomeAssistant) -> None:
)
assert result["step_id"] == "zeroconf_confirm"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
await _setup(hass, result)
@ -131,7 +131,7 @@ async def test_form_invalid_credentials_zeroconf(hass: HomeAssistant) -> None:
)
assert result["step_id"] == "zeroconf_confirm"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
@ -150,7 +150,7 @@ async def test_zeroconf_wrong_device(hass: HomeAssistant) -> None:
)
assert result["reason"] == "Not a devolo Home Control gateway."
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -159,7 +159,7 @@ async def test_zeroconf_wrong_device(hass: HomeAssistant) -> None:
)
assert result["reason"] == "Not a devolo Home Control gateway."
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
async def test_form_reauth(hass: HomeAssistant) -> None:
@ -180,7 +180,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
)
assert result["step_id"] == "reauth_confirm"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
with (
patch(
@ -198,7 +198,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert len(mock_setup_entry.mock_calls) == 1
@ -246,7 +246,7 @@ async def test_form_uuid_change_reauth(hass: HomeAssistant) -> None:
)
assert result["step_id"] == "reauth_confirm"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
with (
patch(
@ -264,7 +264,7 @@ async def test_form_uuid_change_reauth(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "reauth_failed"}

View File

@ -37,7 +37,7 @@ async def test_form(hass: HomeAssistant, info: dict[str, Any]) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
with patch(
@ -52,7 +52,7 @@ async def test_form(hass: HomeAssistant, info: dict[str, Any]) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["result"].unique_id == info["serial_number"]
assert result2["title"] == info["title"]
assert result2["data"] == {
@ -83,7 +83,7 @@ async def test_form_error(hass: HomeAssistant, exception_type, expected_error) -
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {CONF_BASE: expected_error}
@ -96,7 +96,7 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
)
assert result["step_id"] == "zeroconf_confirm"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["description_placeholders"] == {"host_name": "test"}
context = next(
@ -134,7 +134,7 @@ async def test_abort_zeroconf_wrong_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_ZEROCONF},
data=DISCOVERY_INFO_WRONG_DEVICE,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "home_control"
@ -158,7 +158,7 @@ async def test_abort_if_configued(hass: HomeAssistant) -> None:
},
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured"
# Abort on concurrent zeroconf discovery flow
@ -167,7 +167,7 @@ async def test_abort_if_configued(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_ZEROCONF},
data=DISCOVERY_INFO_CHANGED,
)
assert result3["type"] == FlowResultType.ABORT
assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "already_configured"
assert entry.data[CONF_IP_ADDRESS] == IP_ALT
@ -192,7 +192,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
)
assert result["step_id"] == "reauth_confirm"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
with patch(
"homeassistant.components.devolo_home_network.async_setup_entry",
@ -204,7 +204,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "reauth_successful"
assert len(mock_setup_entry.mock_calls) == 1

View File

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

View File

@ -33,7 +33,7 @@ async def test_show_user_form(hass: HomeAssistant) -> None:
)
assert result["step_id"] == "user"
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
async def test_show_ssdp_form(
@ -47,7 +47,7 @@ async def test_show_ssdp_form(
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "ssdp_confirm"
assert result["description_placeholders"] == {CONF_NAME: HOST}
@ -65,7 +65,7 @@ async def test_cannot_connect(
data=user_input,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"}
@ -83,7 +83,7 @@ async def test_ssdp_cannot_connect(
data=discovery_info,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
@ -100,7 +100,7 @@ async def test_ssdp_confirm_cannot_connect(
data=discovery_info,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "cannot_connect"
@ -117,7 +117,7 @@ async def test_user_device_exists_abort(
data=user_input,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -134,7 +134,7 @@ async def test_ssdp_device_exists_abort(
data=discovery_info,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -152,7 +152,7 @@ async def test_ssdp_with_receiver_id_device_exists_abort(
data=discovery_info,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -171,7 +171,7 @@ async def test_unknown_error(
data=user_input,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown"
@ -190,7 +190,7 @@ async def test_ssdp_unknown_error(
data=discovery_info,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown"
@ -209,7 +209,7 @@ async def test_ssdp_confirm_unknown_error(
data=discovery_info,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown"
@ -224,7 +224,7 @@ async def test_full_user_flow_implementation(
context={CONF_SOURCE: SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
user_input = MOCK_USER_INPUT.copy()
@ -234,7 +234,7 @@ async def test_full_user_flow_implementation(
user_input=user_input,
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == HOST
assert result["data"]
@ -253,7 +253,7 @@ async def test_full_ssdp_flow_implementation(
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "ssdp_confirm"
assert result["description_placeholders"] == {CONF_NAME: HOST}
@ -261,7 +261,7 @@ async def test_full_ssdp_flow_implementation(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == HOST
assert result["data"]

View File

@ -2,10 +2,11 @@
import nextcord
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.discord.const import DOMAIN
from homeassistant.const import CONF_API_TOKEN, CONF_SOURCE
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from . import (
CONF_DATA,
@ -29,7 +30,7 @@ async def test_flow_user(hass: HomeAssistant) -> None:
result["flow_id"],
user_input=CONF_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == NAME
assert result["data"] == CONF_DATA
@ -46,7 +47,7 @@ async def test_flow_user_already_configured(hass: HomeAssistant) -> None:
result["flow_id"],
user_input=CONF_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -59,7 +60,7 @@ async def test_flow_user_invalid_auth(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_USER},
data=CONF_DATA,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "invalid_auth"}
@ -68,7 +69,7 @@ async def test_flow_user_invalid_auth(hass: HomeAssistant) -> None:
result["flow_id"],
user_input=CONF_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == NAME
assert result["data"] == CONF_DATA
@ -82,7 +83,7 @@ async def test_flow_user_cannot_connect(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_USER},
data=CONF_DATA,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"}
@ -91,7 +92,7 @@ async def test_flow_user_cannot_connect(hass: HomeAssistant) -> None:
result["flow_id"],
user_input=CONF_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == NAME
assert result["data"] == CONF_DATA
@ -105,7 +106,7 @@ async def test_flow_user_unknown_error(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_USER},
data=CONF_DATA,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "unknown"}
@ -114,7 +115,7 @@ async def test_flow_user_unknown_error(hass: HomeAssistant) -> None:
result["flow_id"],
user_input=CONF_INPUT,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == NAME
assert result["data"] == CONF_DATA
@ -132,7 +133,7 @@ async def test_flow_reauth(hass: HomeAssistant) -> None:
data=entry.data,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
new_conf = {CONF_API_TOKEN: "1234567890123"}
@ -142,7 +143,7 @@ async def test_flow_reauth(hass: HomeAssistant) -> None:
result["flow_id"],
user_input=new_conf,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
assert result["errors"] == {"base": "invalid_auth"}
@ -151,6 +152,6 @@ async def test_flow_reauth(hass: HomeAssistant) -> None:
result["flow_id"],
user_input=new_conf,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
assert entry.data == CONF_DATA | new_conf

View File

@ -5,11 +5,11 @@ from unittest.mock import AsyncMock, patch
from pydiscovergy.error import DiscovergyClientError, HTTPError, InvalidLogin
import pytest
from homeassistant import data_entry_flow
from homeassistant.components.discovergy.const import DOMAIN
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@ -19,7 +19,7 @@ async def test_form(hass: HomeAssistant, discovergy: AsyncMock) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
with patch(
@ -35,7 +35,7 @@ async def test_form(hass: HomeAssistant, discovergy: AsyncMock) -> 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"] == "test@example.com"
assert result2["data"] == {
CONF_EMAIL: "test@example.com",
@ -56,7 +56,7 @@ async def test_reauth(
data=None,
)
assert init_result["type"] == data_entry_flow.FlowResultType.FORM
assert init_result["type"] is FlowResultType.FORM
assert init_result["step_id"] == "reauth"
with patch(
@ -72,7 +72,7 @@ async def test_reauth(
)
await hass.async_block_till_done()
assert configure_result["type"] == data_entry_flow.FlowResultType.ABORT
assert configure_result["type"] is FlowResultType.ABORT
assert configure_result["reason"] == "reauth_successful"
assert len(mock_setup_entry.mock_calls) == 1
@ -100,7 +100,7 @@ async def test_form_fail(
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": message}
@ -114,6 +114,6 @@ async def test_form_fail(
},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "test@example.com"
assert "errors" not in result

View File

@ -2,12 +2,12 @@
from unittest.mock import MagicMock, patch
from homeassistant import data_entry_flow
from homeassistant.components import dhcp
from homeassistant.components.dlink.const import DEFAULT_NAME, DOMAIN
from homeassistant.config_entries import SOURCE_DHCP, SOURCE_USER
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .conftest import (
CONF_DATA,
@ -35,7 +35,7 @@ async def test_flow_user(hass: HomeAssistant, mocked_plug: MagicMock) -> None:
result["flow_id"],
user_input=CONF_DATA,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == DEFAULT_NAME
assert result["data"] == CONF_DATA
@ -48,7 +48,7 @@ async def test_flow_user_already_configured(
DOMAIN, context={"source": SOURCE_USER}, data=CONF_DATA
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -62,7 +62,7 @@ async def test_flow_user_cannot_connect(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=CONF_DATA
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"]["base"] == "cannot_connect"
@ -71,7 +71,7 @@ async def test_flow_user_cannot_connect(
result["flow_id"],
user_input=CONF_DATA,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == DEFAULT_NAME
assert result["data"] == CONF_DATA
@ -85,7 +85,7 @@ async def test_flow_user_unknown_error(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=CONF_DATA
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"]["base"] == "unknown"
@ -94,7 +94,7 @@ async def test_flow_user_unknown_error(
result["flow_id"],
user_input=CONF_DATA,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == DEFAULT_NAME
assert result["data"] == CONF_DATA
@ -104,14 +104,14 @@ async def test_dhcp(hass: HomeAssistant, mocked_plug: MagicMock) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_DHCP}, data=CONF_DHCP_FLOW
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm_discovery"
with patch_config_flow(mocked_plug), _patch_setup_entry():
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=CONF_DHCP_DATA,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == DEFAULT_NAME
assert result["data"] == CONF_DATA
@ -123,14 +123,14 @@ async def test_dhcp_failed_legacy_auth(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_DHCP}, data=CONF_DHCP_FLOW
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm_discovery"
with patch_config_flow(mocked_plug_legacy_no_auth):
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=CONF_DHCP_DATA,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"]["base"] == "cannot_connect"
with patch_config_flow(mocked_plug), _patch_setup_entry():
@ -138,7 +138,7 @@ async def test_dhcp_failed_legacy_auth(
result["flow_id"],
user_input=CONF_DHCP_DATA,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == DEFAULT_NAME
assert result["data"] == CONF_DATA
@ -151,7 +151,7 @@ async def test_dhcp_already_configured(
DOMAIN, context={"source": SOURCE_DHCP}, data=CONF_DHCP_FLOW
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry.unique_id == "aabbccddeeff"
@ -168,14 +168,14 @@ async def test_dhcp_unique_id_assignment(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_DHCP}, data=dhcp_data
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm_discovery"
with patch_config_flow(mocked_plug), _patch_setup_entry():
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input=CONF_DHCP_DATA,
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == CONF_DATA | {CONF_HOST: "2.3.4.5"}
assert result["result"].unique_id == "11:22:33:44:55:66"
@ -188,6 +188,6 @@ async def test_dhcp_changed_ip(
DOMAIN, context={"source": SOURCE_DHCP}, data=CONF_DHCP_FLOW_NEW_IP
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry_with_uid.data[CONF_HOST] == "5.6.7.8"

View File

@ -112,7 +112,7 @@ async def test_user_flow_undiscovered_manual(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DLNA_DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
assert result["step_id"] == "manual"
@ -120,7 +120,7 @@ async def test_user_flow_undiscovered_manual(hass: HomeAssistant) -> None:
result["flow_id"], user_input={CONF_URL: MOCK_DEVICE_LOCATION}
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: MOCK_DEVICE_LOCATION,
@ -144,7 +144,7 @@ async def test_user_flow_discovered_manual(
result = await hass.config_entries.flow.async_init(
DLNA_DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
assert result["step_id"] == "user"
@ -152,7 +152,7 @@ async def test_user_flow_discovered_manual(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
assert result["step_id"] == "manual"
@ -160,7 +160,7 @@ async def test_user_flow_discovered_manual(
result["flow_id"], user_input={CONF_URL: MOCK_DEVICE_LOCATION}
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: MOCK_DEVICE_LOCATION,
@ -182,7 +182,7 @@ async def test_user_flow_selected(hass: HomeAssistant, ssdp_scanner_mock: Mock)
result = await hass.config_entries.flow.async_init(
DLNA_DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] is None
assert result["step_id"] == "user"
@ -190,7 +190,7 @@ async def test_user_flow_selected(hass: HomeAssistant, ssdp_scanner_mock: Mock)
result["flow_id"], user_input={CONF_HOST: MOCK_DEVICE_NAME}
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: MOCK_DEVICE_LOCATION,
@ -211,7 +211,7 @@ async def test_user_flow_uncontactable(
result = await hass.config_entries.flow.async_init(
DLNA_DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
assert result["step_id"] == "manual"
@ -219,7 +219,7 @@ async def test_user_flow_uncontactable(
result["flow_id"], user_input={CONF_URL: MOCK_DEVICE_LOCATION}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "cannot_connect"}
assert result["step_id"] == "manual"
@ -244,7 +244,7 @@ async def test_user_flow_embedded_st(
result = await hass.config_entries.flow.async_init(
DLNA_DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
assert result["step_id"] == "manual"
@ -252,7 +252,7 @@ async def test_user_flow_embedded_st(
result["flow_id"], user_input={CONF_URL: MOCK_DEVICE_LOCATION}
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: MOCK_DEVICE_LOCATION,
@ -272,7 +272,7 @@ async def test_user_flow_wrong_st(hass: HomeAssistant, domain_data_mock: Mock) -
result = await hass.config_entries.flow.async_init(
DLNA_DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
assert result["step_id"] == "manual"
@ -280,7 +280,7 @@ async def test_user_flow_wrong_st(hass: HomeAssistant, domain_data_mock: Mock) -
result["flow_id"], user_input={CONF_URL: MOCK_DEVICE_LOCATION}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "not_dmr"}
assert result["step_id"] == "manual"
@ -295,7 +295,7 @@ async def test_ssdp_flow_success(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_SSDP},
data=MOCK_DISCOVERY,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure(
@ -303,7 +303,7 @@ async def test_ssdp_flow_success(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: MOCK_DEVICE_LOCATION,
@ -327,7 +327,7 @@ async def test_ssdp_flow_unavailable(
context={"source": config_entries.SOURCE_SSDP},
data=MOCK_DISCOVERY,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
domain_data_mock.upnp_factory.async_create_device.side_effect = UpnpError
@ -337,7 +337,7 @@ async def test_ssdp_flow_unavailable(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: MOCK_DEVICE_LOCATION,
@ -368,7 +368,7 @@ async def test_ssdp_flow_existing(
},
),
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry_mock.data[CONF_URL] == NEW_DEVICE_LOCATION
@ -388,7 +388,7 @@ async def test_ssdp_flow_duplicate_location(
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry_mock.data[CONF_URL] == MOCK_DEVICE_LOCATION
@ -414,7 +414,7 @@ async def test_ssdp_duplicate_mac_ignored_entry(
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -437,7 +437,7 @@ async def test_ssdp_duplicate_mac_configured_entry(
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -453,7 +453,7 @@ async def test_ssdp_add_mac(
context={"source": config_entries.SOURCE_SSDP},
data=MOCK_DISCOVERY,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
await hass.async_block_till_done()
@ -474,7 +474,7 @@ async def test_ssdp_dont_remove_mac(
context={"source": config_entries.SOURCE_SSDP},
data=MOCK_DISCOVERY,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
await hass.async_block_till_done()
@ -502,7 +502,7 @@ async def test_ssdp_flow_upnp_udn(
},
),
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry_mock.data[CONF_URL] == NEW_DEVICE_LOCATION
@ -518,7 +518,7 @@ async def test_ssdp_missing_services(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_dmr"
# Service list does not contain services
@ -530,7 +530,7 @@ async def test_ssdp_missing_services(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_dmr"
# AVTransport service is missing
@ -546,7 +546,7 @@ async def test_ssdp_missing_services(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DLNA_DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=discovery
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_dmr"
@ -568,7 +568,7 @@ async def test_ssdp_single_service(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_dmr"
@ -582,7 +582,7 @@ async def test_ssdp_ignore_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "alternative_integration"
discovery = dataclasses.replace(MOCK_DISCOVERY)
@ -595,7 +595,7 @@ async def test_ssdp_ignore_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "alternative_integration"
for manufacturer, model in [
@ -613,7 +613,7 @@ async def test_ssdp_ignore_device(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "alternative_integration"
@ -635,7 +635,7 @@ async def test_ignore_flow(hass: HomeAssistant, ssdp_scanner_mock: Mock) -> None
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: MOCK_DEVICE_LOCATION,
@ -659,7 +659,7 @@ async def test_ignore_flow_no_ssdp(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: None,
@ -680,7 +680,7 @@ async def test_unignore_flow(hass: HomeAssistant, ssdp_scanner_mock: Mock) -> No
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
# Device was found via SSDP, matching the 2nd device type tried
@ -698,7 +698,7 @@ async def test_unignore_flow(hass: HomeAssistant, ssdp_scanner_mock: Mock) -> No
context={"source": config_entries.SOURCE_UNIGNORE},
data={"unique_id": MOCK_DEVICE_UDN},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure(
@ -706,7 +706,7 @@ async def test_unignore_flow(hass: HomeAssistant, ssdp_scanner_mock: Mock) -> No
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: MOCK_DEVICE_LOCATION,
@ -730,7 +730,7 @@ async def test_unignore_flow_offline(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
# Device is not in the SSDP discoveries (perhaps HA restarted between ignore and unignore)
@ -742,7 +742,7 @@ async def test_unignore_flow_offline(
context={"source": config_entries.SOURCE_UNIGNORE},
data={"unique_id": MOCK_DEVICE_UDN},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "discovery_error"
@ -756,7 +756,7 @@ async def test_get_mac_address_ipv4(
context={"source": config_entries.SOURCE_SSDP},
data=MOCK_DISCOVERY,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
mock_get_mac_address.assert_called_once_with(ip=MOCK_DEVICE_HOST_ADDR)
@ -780,7 +780,7 @@ async def test_get_mac_address_ipv6(
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
# The scope must be removed for get_mac_address to work correctly
@ -821,7 +821,7 @@ async def test_options_flow(
config_entry_mock.add_to_hass(hass)
result = await hass.config_entries.options.async_init(config_entry_mock.entry_id)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
assert result["errors"] == {}
@ -835,7 +835,7 @@ async def test_options_flow(
},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
assert result["errors"] == {"base": "invalid_url"}
@ -850,7 +850,7 @@ async def test_options_flow(
},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
CONF_LISTEN_PORT: 2222,
CONF_CALLBACK_URL_OVERRIDE: "http://override/callback",

View File

@ -11,11 +11,12 @@ from unittest.mock import Mock, patch
from async_upnp_client.exceptions import UpnpError
import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components import ssdp
from homeassistant.components.dlna_dms.const import CONF_SOURCE_ID, DOMAIN
from homeassistant.const import CONF_DEVICE_ID, CONF_HOST, CONF_URL
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .conftest import (
MOCK_DEVICE_HOST,
@ -88,7 +89,7 @@ async def test_user_flow(hass: HomeAssistant, ssdp_scanner_mock: Mock) -> 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"] is None
assert result["step_id"] == "user"
@ -97,7 +98,7 @@ async def test_user_flow(hass: HomeAssistant, ssdp_scanner_mock: Mock) -> 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["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: MOCK_DEVICE_LOCATION,
@ -121,7 +122,7 @@ async def test_user_flow_no_devices(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -135,7 +136,7 @@ async def test_ssdp_flow_success(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_SSDP},
data=MOCK_DISCOVERY,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure(
@ -143,7 +144,7 @@ async def test_ssdp_flow_success(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["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: MOCK_DEVICE_LOCATION,
@ -166,7 +167,7 @@ async def test_ssdp_flow_unavailable(
context={"source": config_entries.SOURCE_SSDP},
data=MOCK_DISCOVERY,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
upnp_factory_mock.async_create_device.side_effect = UpnpError
@ -176,7 +177,7 @@ async def test_ssdp_flow_unavailable(
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: MOCK_DEVICE_LOCATION,
@ -206,7 +207,7 @@ async def test_ssdp_flow_existing(
},
),
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry_mock.data[CONF_URL] == NEW_DEVICE_LOCATION
@ -221,7 +222,7 @@ async def test_ssdp_flow_duplicate_location(
context={"source": config_entries.SOURCE_SSDP},
data=MOCK_DISCOVERY,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry_mock.data[CONF_URL] == MOCK_DEVICE_LOCATION
@ -235,7 +236,7 @@ async def test_ssdp_flow_bad_data(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "bad_ssdp"
# Missing USN
@ -245,7 +246,7 @@ async def test_ssdp_flow_bad_data(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "bad_ssdp"
@ -285,7 +286,7 @@ async def test_duplicate_name(
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure(
@ -293,7 +294,7 @@ async def test_duplicate_name(
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == MOCK_DEVICE_NAME
assert result["data"] == {
CONF_URL: new_device_location,
@ -323,7 +324,7 @@ async def test_ssdp_flow_upnp_udn(
},
),
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert config_entry_mock.data[CONF_URL] == NEW_DEVICE_LOCATION
@ -339,7 +340,7 @@ async def test_ssdp_missing_services(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_dms"
# Service list does not contain services
@ -351,7 +352,7 @@ async def test_ssdp_missing_services(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_dms"
# ContentDirectory service is missing
@ -367,7 +368,7 @@ async def test_ssdp_missing_services(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=discovery
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_dms"
@ -389,5 +390,5 @@ async def test_ssdp_single_service(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_SSDP},
data=discovery,
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_dms"

View File

@ -54,7 +54,7 @@ async def test_form(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "home-assistant.io"
assert result2["data"] == {
"hostname": "home-assistant.io",
@ -99,7 +99,7 @@ async def test_form_adv(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "home-assistant.io"
assert result2["data"] == {
"hostname": "home-assistant.io",
@ -132,7 +132,7 @@ async def test_form_error(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "user"
assert result2["errors"] == {"base": "invalid_hostname"}
@ -178,7 +178,7 @@ async def test_flow_already_exist(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.ABORT
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "already_configured"
@ -209,7 +209,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure(
@ -221,7 +221,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
"resolver": "8.8.8.8",
"resolver_ipv6": "2001:4860:4860::8888",
@ -257,7 +257,7 @@ async def test_options_flow_empty_return(hass: HomeAssistant) -> None:
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure(
@ -266,7 +266,7 @@ async def test_options_flow_empty_return(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
"resolver": "208.67.222.222",
"resolver_ipv6": "2620:119:53::53",
@ -337,7 +337,7 @@ async def test_options_error(hass: HomeAssistant, p_input: dict[str, str]) -> No
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["step_id"] == "init"
if p_input[CONF_IPV4]:
assert result2["errors"] == {"resolver": "invalid_resolver"}

View File

@ -6,11 +6,12 @@ from unittest.mock import MagicMock, Mock, patch
import pytest
import requests
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.components.doorbird.const import CONF_EVENTS, DOMAIN
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@ -46,7 +47,7 @@ async def test_user_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"] == {}
doorbirdapi = _get_mock_doorbirdapi_return_values(
@ -195,7 +196,7 @@ async def test_form_zeroconf_correct_oui(hass: HomeAssistant) -> None:
),
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -265,7 +266,7 @@ async def test_form_zeroconf_correct_oui_wrong_device(
),
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "not_doorbird_device"
@ -285,7 +286,7 @@ async def test_form_user_cannot_connect(hass: HomeAssistant) -> None:
VALID_CONFIG,
)
assert result2["type"] == data_entry_flow.FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": "cannot_connect"}
@ -326,12 +327,12 @@ async def test_options_flow(hass: HomeAssistant) -> None:
):
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(
result["flow_id"], user_input={CONF_EVENTS: "eventa, eventc, eventq"}
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert config_entry.options == {CONF_EVENTS: ["eventa", "eventc", "eventq"]}

View File

@ -27,7 +27,7 @@ async def test_user_step_success(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {}
@ -37,7 +37,7 @@ async def test_user_step_success(hass: HomeAssistant) -> None:
CONF_ADDRESS: DKEY_DISCOVERY_INFO.address,
},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "associate"
assert result["errors"] is None
@ -53,7 +53,7 @@ async def test_user_step_no_devices_found(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -74,7 +74,7 @@ async def test_user_step_no_new_devices_found(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "no_devices_found"
@ -88,7 +88,7 @@ async def test_user_step_device_added_between_steps_1(hass: HomeAssistant) -> No
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
entry = MockConfigEntry(
@ -101,7 +101,7 @@ async def test_user_step_device_added_between_steps_1(hass: HomeAssistant) -> No
result["flow_id"],
user_input={"address": DKEY_DISCOVERY_INFO.address},
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -114,7 +114,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
context={"source": config_entries.SOURCE_BLUETOOTH},
data=DKEY_DISCOVERY_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
with patch(
@ -125,7 +125,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
@ -133,7 +133,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
CONF_ADDRESS: DKEY_DISCOVERY_INFO.address,
},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "associate"
assert result["errors"] is None
@ -150,12 +150,12 @@ async def test_bluetooth_step_success(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH},
data=DKEY_DISCOVERY_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
assert result["errors"] is None
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "associate"
assert result["errors"] is None
@ -178,7 +178,7 @@ async def _test_common_success(hass: HomeAssistant, result: FlowResult) -> None:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"activation_code": "1234-1234"}
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == DKEY_DISCOVERY_INFO.name
assert result["data"] == {
CONF_ADDRESS: DKEY_DISCOVERY_INFO.address,
@ -200,7 +200,7 @@ async def test_bluetooth_step_already_configured(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH},
data=DKEY_DISCOVERY_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -211,7 +211,7 @@ async def test_bluetooth_step_already_in_progress(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH},
data=DKEY_DISCOVERY_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
result = await hass.config_entries.flow.async_init(
@ -219,7 +219,7 @@ async def test_bluetooth_step_already_in_progress(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_BLUETOOTH},
data=DKEY_DISCOVERY_INFO,
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_in_progress"
@ -237,17 +237,17 @@ async def test_bluetooth_step_cannot_connect(hass: HomeAssistant, exc, error) ->
context={"source": config_entries.SOURCE_BLUETOOTH},
data=DKEY_DISCOVERY_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
assert result["errors"] is None
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
assert result["errors"] is None
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "associate"
assert result["errors"] is None
@ -258,7 +258,7 @@ async def test_bluetooth_step_cannot_connect(hass: HomeAssistant, exc, error) ->
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"activation_code": "1234-1234"}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == error
@ -276,17 +276,17 @@ async def test_bluetooth_step_cannot_associate(hass: HomeAssistant, exc, error)
context={"source": config_entries.SOURCE_BLUETOOTH},
data=DKEY_DISCOVERY_INFO,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
assert result["errors"] is None
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "bluetooth_confirm"
assert result["errors"] is None
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "associate"
assert result["errors"] is None
@ -297,7 +297,7 @@ async def test_bluetooth_step_cannot_associate(hass: HomeAssistant, exc, error)
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"activation_code": "1234-1234"}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "associate"
assert result["errors"] == {"base": error}
@ -315,7 +315,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
context={"source": config_entries.SOURCE_REAUTH, "entry_id": entry.entry_id},
data=entry.data,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
with patch(
@ -328,7 +328,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "reauth_confirm"
assert result["errors"] == {"base": "no_longer_in_range"}
@ -342,7 +342,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "associate"
assert result["errors"] is None
@ -359,7 +359,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"activation_code": "1234-1234"}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
assert entry.data == {
CONF_ADDRESS: DKEY_DISCOVERY_INFO.address,

View File

@ -30,13 +30,13 @@ async def test_user_form(hass: HomeAssistant) -> None:
result["flow_id"],
user_input=CONFIG,
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
with patch(
"homeassistant.components.downloader.config_flow.DownloaderConfigFlow._validate_input",
side_effect=DirectoryDoesNotExist,
):
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"}
@ -54,7 +54,7 @@ async def test_user_form(hass: HomeAssistant) -> None:
user_input=CONFIG,
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Downloader"
assert result["data"] == {"download_dir": "download_dir"}
@ -73,7 +73,7 @@ async def test_single_instance_allowed(
DOMAIN, context={"source": source}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "single_instance_allowed"
@ -95,7 +95,7 @@ async def test_import_flow_success(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Downloader"
assert result["data"] == {}
assert result["options"] == {}

View File

@ -23,7 +23,7 @@ async def test_full_user_flow_implementation(hass: HomeAssistant, connection) ->
DOMAIN, context={CONF_SOURCE: SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with patch_async_setup_entry():
@ -31,7 +31,7 @@ async def test_full_user_flow_implementation(hass: HomeAssistant, connection) ->
result["flow_id"], user_input=CONF_DATA
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "DREMEL 3D45"
assert result["data"] == CONF_DATA
@ -43,7 +43,7 @@ async def test_already_configured(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=CONF_DATA
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -54,7 +54,7 @@ async def test_cannot_connect(hass: HomeAssistant, connection) -> None:
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=CONF_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "cannot_connect"}
@ -63,7 +63,7 @@ async def test_cannot_connect(hass: HomeAssistant, connection) -> None:
result["flow_id"], user_input=CONF_DATA
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == CONF_DATA
@ -74,7 +74,7 @@ async def test_unknown_error(hass: HomeAssistant, connection) -> None:
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=CONF_DATA
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] == {"base": "unknown"}
@ -83,6 +83,6 @@ async def test_unknown_error(hass: HomeAssistant, connection) -> None:
result["flow_id"], user_input=CONF_DATA
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "DREMEL 3D45"
assert result["data"] == CONF_DATA

View File

@ -32,7 +32,7 @@ async def test_mqtt_setup(hass: HomeAssistant, mqtt_mock: MqttMockHAClient) -> N
)
await hass.async_block_till_done()
assert result is not None
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
"drop_command_topic": "drop_connect/DROP-1_C0FFEE/cmd/255",
"drop_data_topic": "drop_connect/DROP-1_C0FFEE/data/255/#",
@ -69,7 +69,7 @@ async def test_duplicate(hass: HomeAssistant, mqtt_mock: MqttMockHAClient) -> No
)
await hass.async_block_till_done()
assert result is not None
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
# Attempting configuration of the same object should abort
result = await hass.config_entries.flow.async_init(

View File

@ -9,7 +9,7 @@ import pytest
import serial
import serial.tools.list_ports
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components.dsmr import DOMAIN, config_flow
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
@ -196,7 +196,7 @@ async def test_setup_serial(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["errors"] is None
@ -205,7 +205,7 @@ async def test_setup_serial(
{"type": "Serial"},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "setup_serial"
assert result["errors"] == {}
@ -216,7 +216,7 @@ async def test_setup_serial(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == port.device
assert result["data"] == entry_data
@ -499,7 +499,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
patch("homeassistant.components.dsmr.async_setup_entry", return_value=True),
patch("homeassistant.components.dsmr.async_unload_entry", return_value=True),
):
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
await hass.async_block_till_done()

View File

@ -12,7 +12,7 @@ async def test_user_step(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm"
assert result["errors"] is None
@ -20,12 +20,12 @@ async def test_user_step(hass: HomeAssistant) -> None:
result["flow_id"], user_input={}
)
assert config_result["type"] == FlowResultType.CREATE_ENTRY
assert config_result["type"] is FlowResultType.CREATE_ENTRY
assert config_result["title"] == "DSMR Reader"
duplicate_result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert duplicate_result["type"] == FlowResultType.ABORT
assert duplicate_result["type"] is FlowResultType.ABORT
assert duplicate_result["reason"] == "single_instance_allowed"

View File

@ -2,11 +2,11 @@
from unittest.mock import patch
from homeassistant import data_entry_flow
from homeassistant.components.dunehd.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from tests.common import MockConfigEntry
@ -77,7 +77,7 @@ async def test_create_entry(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG_HOSTNAME
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "dunehd-host"
assert result["data"] == {CONF_HOST: "dunehd-host"}
@ -94,6 +94,6 @@ async def test_create_entry_with_ipv6_address(hass: HomeAssistant) -> None:
data={CONF_HOST: "2001:db8::1428:57ab"},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "2001:db8::1428:57ab"
assert result["data"] == {CONF_HOST: "2001:db8::1428:57ab"}

View File

@ -20,7 +20,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {}
with patch(
@ -37,7 +37,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
)
await hass.async_block_till_done()
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "1.1.1.1"
assert result2["data"] == {
"host": "1.1.1.1",
@ -71,7 +71,7 @@ async def test_invalid(hass: HomeAssistant, test_side_effect, test_error):
},
)
assert result2["type"] == FlowResultType.FORM
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == {"base": test_error}
with patch("duotecno.controller.PyDuotecno.connect"):
@ -83,7 +83,7 @@ async def test_invalid(hass: HomeAssistant, test_side_effect, test_error):
"password": "test-password2",
},
)
assert result2["type"] == FlowResultType.CREATE_ENTRY
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "1.1.1.1"
assert result2["data"] == {
"host": "1.1.1.1",
@ -105,5 +105,5 @@ async def test_already_setup(hass: HomeAssistant, mock_setup_entry: AsyncMock) -
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "single_instance_allowed"

View File

@ -38,7 +38,7 @@ async def test_create_entry(hass: HomeAssistant) -> None:
DOMAIN, context={"source": SOURCE_USER}
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
with patch(
"homeassistant.components.dwd_weather_warnings.config_flow.DwdWeatherWarningsAPI",
@ -50,7 +50,7 @@ async def test_create_entry(hass: HomeAssistant) -> None:
# Test for invalid region identifier.
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "invalid_identifier"}
with patch(
@ -63,7 +63,7 @@ async def test_create_entry(hass: HomeAssistant) -> None:
# Test for successfully created entry.
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "807111000"
assert result["data"] == {
CONF_REGION_IDENTIFIER: "807111000",
@ -85,7 +85,7 @@ async def test_config_flow_already_configured(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
with patch(
"homeassistant.components.dwd_weather_warnings.config_flow.DwdWeatherWarningsAPI",
@ -96,5 +96,5 @@ async def test_config_flow_already_configured(hass: HomeAssistant) -> None:
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"

View File

@ -17,7 +17,7 @@ async def test_full_user_flow(
DOMAIN, context={"source": SOURCE_USER}
)
assert result.get("type") == FlowResultType.FORM
assert result.get("type") is FlowResultType.FORM
assert result.get("step_id") == "user"
assert "flow_id" in result
@ -26,7 +26,7 @@ async def test_full_user_flow(
user_input={},
)
assert result2.get("type") == FlowResultType.CREATE_ENTRY
assert result2.get("type") is FlowResultType.CREATE_ENTRY
assert result2.get("title") == "easyEnergy"
assert result2.get("data") == {}

Some files were not shown because too many files have changed in this diff Show More