mirror of
https://github.com/home-assistant/core.git
synced 2025-12-26 22:18:40 +00:00
Use is in enum comparison in config flow tests K-O (#114672)
This commit is contained in:
committed by
GitHub
parent
3875533f95
commit
5d500cb74b
@@ -5,7 +5,7 @@ from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.onvif import DOMAIN, config_flow
|
||||
from homeassistant.config_entries import SOURCE_DHCP
|
||||
@@ -107,7 +107,7 @@ async def test_flow_discovered_devices(hass: HomeAssistant) -> None:
|
||||
config_flow.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 (
|
||||
@@ -127,7 +127,7 @@ async def test_flow_discovered_devices(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], user_input={"auto": True}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "device"
|
||||
container = result["data_schema"].schema[config_flow.CONF_HOST].container
|
||||
assert len(container) == 3
|
||||
@@ -141,7 +141,7 @@ async def test_flow_discovered_devices(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], user_input={config_flow.CONF_HOST: HOST}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
with patch(
|
||||
@@ -158,7 +158,7 @@ async def test_flow_discovered_devices(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == f"{URN} - {MAC}"
|
||||
assert result["data"] == {
|
||||
config_flow.CONF_NAME: URN,
|
||||
@@ -180,7 +180,7 @@ async def test_flow_discovered_devices_ignore_configured_manual_input(
|
||||
config_flow.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 (
|
||||
@@ -200,7 +200,7 @@ async def test_flow_discovered_devices_ignore_configured_manual_input(
|
||||
result["flow_id"], user_input={"auto": True}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "device"
|
||||
assert len(result["data_schema"].schema[config_flow.CONF_HOST].container) == 2
|
||||
|
||||
@@ -209,7 +209,7 @@ async def test_flow_discovered_devices_ignore_configured_manual_input(
|
||||
user_input={config_flow.CONF_HOST: config_flow.CONF_MANUAL_INPUT},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ async def test_flow_discovered_no_device(hass: HomeAssistant) -> None:
|
||||
config_flow.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 (
|
||||
@@ -241,7 +241,7 @@ async def test_flow_discovered_no_device(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], user_input={"auto": True}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ async def test_flow_discovery_ignore_existing_and_abort(hass: HomeAssistant) ->
|
||||
config_flow.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 (
|
||||
@@ -287,7 +287,7 @@ async def test_flow_discovery_ignore_existing_and_abort(hass: HomeAssistant) ->
|
||||
)
|
||||
|
||||
# It should skip to manual entry if the only devices are already configured
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -302,7 +302,7 @@ async def test_flow_discovery_ignore_existing_and_abort(hass: HomeAssistant) ->
|
||||
)
|
||||
|
||||
# It should abort if already configured and entered manually
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
|
||||
|
||||
async def test_flow_manual_entry(hass: HomeAssistant) -> None:
|
||||
@@ -312,7 +312,7 @@ async def test_flow_manual_entry(hass: HomeAssistant) -> None:
|
||||
config_flow.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 (
|
||||
@@ -334,7 +334,7 @@ async def test_flow_manual_entry(hass: HomeAssistant) -> None:
|
||||
user_input={"auto": False},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
with patch(
|
||||
@@ -354,7 +354,7 @@ async def test_flow_manual_entry(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == f"{NAME} - {MAC}"
|
||||
assert result["data"] == {
|
||||
config_flow.CONF_NAME: NAME,
|
||||
@@ -371,7 +371,7 @@ async def test_flow_manual_entry_no_profiles(hass: HomeAssistant) -> None:
|
||||
config_flow.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 (
|
||||
@@ -403,7 +403,7 @@ async def test_flow_manual_entry_no_profiles(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "no_h264"
|
||||
|
||||
|
||||
@@ -413,7 +413,7 @@ async def test_flow_manual_entry_no_mac(hass: HomeAssistant) -> None:
|
||||
config_flow.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 (
|
||||
@@ -447,7 +447,7 @@ async def test_flow_manual_entry_no_mac(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "no_mac"
|
||||
|
||||
|
||||
@@ -457,7 +457,7 @@ async def test_flow_manual_entry_fails(hass: HomeAssistant) -> None:
|
||||
config_flow.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 (
|
||||
@@ -481,7 +481,7 @@ async def test_flow_manual_entry_fails(hass: HomeAssistant) -> None:
|
||||
user_input={"auto": False},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
with patch(
|
||||
@@ -501,7 +501,7 @@ async def test_flow_manual_entry_fails(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure"
|
||||
assert result["errors"] == {"base": "onvif_error"}
|
||||
assert result["description_placeholders"] == {"error": "camera not ready"}
|
||||
@@ -526,7 +526,7 @@ async def test_flow_manual_entry_fails(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure"
|
||||
assert result["errors"] == {"base": "onvif_error"}
|
||||
assert result["description_placeholders"] == {
|
||||
@@ -567,7 +567,7 @@ async def test_flow_manual_entry_wrong_password(hass: HomeAssistant) -> None:
|
||||
config_flow.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 (
|
||||
@@ -589,7 +589,7 @@ async def test_flow_manual_entry_wrong_password(hass: HomeAssistant) -> None:
|
||||
user_input={"auto": False},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
with patch(
|
||||
@@ -609,7 +609,7 @@ async def test_flow_manual_entry_wrong_password(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure"
|
||||
assert result["errors"] == {"password": "auth_failed"}
|
||||
assert result["description_placeholders"] == {"error": "Authority failure"}
|
||||
@@ -651,7 +651,7 @@ async def test_option_flow(hass: HomeAssistant, option_value: bool) -> None:
|
||||
entry.entry_id, context={"show_advanced_options": True}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "onvif_devices"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -664,7 +664,7 @@ async def test_option_flow(hass: HomeAssistant, option_value: bool) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
config_flow.CONF_EXTRA_ARGUMENTS: "",
|
||||
config_flow.CONF_RTSP_TRANSPORT: list(config_flow.RTSP_TRANSPORTS)[1],
|
||||
@@ -691,7 +691,7 @@ async def test_discovered_by_dhcp_updates_host(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"
|
||||
assert config_entry.data[CONF_HOST] == DHCP_DISCOVERY.ip
|
||||
|
||||
@@ -716,7 +716,7 @@ async def test_discovered_by_dhcp_does_nothing_if_host_is_the_same(
|
||||
)
|
||||
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] == DHCP_DISCOVERY_SAME_IP.ip
|
||||
|
||||
@@ -740,7 +740,7 @@ async def test_discovered_by_dhcp_does_not_update_if_already_loaded(
|
||||
)
|
||||
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] != DHCP_DISCOVERY.ip
|
||||
|
||||
@@ -754,7 +754,7 @@ async def test_discovered_by_dhcp_does_not_update_if_no_matching_entry(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
@@ -775,7 +775,7 @@ async def test_form_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"
|
||||
assert (
|
||||
_get_schema_default(result["data_schema"].schema, CONF_USERNAME)
|
||||
@@ -804,7 +804,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "reauth_confirm"
|
||||
assert result2["errors"] == {config_flow.CONF_PASSWORD: "auth_failed"}
|
||||
assert result2["description_placeholders"] == {
|
||||
@@ -833,7 +833,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == FlowResultType.ABORT
|
||||
assert result3["type"] is FlowResultType.ABORT
|
||||
assert result3["reason"] == "reauth_successful"
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
assert entry.data[config_flow.CONF_USERNAME] == "new-test-username"
|
||||
@@ -850,7 +850,7 @@ async def test_flow_manual_entry_updates_existing_user_password(
|
||||
config_flow.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 (
|
||||
@@ -871,7 +871,7 @@ async def test_flow_manual_entry_updates_existing_user_password(
|
||||
result["flow_id"],
|
||||
user_input={"auto": False},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
with patch(
|
||||
@@ -890,7 +890,7 @@ async def test_flow_manual_entry_updates_existing_user_password(
|
||||
|
||||
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 entry.data[config_flow.CONF_USERNAME] == USERNAME
|
||||
assert entry.data[config_flow.CONF_PASSWORD] == "new_password"
|
||||
@@ -903,7 +903,7 @@ async def test_flow_manual_entry_wrong_port(hass: HomeAssistant) -> None:
|
||||
config_flow.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 (
|
||||
@@ -925,7 +925,7 @@ async def test_flow_manual_entry_wrong_port(hass: HomeAssistant) -> None:
|
||||
user_input={"auto": False},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
with patch(
|
||||
@@ -945,7 +945,7 @@ async def test_flow_manual_entry_wrong_port(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure"
|
||||
assert result["errors"] == {"port": "no_onvif_service"}
|
||||
assert result["description_placeholders"] == {}
|
||||
|
||||
Reference in New Issue
Block a user