Use is in enum comparison in config flow tests U-Z (#114677)

* Use right enum expression U-Z

* Fix
This commit is contained in:
Joost Lekkerkerker 2024-04-02 23:09:56 +02:00 committed by GitHub
parent 83b56ab005
commit 2ef0521d3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
61 changed files with 861 additions and 850 deletions

View file

@ -5,7 +5,7 @@ from unittest.mock import patch
import aiounifi
from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components import ssdp
from homeassistant.components.unifi.config_flow import _async_discover_unifi
from homeassistant.components.unifi.const import (
@ -33,6 +33,7 @@ from homeassistant.const import (
CONTENT_TYPE_JSON,
)
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .test_hub import setup_unifi_integration
@ -105,7 +106,7 @@ async def test_flow_works(
UNIFI_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"
assert result["data_schema"]({CONF_USERNAME: "", CONF_PASSWORD: ""}) == {
CONF_HOST: "unifi",
@ -145,7 +146,7 @@ async def test_flow_works(
},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Site name"
assert result["data"] == {
CONF_HOST: "1.2.3.4",
@ -165,7 +166,7 @@ async def test_flow_works_negative_discovery(
UNIFI_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"
assert result["data_schema"]({CONF_USERNAME: "", CONF_PASSWORD: ""}) == {
CONF_HOST: "",
@ -184,7 +185,7 @@ async def test_flow_multiple_sites(
UNIFI_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"
aioclient_mock.get("https://1.2.3.4:1234", status=302)
@ -218,7 +219,7 @@ async def test_flow_multiple_sites(
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "site"
assert result["data_schema"]({"site": "1"})
assert result["data_schema"]({"site": "2"})
@ -234,7 +235,7 @@ async def test_flow_raise_already_configured(
UNIFI_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"
aioclient_mock.clear_requests()
@ -269,7 +270,7 @@ async def test_flow_raise_already_configured(
},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "already_configured"
@ -291,7 +292,7 @@ async def test_flow_aborts_configuration_updated(
UNIFI_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"
aioclient_mock.get("https://1.2.3.4:1234", status=302)
@ -325,7 +326,7 @@ async def test_flow_aborts_configuration_updated(
},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "configuration_updated"
@ -337,7 +338,7 @@ async def test_flow_fails_user_credentials_faulty(
UNIFI_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"
aioclient_mock.get("https://1.2.3.4:1234", status=302)
@ -354,7 +355,7 @@ async def test_flow_fails_user_credentials_faulty(
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "faulty_credentials"}
@ -366,7 +367,7 @@ async def test_flow_fails_hub_unavailable(
UNIFI_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"
aioclient_mock.get("https://1.2.3.4:1234", status=302)
@ -383,7 +384,7 @@ async def test_flow_fails_hub_unavailable(
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["errors"] == {"base": "service_unavailable"}
@ -405,7 +406,7 @@ async def test_reauth_flow_update_configuration(
data=config_entry.data,
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
aioclient_mock.clear_requests()
@ -440,7 +441,7 @@ async def test_reauth_flow_update_configuration(
},
)
assert result["type"] == data_entry_flow.FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
assert config_entry.data[CONF_HOST] == "1.2.3.4"
assert config_entry.data[CONF_USERNAME] == "new_name"
@ -465,7 +466,7 @@ async def test_advanced_option_flow(
config_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"] == "configure_entity_sources"
assert not result["last_step"]
assert list(result["data_schema"].schema[CONF_CLIENT_SOURCE].options.keys()) == [
@ -476,7 +477,7 @@ async def test_advanced_option_flow(
user_input={CONF_CLIENT_SOURCE: ["00:00:00:00:00:01"]},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "device_tracker"
assert not result["last_step"]
assert list(result["data_schema"].schema[CONF_SSID_FILTER].options.keys()) == [
@ -498,7 +499,7 @@ async def test_advanced_option_flow(
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "client_control"
assert not result["last_step"]
@ -510,7 +511,7 @@ async def test_advanced_option_flow(
},
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "statistics_sensors"
assert result["last_step"]
@ -522,7 +523,7 @@ async def test_advanced_option_flow(
},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
CONF_CLIENT_SOURCE: ["00:00:00:00:00:01"],
CONF_TRACK_CLIENTS: False,
@ -550,7 +551,7 @@ async def test_simple_option_flow(
config_entry.entry_id, context={"show_advanced_options": False}
)
assert result["type"] == data_entry_flow.FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "simple_options"
assert result["last_step"]
@ -563,7 +564,7 @@ async def test_simple_option_flow(
},
)
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
CONF_TRACK_CLIENTS: False,
CONF_TRACK_DEVICES: False,