Use is in enum comparison in config flow tests P-T (#114675)

This commit is contained in:
Joost Lekkerkerker 2024-04-02 23:21:50 +02:00 committed by GitHub
parent 5d500cb74b
commit ee66f6ec8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
164 changed files with 1919 additions and 1890 deletions

View file

@ -56,7 +56,7 @@ async def test_bad_credentials(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with (
@ -69,14 +69,14 @@ async def test_bad_credentials(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.EXTERNAL_STEP
assert result["type"] is FlowResultType.EXTERNAL_STEP
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.EXTERNAL_STEP_DONE
assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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"] == "user"
assert result["errors"][CONF_TOKEN] == "faulty_credentials"
@ -88,7 +88,7 @@ async def test_bad_hostname(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with (
@ -102,14 +102,14 @@ async def test_bad_hostname(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.EXTERNAL_STEP
assert result["type"] is FlowResultType.EXTERNAL_STEP
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.EXTERNAL_STEP_DONE
assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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"] == "user"
assert result["errors"][CONF_HOST] == "not_found"
@ -121,7 +121,7 @@ async def test_unknown_exception(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with (
@ -132,13 +132,13 @@ async def test_unknown_exception(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.EXTERNAL_STEP
assert result["type"] is FlowResultType.EXTERNAL_STEP
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.EXTERNAL_STEP_DONE
assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "unknown"
@ -155,7 +155,7 @@ async def test_no_servers_found(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with (
@ -165,13 +165,13 @@ async def test_no_servers_found(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.EXTERNAL_STEP
assert result["type"] is FlowResultType.EXTERNAL_STEP
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.EXTERNAL_STEP_DONE
assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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"] == "user"
assert result["errors"]["base"] == "no_servers"
@ -186,7 +186,7 @@ async def test_single_available_server(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with (
@ -196,13 +196,13 @@ async def test_single_available_server(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.EXTERNAL_STEP
assert result["type"] is FlowResultType.EXTERNAL_STEP
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.EXTERNAL_STEP_DONE
assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert (
result["title"] == "https://1-2-3-4.123456789001234567890.plex.direct:32400"
@ -230,7 +230,7 @@ async def test_multiple_servers_with_selection(
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"
requests_mock.get(
@ -244,13 +244,13 @@ async def test_multiple_servers_with_selection(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.EXTERNAL_STEP
assert result["type"] is FlowResultType.EXTERNAL_STEP
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.EXTERNAL_STEP_DONE
assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
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"] == "select_server"
result = await hass.config_entries.flow.async_configure(
@ -259,7 +259,7 @@ async def test_multiple_servers_with_selection(
CONF_SERVER_IDENTIFIER: MOCK_SERVERS[0][CONF_SERVER_IDENTIFIER]
},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert (
result["title"] == "https://1-2-3-4.123456789001234567890.plex.direct:32400"
@ -295,7 +295,7 @@ async def test_adding_last_unconfigured_server(
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"
requests_mock.get(
@ -310,13 +310,13 @@ async def test_adding_last_unconfigured_server(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.EXTERNAL_STEP
assert result["type"] is FlowResultType.EXTERNAL_STEP
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.EXTERNAL_STEP_DONE
assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert (
result["title"] == "https://1-2-3-4.123456789001234567890.plex.direct:32400"
@ -354,7 +354,7 @@ async def test_all_available_servers_configured(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
requests_mock.get("https://plex.tv/api/v2/user", text=plextv_account)
@ -370,13 +370,13 @@ async def test_all_available_servers_configured(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.EXTERNAL_STEP
assert result["type"] is FlowResultType.EXTERNAL_STEP
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.EXTERNAL_STEP_DONE
assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "all_configured"
@ -388,7 +388,7 @@ async def test_option_flow(hass: HomeAssistant, entry, mock_plex_server) -> None
result = await hass.config_entries.options.async_init(
entry.entry_id, context={"source": "test"}, data=None
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "plex_mp_settings"
result = await hass.config_entries.options.async_configure(
@ -399,7 +399,7 @@ async def test_option_flow(hass: HomeAssistant, entry, mock_plex_server) -> None
CONF_MONITORED_USERS: list(mock_plex_server.accounts),
},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
Platform.MEDIA_PLAYER: {
CONF_USE_EPISODE_ART: True,
@ -422,7 +422,7 @@ async def test_missing_option_flow(
result = await hass.config_entries.options.async_init(
entry.entry_id, context={"source": "test"}, data=None
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "plex_mp_settings"
result = await hass.config_entries.options.async_configure(
@ -433,7 +433,7 @@ async def test_missing_option_flow(
CONF_MONITORED_USERS: list(mock_plex_server.accounts),
},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["data"] == {
Platform.MEDIA_PLAYER: {
CONF_USE_EPISODE_ART: True,
@ -470,7 +470,7 @@ async def test_option_flow_new_users_available(
result = await hass.config_entries.options.async_init(
entry.entry_id, context={"source": "test"}, data=None
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "plex_mp_settings"
multiselect_defaults = result["data_schema"].schema["monitored_users"].options
@ -486,7 +486,7 @@ async def test_external_timed_out(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with (
@ -496,13 +496,13 @@ async def test_external_timed_out(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.EXTERNAL_STEP
assert result["type"] is FlowResultType.EXTERNAL_STEP
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.EXTERNAL_STEP_DONE
assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "token_request_timeout"
@ -515,7 +515,7 @@ async def test_callback_view(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with (
@ -525,7 +525,7 @@ async def test_callback_view(
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
)
assert result["type"] == FlowResultType.EXTERNAL_STEP
assert result["type"] is FlowResultType.EXTERNAL_STEP
client = await hass_client_no_auth()
forward_url = f'{config_flow.AUTH_CALLBACK_PATH}?flow_id={result["flow_id"]}'
@ -552,7 +552,7 @@ async def test_manual_config(
config_flow.DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
assert result["data_schema"] is None
hass.config_entries.flow.async_abort(result["flow_id"])
@ -564,7 +564,7 @@ async def test_manual_config(
)
assert result["data_schema"] is not None
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user_advanced"
with patch("plexauth.PlexAuth.initiate_auth"):
@ -572,7 +572,7 @@ async def test_manual_config(
result["flow_id"], user_input={"setup_method": AUTOMATIC_SETUP_STRING}
)
assert result["type"] == FlowResultType.EXTERNAL_STEP
assert result["type"] is FlowResultType.EXTERNAL_STEP
hass.config_entries.flow.async_abort(result["flow_id"])
# Advanced manual
@ -582,14 +582,14 @@ async def test_manual_config(
)
assert result["data_schema"] is not None
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user_advanced"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"setup_method": MANUAL_SETUP_STRING}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_setup"
MANUAL_SERVER = {
@ -610,7 +610,7 @@ async def test_manual_config(
result["flow_id"], user_input=MANUAL_SERVER_NO_HOST_OR_TOKEN
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_setup"
assert result["errors"]["base"] == "host_or_token"
@ -622,7 +622,7 @@ async def test_manual_config(
result["flow_id"], user_input=MANUAL_SERVER
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_setup"
assert result["errors"]["base"] == "ssl_error"
@ -634,7 +634,7 @@ async def test_manual_config(
result["flow_id"], user_input=MANUAL_SERVER
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_setup"
assert result["errors"]["base"] == "ssl_error"
@ -646,7 +646,7 @@ async def test_manual_config(
result["flow_id"], user_input=MANUAL_SERVER
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_setup"
assert result["errors"]["base"] == "ssl_error"
@ -659,7 +659,7 @@ async def test_manual_config(
)
await hass.async_block_till_done()
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "http://1.2.3.4:32400"
assert result["data"][CONF_SERVER] == "Plex Server 1"
@ -682,14 +682,14 @@ async def test_manual_config_with_token(
context={"source": SOURCE_USER, "show_advanced_options": True},
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user_advanced"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={"setup_method": MANUAL_SETUP_STRING}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "manual_setup"
with (
@ -700,7 +700,7 @@ async def test_manual_config_with_token(
result["flow_id"], user_input={CONF_TOKEN: MOCK_TOKEN}
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["type"] is FlowResultType.CREATE_ENTRY
mock_url = "https://1-2-3-4.123456789001234567890.plex.direct:32400"
@ -761,13 +761,13 @@ async def test_reauth(
patch("plexauth.PlexAuth.token", return_value="BRAND_NEW_TOKEN"),
):
result = await hass.config_entries.flow.async_configure(flow_id, user_input={})
assert result["type"] == FlowResultType.EXTERNAL_STEP
assert result["type"] is FlowResultType.EXTERNAL_STEP
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.EXTERNAL_STEP_DONE
assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["reason"] == "reauth_successful"
assert result["flow_id"] == flow_id
@ -813,13 +813,13 @@ async def test_reauth_multiple_servers_available(
patch("plexauth.PlexAuth.token", return_value="BRAND_NEW_TOKEN"),
):
result = await hass.config_entries.flow.async_configure(flow_id, user_input={})
assert result["type"] == FlowResultType.EXTERNAL_STEP
assert result["type"] is FlowResultType.EXTERNAL_STEP
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.EXTERNAL_STEP_DONE
assert result["type"] is FlowResultType.EXTERNAL_STEP_DONE
result = await hass.config_entries.flow.async_configure(result["flow_id"])
assert result["type"] == FlowResultType.ABORT
assert result["type"] is FlowResultType.ABORT
assert result["flow_id"] == flow_id
assert result["reason"] == "reauth_successful"
@ -840,7 +840,7 @@ async def test_client_request_missing(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"
with (
@ -864,7 +864,7 @@ async def test_client_header_issues(
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert result["type"] == FlowResultType.FORM
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "user"
with (