mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Use is in enum comparison in config flow tests U-Z (#114677)
* Use right enum expression U-Z * Fix
This commit is contained in:
parent
83b56ab005
commit
2ef0521d3d
@ -56,10 +56,10 @@ async def test_state(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
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.ukraine_alarm.async_setup_entry",
|
||||
@ -73,7 +73,7 @@ async def test_state(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"] == "State 1"
|
||||
assert result3["data"] == {
|
||||
"region": "1",
|
||||
@ -87,10 +87,10 @@ async def test_state_district(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
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -98,7 +98,7 @@ async def test_state_district(hass: HomeAssistant) -> None:
|
||||
"region": "2",
|
||||
},
|
||||
)
|
||||
assert result3["type"] == FlowResultType.FORM
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.ukraine_alarm.async_setup_entry",
|
||||
@ -112,7 +112,7 @@ async def test_state_district(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result4["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["title"] == "District 2.2"
|
||||
assert result4["data"] == {
|
||||
"region": "2.2",
|
||||
@ -126,10 +126,10 @@ async def test_state_district_pick_region(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
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -137,7 +137,7 @@ async def test_state_district_pick_region(hass: HomeAssistant) -> None:
|
||||
"region": "2",
|
||||
},
|
||||
)
|
||||
assert result3["type"] == FlowResultType.FORM
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.ukraine_alarm.async_setup_entry",
|
||||
@ -151,7 +151,7 @@ async def test_state_district_pick_region(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result4["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["title"] == "State 2"
|
||||
assert result4["data"] == {
|
||||
"region": "2",
|
||||
@ -165,12 +165,12 @@ async def test_state_district_community(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
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
)
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -178,7 +178,7 @@ async def test_state_district_community(hass: HomeAssistant) -> None:
|
||||
"region": "3",
|
||||
},
|
||||
)
|
||||
assert result3["type"] == FlowResultType.FORM
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
|
||||
result4 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -186,7 +186,7 @@ async def test_state_district_community(hass: HomeAssistant) -> None:
|
||||
"region": "3.2",
|
||||
},
|
||||
)
|
||||
assert result4["type"] == FlowResultType.FORM
|
||||
assert result4["type"] is FlowResultType.FORM
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.ukraine_alarm.async_setup_entry",
|
||||
@ -200,7 +200,7 @@ async def test_state_district_community(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result5["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result5["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result5["title"] == "Community 3.2.1"
|
||||
assert result5["data"] == {
|
||||
"region": "3.2.1",
|
||||
@ -231,7 +231,7 @@ async def test_rate_limit(hass: HomeAssistant, mock_get_regions: AsyncMock) -> N
|
||||
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"] == "rate_limit"
|
||||
|
||||
|
||||
@ -243,7 +243,7 @@ async def test_server_error(hass: HomeAssistant, mock_get_regions) -> 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"] == "unknown"
|
||||
|
||||
|
||||
@ -253,7 +253,7 @@ async def test_cannot_connect(hass: HomeAssistant, mock_get_regions: AsyncMock)
|
||||
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"
|
||||
|
||||
|
||||
@ -265,7 +265,7 @@ async def test_unknown_client_error(
|
||||
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"] == "unknown"
|
||||
|
||||
|
||||
@ -275,7 +275,7 @@ async def test_timeout_error(hass: HomeAssistant, mock_get_regions: AsyncMock) -
|
||||
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"] == "timeout"
|
||||
|
||||
|
||||
@ -287,5 +287,5 @@ async def test_no_regions_returned(
|
||||
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"] == "unknown"
|
||||
|
@ -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,
|
||||
|
@ -63,7 +63,7 @@ async def test_form(hass: HomeAssistant, bootstrap: Bootstrap, nvr: NVR) -> 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 not result["errors"]
|
||||
|
||||
bootstrap.nvr = nvr
|
||||
@ -91,7 +91,7 @@ async def test_form(hass: HomeAssistant, bootstrap: Bootstrap, nvr: NVR) -> None
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "UnifiProtect"
|
||||
assert result2["data"] == {
|
||||
"host": "1.1.1.1",
|
||||
@ -127,7 +127,7 @@ async def test_form_version_too_old(
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "protect_version"}
|
||||
|
||||
|
||||
@ -150,7 +150,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"password": "invalid_auth"}
|
||||
|
||||
|
||||
@ -178,7 +178,7 @@ async def test_form_cloud_user(
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cloud_user"}
|
||||
|
||||
|
||||
@ -201,7 +201,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"}
|
||||
|
||||
|
||||
@ -230,7 +230,7 @@ async def test_form_reauth_auth(
|
||||
"entry_id": mock_config.entry_id,
|
||||
},
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert not result["errors"]
|
||||
flows = hass.config_entries.flow.async_progress_by_handler(DOMAIN)
|
||||
assert flows[0]["context"]["title_placeholders"] == {
|
||||
@ -250,7 +250,7 @@ async def test_form_reauth_auth(
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"password": "invalid_auth"}
|
||||
assert result2["step_id"] == "reauth_confirm"
|
||||
|
||||
@ -274,7 +274,7 @@ async def test_form_reauth_auth(
|
||||
)
|
||||
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.mock_calls) == 1
|
||||
|
||||
@ -310,7 +310,7 @@ async def test_form_options(hass: HomeAssistant, ufp_client: ProtectApiClient) -
|
||||
assert mock_config.state == config_entries.ConfigEntryState.LOADED
|
||||
|
||||
result = await hass.config_entries.options.async_init(mock_config.entry_id)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert not result["errors"]
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
@ -323,7 +323,7 @@ async def test_form_options(hass: HomeAssistant, ufp_client: ProtectApiClient) -
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == {
|
||||
"all_updates": True,
|
||||
"disable_rtsp": True,
|
||||
@ -354,7 +354,7 @@ async def test_discovered_by_ssdp_or_dhcp(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "discovery_started"
|
||||
|
||||
|
||||
@ -371,7 +371,7 @@ async def test_discovered_by_unifi_discovery_direct_connect(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "discovery_confirm"
|
||||
flows = hass.config_entries.flow.async_progress_by_handler(DOMAIN)
|
||||
assert flows[0]["context"]["title_placeholders"] == {
|
||||
@ -405,7 +405,7 @@ async def test_discovered_by_unifi_discovery_direct_connect(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "UnifiProtect"
|
||||
assert result2["data"] == {
|
||||
"host": DIRECT_CONNECT_DOMAIN,
|
||||
@ -446,7 +446,7 @@ async def test_discovered_by_unifi_discovery_direct_connect_updated(
|
||||
)
|
||||
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.data[CONF_HOST] == DIRECT_CONNECT_DOMAIN
|
||||
|
||||
@ -484,7 +484,7 @@ async def test_discovered_by_unifi_discovery_direct_connect_updated_but_not_usin
|
||||
)
|
||||
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.data[CONF_HOST] == "127.0.0.1"
|
||||
|
||||
@ -522,7 +522,7 @@ async def test_discovered_by_unifi_discovery_does_not_update_ip_when_console_is_
|
||||
)
|
||||
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.data[CONF_HOST] == "1.2.2.2"
|
||||
|
||||
@ -553,7 +553,7 @@ async def test_discovered_host_not_updated_if_existing_is_a_hostname(
|
||||
)
|
||||
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.data[CONF_HOST] == "a.hostname"
|
||||
|
||||
@ -571,7 +571,7 @@ async def test_discovered_by_unifi_discovery(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "discovery_confirm"
|
||||
flows = hass.config_entries.flow.async_progress_by_handler(DOMAIN)
|
||||
assert flows[0]["context"]["title_placeholders"] == {
|
||||
@ -605,7 +605,7 @@ async def test_discovered_by_unifi_discovery(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "UnifiProtect"
|
||||
assert result2["data"] == {
|
||||
"host": DEVICE_IP_ADDRESS,
|
||||
@ -632,7 +632,7 @@ async def test_discovered_by_unifi_discovery_partial(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "discovery_confirm"
|
||||
flows = hass.config_entries.flow.async_progress_by_handler(DOMAIN)
|
||||
assert flows[0]["context"]["title_placeholders"] == {
|
||||
@ -666,7 +666,7 @@ async def test_discovered_by_unifi_discovery_partial(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "UnifiProtect"
|
||||
assert result2["data"] == {
|
||||
"host": DEVICE_IP_ADDRESS,
|
||||
@ -706,7 +706,7 @@ async def test_discovered_by_unifi_discovery_direct_connect_on_different_interfa
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -736,7 +736,7 @@ async def test_discovered_by_unifi_discovery_direct_connect_on_different_interfa
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -777,7 +777,7 @@ async def test_discovered_by_unifi_discovery_direct_connect_on_different_interfa
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -814,7 +814,7 @@ async def test_discovered_by_unifi_discovery_direct_connect_on_different_interfa
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "discovery_confirm"
|
||||
flows = hass.config_entries.flow.async_progress_by_handler(DOMAIN)
|
||||
assert flows[0]["context"]["title_placeholders"] == {
|
||||
@ -848,7 +848,7 @@ async def test_discovered_by_unifi_discovery_direct_connect_on_different_interfa
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "UnifiProtect"
|
||||
assert result2["data"] == {
|
||||
"host": "nomatchsameip.ui.direct",
|
||||
@ -892,7 +892,7 @@ async def test_discovered_by_unifi_discovery_direct_connect_on_different_interfa
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -913,5 +913,5 @@ async def test_discovery_can_be_ignored(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"
|
||||
|
@ -31,7 +31,7 @@ async def test_show_set_form(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=None
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ async def test_connection_error(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=FIXTURE_USER_INPUT
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@ -65,7 +65,7 @@ async def test_login_error(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=FIXTURE_USER_INPUT
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
@ -80,7 +80,7 @@ async def test_success(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=FIXTURE_USER_INPUT
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"][CONF_USERNAME] == FIXTURE_USER_INPUT[CONF_USERNAME]
|
||||
assert result["data"][CONF_PASSWORD] == FIXTURE_USER_INPUT[CONF_PASSWORD]
|
||||
|
||||
@ -98,7 +98,7 @@ async def test_options(hass: HomeAssistant) -> 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"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@ -129,7 +129,7 @@ async def test_already_configured(hass: HomeAssistant, requests_mock) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=new_user_input
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert config_entry.data[CONF_USERNAME] == new_user_input[CONF_USERNAME]
|
||||
assert config_entry.data[CONF_PASSWORD] == new_user_input[CONF_PASSWORD]
|
||||
|
@ -6,7 +6,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.upnp.const import (
|
||||
CONFIG_ENTRY_HOST,
|
||||
@ -19,6 +19,7 @@ from homeassistant.components.upnp.const import (
|
||||
ST_IGD_V1,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from .conftest import (
|
||||
TEST_DISCOVERY,
|
||||
@ -48,7 +49,7 @@ async def test_flow_ssdp(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=TEST_DISCOVERY,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "ssdp_confirm"
|
||||
|
||||
# Confirm via step ssdp_confirm.
|
||||
@ -56,7 +57,7 @@ async def test_flow_ssdp(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_FRIENDLY_NAME
|
||||
assert result["data"] == {
|
||||
CONFIG_ENTRY_ST: TEST_ST,
|
||||
@ -82,7 +83,7 @@ async def test_flow_ssdp_ignore(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=TEST_DISCOVERY,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "ssdp_confirm"
|
||||
|
||||
# Ignore entry.
|
||||
@ -91,7 +92,7 @@ async def test_flow_ssdp_ignore(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_IGNORE},
|
||||
data={"unique_id": TEST_USN, "title": TEST_FRIENDLY_NAME},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_FRIENDLY_NAME
|
||||
assert result["data"] == {
|
||||
CONFIG_ENTRY_ST: TEST_ST,
|
||||
@ -121,7 +122,7 @@ async def test_flow_ssdp_incomplete_discovery(hass: HomeAssistant) -> None:
|
||||
},
|
||||
),
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "incomplete_discovery"
|
||||
|
||||
|
||||
@ -143,7 +144,7 @@ async def test_flow_ssdp_non_igd_device(hass: HomeAssistant) -> None:
|
||||
},
|
||||
),
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "non_igd_device"
|
||||
|
||||
|
||||
@ -161,7 +162,7 @@ async def test_flow_ssdp_no_mac_address(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=TEST_DISCOVERY,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "ssdp_confirm"
|
||||
|
||||
# Confirm via step ssdp_confirm.
|
||||
@ -169,7 +170,7 @@ async def test_flow_ssdp_no_mac_address(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_FRIENDLY_NAME
|
||||
assert result["data"] == {
|
||||
CONFIG_ENTRY_ST: TEST_ST,
|
||||
@ -209,7 +210,7 @@ async def test_flow_ssdp_discovery_changed_udn_match_mac(hass: HomeAssistant) ->
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=new_discovery,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "config_entry_updated"
|
||||
|
||||
|
||||
@ -241,7 +242,7 @@ async def test_flow_ssdp_discovery_changed_udn_match_host(hass: HomeAssistant) -
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=new_discovery,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "config_entry_updated"
|
||||
|
||||
|
||||
@ -283,7 +284,7 @@ async def test_flow_ssdp_discovery_changed_udn_but_st_differs(
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=new_discovery,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "ssdp_confirm"
|
||||
|
||||
# UDN + ST different: New discovery via step ssdp.
|
||||
@ -301,7 +302,7 @@ async def test_flow_ssdp_discovery_changed_udn_but_st_differs(
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=new_discovery,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "ssdp_confirm"
|
||||
|
||||
|
||||
@ -333,7 +334,7 @@ async def test_flow_ssdp_discovery_changed_location(hass: HomeAssistant) -> None
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=new_discovery,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
# Test if location is updated.
|
||||
@ -362,7 +363,7 @@ async def test_flow_ssdp_discovery_ignored_entry(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=TEST_DISCOVERY,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -395,7 +396,7 @@ async def test_flow_ssdp_discovery_changed_udn_ignored_entry(
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=new_discovery,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "discovery_ignored"
|
||||
|
||||
|
||||
@ -411,7 +412,7 @@ async def test_flow_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"
|
||||
|
||||
# Confirmed via step user.
|
||||
@ -419,7 +420,7 @@ async def test_flow_user(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={"unique_id": TEST_USN},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_FRIENDLY_NAME
|
||||
assert result["data"] == {
|
||||
CONFIG_ENTRY_ST: TEST_ST,
|
||||
@ -442,7 +443,7 @@ async def test_flow_user_no_discovery(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.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
@ -463,7 +464,7 @@ async def test_flow_ssdp_with_mismatched_udn(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=test_discovery,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "ssdp_confirm"
|
||||
|
||||
# Confirm via step ssdp_confirm.
|
||||
@ -471,7 +472,7 @@ async def test_flow_ssdp_with_mismatched_udn(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_FRIENDLY_NAME
|
||||
assert result["data"] == {
|
||||
CONFIG_ENTRY_ST: TEST_ST,
|
||||
|
@ -21,7 +21,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(
|
||||
@ -29,7 +29,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 == snapshot
|
||||
|
||||
|
||||
@ -44,5 +44,5 @@ async def test_single_instance_allowed(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "single_instance_allowed"
|
||||
|
@ -30,7 +30,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 (
|
||||
@ -50,7 +50,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["result"].unique_id == MOCK_UPTIMEROBOT_UNIQUE_ID
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == MOCK_UPTIMEROBOT_ACCOUNT["email"]
|
||||
assert result2["data"] == {CONF_API_KEY: MOCK_UPTIMEROBOT_API_KEY}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@ -62,7 +62,7 @@ async def test_form_read_only(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(
|
||||
@ -75,7 +75,7 @@ async def test_form_read_only(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"]["base"] == "not_main_key"
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ async def test_form_exception_thrown(hass: HomeAssistant, exception, error_key)
|
||||
{CONF_API_KEY: MOCK_UPTIMEROBOT_API_KEY},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"]["base"] == error_key
|
||||
|
||||
|
||||
@ -137,7 +137,7 @@ async def test_user_unique_id_already_exists(
|
||||
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 (
|
||||
@ -157,7 +157,7 @@ async def test_user_unique_id_already_exists(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -178,7 +178,7 @@ async def test_reauthentication(
|
||||
data=old_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@ -198,7 +198,7 @@ async def test_reauthentication(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@ -219,7 +219,7 @@ async def test_reauthentication_failure(
|
||||
data=old_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@ -240,7 +240,7 @@ async def test_reauthentication_failure(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["step_id"] == "reauth_confirm"
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"]["base"] == "unknown"
|
||||
|
||||
|
||||
@ -263,7 +263,7 @@ async def test_reauthentication_failure_no_existing_entry(
|
||||
data=old_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@ -283,7 +283,7 @@ async def test_reauthentication_failure_no_existing_entry(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_failed_existing"
|
||||
|
||||
|
||||
@ -304,7 +304,7 @@ async def test_reauthentication_failure_account_not_matching(
|
||||
data=old_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@ -328,5 +328,5 @@ async def test_reauthentication_failure_account_not_matching(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["step_id"] == "reauth_confirm"
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"]["base"] == "reauth_failed_matching_account"
|
||||
|
@ -21,7 +21,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(
|
||||
@ -40,7 +40,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"] == "Electricity meter"
|
||||
assert result["data"] == {}
|
||||
assert result["options"] == {
|
||||
@ -79,7 +79,7 @@ async def test_tariffs(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
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@ -94,7 +94,7 @@ async def test_tariffs(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"] == "Electricity meter"
|
||||
assert result["data"] == {}
|
||||
assert result["options"] == {
|
||||
@ -127,7 +127,7 @@ async def test_tariffs(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
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@ -142,7 +142,7 @@ async def test_tariffs(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"]["base"] == "tariffs_not_unique"
|
||||
|
||||
|
||||
@ -153,7 +153,7 @@ async def test_non_periodically_resetting(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
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@ -169,7 +169,7 @@ async def test_non_periodically_resetting(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"] == "Electricity meter"
|
||||
assert result["data"] == {}
|
||||
assert result["options"] == {
|
||||
@ -206,7 +206,7 @@ async def test_always_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
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@ -223,7 +223,7 @@ async def test_always_available(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"] == "Electricity meter"
|
||||
assert result["data"] == {}
|
||||
assert result["options"] == {
|
||||
@ -290,7 +290,7 @@ async def test_options(hass: HomeAssistant) -> 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, "source") == input_sensor1_entity_id
|
||||
@ -304,7 +304,7 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||
"always_available": True,
|
||||
},
|
||||
)
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
"cycle": "monthly",
|
||||
"delta_values": False,
|
||||
@ -428,7 +428,7 @@ async def test_change_device_source(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.options.async_init(
|
||||
utility_meter_config_entry.entry_id
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
@ -436,7 +436,7 @@ async def test_change_device_source(hass: HomeAssistant) -> None:
|
||||
"source": current_entity_source.entity_id,
|
||||
},
|
||||
)
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Confirm that the configuration entry has been removed from the source entity 1 (previous) device registry
|
||||
@ -458,7 +458,7 @@ async def test_change_device_source(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.options.async_init(
|
||||
utility_meter_config_entry.entry_id
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
@ -466,7 +466,7 @@ async def test_change_device_source(hass: HomeAssistant) -> None:
|
||||
"source": current_entity_source.entity_id,
|
||||
},
|
||||
)
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Confirm that the configuration entry has been removed from the source entity 2 (previous) device registry
|
||||
@ -490,7 +490,7 @@ async def test_change_device_source(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.options.async_init(
|
||||
utility_meter_config_entry.entry_id
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
@ -498,7 +498,7 @@ async def test_change_device_source(hass: HomeAssistant) -> None:
|
||||
"source": current_entity_source.entity_id,
|
||||
},
|
||||
)
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Confirm that the configuration entry has been added to the source entity 2 (current) device registry
|
||||
|
@ -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"] == "EVSE 1.1.1.1"
|
||||
assert result2["data"] == {
|
||||
"host": "1.1.1.1",
|
||||
@ -65,7 +65,7 @@ async def test_form_cannot_connect(
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": error}
|
||||
|
||||
with patch(
|
||||
@ -80,7 +80,7 @@ async def test_form_cannot_connect(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "EVSE 1.1.1.1"
|
||||
assert result3["data"] == {
|
||||
"host": "1.1.1.1",
|
||||
|
@ -20,7 +20,7 @@ async def test_form_no_input(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ async def test_form_create_entry(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
|
||||
assert init["type"] == FlowResultType.FORM
|
||||
assert init["type"] is FlowResultType.FORM
|
||||
assert init["errors"] is None
|
||||
|
||||
with (
|
||||
@ -49,7 +49,7 @@ async def test_form_create_entry(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"] == "Vallox"
|
||||
assert result["data"] == {"host": "1.2.3.4", "name": "Vallox"}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@ -67,7 +67,7 @@ async def test_form_invalid_ip(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"host": "invalid_host"}
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ async def test_form_vallox_api_exception_cannot_connect(hass: HomeAssistant) ->
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"host": "cannot_connect"}
|
||||
|
||||
|
||||
@ -107,7 +107,7 @@ async def test_form_os_error_cannot_connect(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"host": "cannot_connect"}
|
||||
|
||||
|
||||
@ -127,7 +127,7 @@ async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"host": "unknown"}
|
||||
|
||||
|
||||
@ -152,5 +152,5 @@ async def test_form_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"
|
||||
|
@ -7,12 +7,12 @@ import pytest
|
||||
import serial.tools.list_ports
|
||||
from velbusaio.exceptions import VelbusConnectionFailed
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components import usb
|
||||
from homeassistant.components.velbus.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USB, SOURCE_USER
|
||||
from homeassistant.const import CONF_NAME, CONF_PORT, CONF_SOURCE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from .const import PORT_SERIAL, PORT_TCP
|
||||
|
||||
@ -73,7 +73,7 @@ async def test_user(hass: HomeAssistant) -> None:
|
||||
)
|
||||
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"
|
||||
|
||||
# try with a serial port
|
||||
@ -83,7 +83,7 @@ async def test_user(hass: HomeAssistant) -> None:
|
||||
data={CONF_NAME: "Velbus Test Serial", CONF_PORT: PORT_SERIAL},
|
||||
)
|
||||
assert result
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result.get("title") == "velbus_test_serial"
|
||||
data = result.get("data")
|
||||
assert data
|
||||
@ -96,7 +96,7 @@ async def test_user(hass: HomeAssistant) -> None:
|
||||
data={CONF_NAME: "Velbus Test TCP", CONF_PORT: PORT_TCP},
|
||||
)
|
||||
assert result
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result.get("title") == "velbus_test_tcp"
|
||||
data = result.get("data")
|
||||
assert data
|
||||
@ -112,7 +112,7 @@ async def test_user_fail(hass: HomeAssistant) -> None:
|
||||
data={CONF_NAME: "Velbus Test Serial", CONF_PORT: PORT_SERIAL},
|
||||
)
|
||||
assert result
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {CONF_PORT: "cannot_connect"}
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -121,7 +121,7 @@ async def test_user_fail(hass: HomeAssistant) -> None:
|
||||
data={CONF_NAME: "Velbus Test TCP", CONF_PORT: PORT_TCP},
|
||||
)
|
||||
assert result
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {CONF_PORT: "cannot_connect"}
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ async def test_abort_if_already_setup(hass: HomeAssistant) -> None:
|
||||
data={CONF_PORT: PORT_TCP, CONF_NAME: "velbus test"},
|
||||
)
|
||||
assert result
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
|
||||
|
||||
@ -148,7 +148,7 @@ async def test_flow_usb(hass: HomeAssistant) -> None:
|
||||
data=DISCOVERY_INFO,
|
||||
)
|
||||
assert result
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "discovery_confirm"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@ -156,7 +156,7 @@ async def test_flow_usb(hass: HomeAssistant) -> None:
|
||||
user_input={},
|
||||
)
|
||||
assert result
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
|
||||
# test an already configured discovery
|
||||
entry = MockConfigEntry(
|
||||
@ -170,7 +170,7 @@ async def test_flow_usb(hass: HomeAssistant) -> None:
|
||||
data=DISCOVERY_INFO,
|
||||
)
|
||||
assert result
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
|
||||
|
||||
@ -184,5 +184,5 @@ async def test_flow_usb_failed(hass: HomeAssistant) -> None:
|
||||
data=DISCOVERY_INFO,
|
||||
)
|
||||
assert result
|
||||
assert result.get("type") == data_entry_flow.FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "cannot_connect"
|
||||
|
@ -9,11 +9,11 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
from pyvlx import PyVLXException
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.velux import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@ -45,7 +45,7 @@ async def test_user_success(hass: HomeAssistant) -> None:
|
||||
client_mock.return_value.disconnect.assert_called_once()
|
||||
client_mock.return_value.connect.assert_called_once()
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == DUMMY_DATA[CONF_HOST]
|
||||
assert result["data"] == DUMMY_DATA
|
||||
|
||||
@ -64,7 +64,7 @@ async def test_user_errors(
|
||||
|
||||
connect_mock.assert_called_once()
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": error_name}
|
||||
|
||||
@ -77,7 +77,7 @@ async def test_import_valid_config(hass: HomeAssistant) -> None:
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data=DUMMY_DATA,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == DUMMY_DATA[CONF_HOST]
|
||||
assert result["data"] == DUMMY_DATA
|
||||
|
||||
@ -97,7 +97,7 @@ async def test_flow_duplicate_entry(hass: HomeAssistant, flow_source: str) -> No
|
||||
context={"source": flow_source},
|
||||
data=DUMMY_DATA,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -115,5 +115,5 @@ async def test_import_errors(
|
||||
context={"source": SOURCE_IMPORT},
|
||||
data=DUMMY_DATA,
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == error_name
|
||||
|
@ -37,7 +37,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@ -56,7 +56,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["data"] == TEST_DATA
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
@ -76,7 +76,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"}
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ async def test_unknown_error(hass: HomeAssistant) -> None:
|
||||
TEST_DATA,
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@ -107,7 +107,7 @@ async def test_already_configured(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 (
|
||||
@ -126,5 +126,5 @@ async def test_already_configured(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"
|
||||
|
@ -4,7 +4,7 @@ from unittest.mock import MagicMock, patch
|
||||
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.vera import CONF_CONTROLLER, CONF_LEGACY_UNIQUE_ID, DOMAIN
|
||||
from homeassistant.const import CONF_EXCLUDE, CONF_LIGHTS, CONF_SOURCE
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -25,7 +25,7 @@ async def test_async_step_user_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"] == config_entries.SOURCE_USER
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@ -36,7 +36,7 @@ async def test_async_step_user_success(hass: HomeAssistant) -> None:
|
||||
CONF_EXCLUDE: "14 15",
|
||||
},
|
||||
)
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "http://127.0.0.1:123"
|
||||
assert result["data"] == {
|
||||
CONF_CONTROLLER: "http://127.0.0.1:123",
|
||||
@ -65,7 +65,7 @@ async def test_async_step_import_success(hass: HomeAssistant) -> None:
|
||||
data={CONF_CONTROLLER: "http://127.0.0.1:123/"},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "http://127.0.0.1:123"
|
||||
assert result["data"] == {
|
||||
CONF_CONTROLLER: "http://127.0.0.1:123",
|
||||
@ -95,7 +95,7 @@ async def test_async_step_import_success_with_legacy_unique_id(
|
||||
data={CONF_CONTROLLER: "http://127.0.0.1:123/"},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "http://127.0.0.1:123"
|
||||
assert result["data"] == {
|
||||
CONF_CONTROLLER: "http://127.0.0.1:123",
|
||||
@ -139,7 +139,7 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.options.async_init(
|
||||
entry.entry_id, context={"source": "test"}, 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(
|
||||
@ -149,7 +149,7 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||
CONF_EXCLUDE: "8,9;10 11 12_13bb14",
|
||||
},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
CONF_LIGHTS: [1, 2, 3, 4, 5, 6, 7],
|
||||
CONF_EXCLUDE: [8, 9, 10, 11, 12, 13, 14],
|
||||
|
@ -32,7 +32,7 @@ async def test_full_user_flow_single_installation(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {}
|
||||
|
||||
mock_verisure_config_flow.get_installations.return_value = {
|
||||
@ -49,7 +49,7 @@ async def test_full_user_flow_single_installation(
|
||||
)
|
||||
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") == "ascending (12345th street)"
|
||||
assert result2.get("data") == {
|
||||
CONF_GIID: "12345",
|
||||
@ -71,7 +71,7 @@ async def test_full_user_flow_multiple_installations(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@ -84,7 +84,7 @@ async def test_full_user_flow_multiple_installations(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2.get("step_id") == "installation"
|
||||
assert result2.get("type") == FlowResultType.FORM
|
||||
assert result2.get("type") is FlowResultType.FORM
|
||||
assert result2.get("errors") is None
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@ -92,7 +92,7 @@ async def test_full_user_flow_multiple_installations(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result3.get("title") == "descending (54321th street)"
|
||||
assert result3.get("data") == {
|
||||
CONF_GIID: "54321",
|
||||
@ -114,7 +114,7 @@ async def test_full_user_flow_single_installation_with_mfa(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {}
|
||||
|
||||
mock_verisure_config_flow.login.side_effect = VerisureLoginError(
|
||||
@ -130,7 +130,7 @@ async def test_full_user_flow_single_installation_with_mfa(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2.get("type") == FlowResultType.FORM
|
||||
assert result2.get("type") is FlowResultType.FORM
|
||||
assert result2.get("step_id") == "mfa"
|
||||
|
||||
mock_verisure_config_flow.login.side_effect = None
|
||||
@ -147,7 +147,7 @@ async def test_full_user_flow_single_installation_with_mfa(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result3.get("title") == "ascending (12345th street)"
|
||||
assert result3.get("data") == {
|
||||
CONF_GIID: "12345",
|
||||
@ -171,7 +171,7 @@ async def test_full_user_flow_multiple_installations_with_mfa(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {}
|
||||
|
||||
mock_verisure_config_flow.login.side_effect = VerisureLoginError(
|
||||
@ -187,7 +187,7 @@ async def test_full_user_flow_multiple_installations_with_mfa(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2.get("type") == FlowResultType.FORM
|
||||
assert result2.get("type") is FlowResultType.FORM
|
||||
assert result2.get("step_id") == "mfa"
|
||||
|
||||
mock_verisure_config_flow.login.side_effect = None
|
||||
@ -201,7 +201,7 @@ async def test_full_user_flow_multiple_installations_with_mfa(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3.get("step_id") == "installation"
|
||||
assert result3.get("type") == FlowResultType.FORM
|
||||
assert result3.get("type") is FlowResultType.FORM
|
||||
assert result3.get("errors") is None
|
||||
|
||||
result4 = await hass.config_entries.flow.async_configure(
|
||||
@ -209,7 +209,7 @@ async def test_full_user_flow_multiple_installations_with_mfa(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result4.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result4.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result4.get("title") == "descending (54321th street)"
|
||||
assert result4.get("data") == {
|
||||
CONF_GIID: "54321",
|
||||
@ -252,7 +252,7 @@ async def test_verisure_errors(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2.get("type") == FlowResultType.FORM
|
||||
assert result2.get("type") is FlowResultType.FORM
|
||||
assert result2.get("step_id") == "user"
|
||||
assert result2.get("errors") == {"base": error}
|
||||
|
||||
@ -272,7 +272,7 @@ async def test_verisure_errors(
|
||||
|
||||
mock_verisure_config_flow.request_mfa.side_effect = None
|
||||
|
||||
assert result3.get("type") == FlowResultType.FORM
|
||||
assert result3.get("type") is FlowResultType.FORM
|
||||
assert result3.get("step_id") == "user"
|
||||
assert result3.get("errors") == {"base": "unknown_mfa"}
|
||||
|
||||
@ -285,7 +285,7 @@ async def test_verisure_errors(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result4.get("type") == FlowResultType.FORM
|
||||
assert result4.get("type") is FlowResultType.FORM
|
||||
assert result4.get("step_id") == "mfa"
|
||||
|
||||
mock_verisure_config_flow.validate_mfa.side_effect = side_effect
|
||||
@ -296,7 +296,7 @@ async def test_verisure_errors(
|
||||
"code": "123456",
|
||||
},
|
||||
)
|
||||
assert result5.get("type") == FlowResultType.FORM
|
||||
assert result5.get("type") is FlowResultType.FORM
|
||||
assert result5.get("step_id") == "mfa"
|
||||
assert result5.get("errors") == {"base": error}
|
||||
|
||||
@ -315,7 +315,7 @@ async def test_verisure_errors(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result6.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result6.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result6.get("title") == "ascending (12345th street)"
|
||||
assert result6.get("data") == {
|
||||
CONF_GIID: "12345",
|
||||
@ -339,7 +339,7 @@ async def test_dhcp(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "user"
|
||||
|
||||
|
||||
@ -362,7 +362,7 @@ async def test_reauth_flow(
|
||||
data=mock_config_entry.data,
|
||||
)
|
||||
assert result.get("step_id") == "reauth_confirm"
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@ -374,7 +374,7 @@ async def test_reauth_flow(
|
||||
)
|
||||
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"
|
||||
assert mock_config_entry.data == {
|
||||
CONF_GIID: "12345",
|
||||
@ -405,7 +405,7 @@ async def test_reauth_flow_with_mfa(
|
||||
data=mock_config_entry.data,
|
||||
)
|
||||
assert result.get("step_id") == "reauth_confirm"
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("errors") == {}
|
||||
|
||||
mock_verisure_config_flow.login.side_effect = VerisureLoginError(
|
||||
@ -421,7 +421,7 @@ async def test_reauth_flow_with_mfa(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2.get("type") == FlowResultType.FORM
|
||||
assert result2.get("type") is FlowResultType.FORM
|
||||
assert result2.get("step_id") == "reauth_mfa"
|
||||
|
||||
mock_verisure_config_flow.login.side_effect = None
|
||||
@ -434,7 +434,7 @@ async def test_reauth_flow_with_mfa(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3.get("type") == FlowResultType.ABORT
|
||||
assert result3.get("type") is FlowResultType.ABORT
|
||||
assert result3.get("reason") == "reauth_successful"
|
||||
assert mock_config_entry.data == {
|
||||
CONF_GIID: "12345",
|
||||
@ -487,7 +487,7 @@ async def test_reauth_flow_errors(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2.get("step_id") == "reauth_confirm"
|
||||
assert result2.get("type") == FlowResultType.FORM
|
||||
assert result2.get("type") is FlowResultType.FORM
|
||||
assert result2.get("errors") == {"base": error}
|
||||
|
||||
mock_verisure_config_flow.login.side_effect = VerisureLoginError(
|
||||
@ -504,7 +504,7 @@ async def test_reauth_flow_errors(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3.get("type") == FlowResultType.FORM
|
||||
assert result3.get("type") is FlowResultType.FORM
|
||||
assert result3.get("step_id") == "reauth_confirm"
|
||||
assert result3.get("errors") == {"base": "unknown_mfa"}
|
||||
|
||||
@ -519,7 +519,7 @@ async def test_reauth_flow_errors(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result4.get("type") == FlowResultType.FORM
|
||||
assert result4.get("type") is FlowResultType.FORM
|
||||
assert result4.get("step_id") == "reauth_mfa"
|
||||
|
||||
mock_verisure_config_flow.validate_mfa.side_effect = side_effect
|
||||
@ -530,7 +530,7 @@ async def test_reauth_flow_errors(
|
||||
"code": "123456",
|
||||
},
|
||||
)
|
||||
assert result5.get("type") == FlowResultType.FORM
|
||||
assert result5.get("type") is FlowResultType.FORM
|
||||
assert result5.get("step_id") == "reauth_mfa"
|
||||
assert result5.get("errors") == {"base": error}
|
||||
|
||||
@ -575,7 +575,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "init"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@ -583,5 +583,5 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||
user_input={CONF_LOCK_CODE_DIGITS: 4},
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result.get("data") == {CONF_LOCK_CODE_DIGITS: DEFAULT_LOCK_CODE_DIGITS}
|
||||
|
@ -53,7 +53,7 @@ async def test_basic_form(hass: HomeAssistant) -> None:
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_USER, "show_advanced_options": False},
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.version.async_setup_entry",
|
||||
@ -65,7 +65,7 @@ async def test_basic_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"] == VERSION_SOURCE_DOCKER_HUB
|
||||
assert result2["data"] == {
|
||||
**DEFAULT_CONFIGURATION,
|
||||
@ -81,7 +81,7 @@ async def test_advanced_form_pypi(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
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -89,11 +89,11 @@ async def test_advanced_form_pypi(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "version_source"
|
||||
|
||||
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"] == "version_source"
|
||||
|
||||
with patch(
|
||||
@ -105,7 +105,7 @@ async def test_advanced_form_pypi(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"] == VERSION_SOURCE_PYPI
|
||||
assert result["data"] == {
|
||||
**DEFAULT_CONFIGURATION,
|
||||
@ -122,7 +122,7 @@ async def test_advanced_form_container(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
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -130,11 +130,11 @@ async def test_advanced_form_container(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "version_source"
|
||||
|
||||
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"] == "version_source"
|
||||
|
||||
with patch(
|
||||
@ -146,7 +146,7 @@ async def test_advanced_form_container(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"] == VERSION_SOURCE_DOCKER_HUB
|
||||
assert result["data"] == {
|
||||
**DEFAULT_CONFIGURATION,
|
||||
@ -163,7 +163,7 @@ async def test_advanced_form_supervisor(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
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -171,11 +171,11 @@ async def test_advanced_form_supervisor(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "version_source"
|
||||
|
||||
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"] == "version_source"
|
||||
|
||||
with patch(
|
||||
@ -188,7 +188,7 @@ async def test_advanced_form_supervisor(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"] == f"{VERSION_SOURCE_VERSIONS} Dev"
|
||||
assert result["data"] == {
|
||||
**DEFAULT_CONFIGURATION,
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.vesync import DOMAIN, config_flow
|
||||
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
|
||||
|
||||
@ -19,7 +19,7 @@ async def test_abort_already_setup(hass: HomeAssistant) -> None:
|
||||
)
|
||||
result = await flow.async_step_user()
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ async def test_invalid_login_error(hass: HomeAssistant) -> None:
|
||||
with patch("pyvesync.vesync.VeSync.login", return_value=False):
|
||||
result = await flow.async_step_user(user_input=test_dict)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@ -40,11 +40,11 @@ async def test_config_flow_user_input(hass: HomeAssistant) -> None:
|
||||
flow = config_flow.VeSyncFlowHandler()
|
||||
flow.hass = hass
|
||||
result = await flow.async_step_user()
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
with patch("pyvesync.vesync.VeSync.login", return_value=True):
|
||||
result = await flow.async_step_user(
|
||||
{CONF_USERNAME: "user", CONF_PASSWORD: "pass"}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"][CONF_USERNAME] == "user"
|
||||
assert result["data"][CONF_PASSWORD] == "pass"
|
||||
|
@ -43,7 +43,7 @@ async def test_user_create_entry(
|
||||
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"] == {}
|
||||
|
||||
@ -59,7 +59,7 @@ async def test_user_create_entry(
|
||||
VALID_CONFIG,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
@ -73,7 +73,7 @@ async def test_user_create_entry(
|
||||
VALID_CONFIG,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
@ -88,7 +88,7 @@ async def test_user_create_entry(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "ViCare"
|
||||
assert result["data"] == snapshot
|
||||
mock_setup_entry.assert_called_once()
|
||||
@ -109,7 +109,7 @@ async def test_step_reauth(hass: HomeAssistant, mock_setup_entry: AsyncMock) ->
|
||||
context={"source": SOURCE_REAUTH, "entry_id": config_entry.entry_id},
|
||||
data=VALID_CONFIG,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
# test PyViCareInvalidConfigurationError
|
||||
@ -123,7 +123,7 @@ async def test_step_reauth(hass: HomeAssistant, mock_setup_entry: AsyncMock) ->
|
||||
result["flow_id"],
|
||||
user_input={CONF_PASSWORD: new_password, CONF_CLIENT_ID: new_client_id},
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
@ -136,7 +136,7 @@ async def test_step_reauth(hass: HomeAssistant, mock_setup_entry: AsyncMock) ->
|
||||
result["flow_id"],
|
||||
user_input={CONF_PASSWORD: new_password, CONF_CLIENT_ID: new_client_id},
|
||||
)
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
|
||||
assert len(hass.config_entries.async_entries()) == 1
|
||||
@ -159,7 +159,7 @@ async def test_form_dhcp(
|
||||
context={"source": SOURCE_DHCP},
|
||||
data=DHCP_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -173,7 +173,7 @@ async def test_form_dhcp(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "ViCare"
|
||||
assert result["data"] == snapshot
|
||||
mock_setup_entry.assert_called_once()
|
||||
@ -192,7 +192,7 @@ async def test_dhcp_single_instance_allowed(hass: HomeAssistant) -> None:
|
||||
context={"source": SOURCE_DHCP},
|
||||
data=DHCP_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
@ -208,5 +208,5 @@ async def test_user_input_single_instance_allowed(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"] == "single_instance_allowed"
|
||||
|
@ -4,11 +4,12 @@ from unittest.mock import Mock, patch
|
||||
|
||||
import vilfo
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.vilfo import config_flow
|
||||
from homeassistant.components.vilfo.const import DOMAIN
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST, CONF_ID, CONF_MAC
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
|
||||
async def test_form(hass: HomeAssistant) -> None:
|
||||
@ -19,7 +20,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 (
|
||||
@ -35,7 +36,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"] == "testadmin.vilfo.com"
|
||||
assert result2["data"] == {
|
||||
"host": "testadmin.vilfo.com",
|
||||
@ -64,7 +65,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
{"host": "testadmin.vilfo.com", "access_token": "test-token"},
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@ -83,7 +84,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
{"host": "testadmin.vilfo.com", "access_token": "test-token"},
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
with (
|
||||
@ -95,7 +96,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
{"host": "testadmin.vilfo.com", "access_token": "test-token"},
|
||||
)
|
||||
|
||||
assert result3["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@ -148,8 +149,8 @@ async def test_form_already_configured(hass: HomeAssistant) -> None:
|
||||
{CONF_HOST: "testadmin.vilfo.com", CONF_ACCESS_TOKEN: "test-token"},
|
||||
)
|
||||
|
||||
assert first_flow_result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert second_flow_result2["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert first_flow_result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert second_flow_result2["type"] is FlowResultType.ABORT
|
||||
assert second_flow_result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
|
@ -5,7 +5,6 @@ import dataclasses
|
||||
import pytest
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.media_player import MediaPlayerDeviceClass
|
||||
from homeassistant.components.vizio.config_flow import _get_config_schema
|
||||
from homeassistant.components.vizio.const import (
|
||||
@ -32,6 +31,7 @@ from homeassistant.const import (
|
||||
CONF_PIN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from .const import (
|
||||
ACCESS_TOKEN,
|
||||
@ -67,14 +67,14 @@ async def test_user_flow_minimum_fields(
|
||||
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=MOCK_SPEAKER_CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == NAME
|
||||
assert result["data"][CONF_NAME] == NAME
|
||||
assert result["data"][CONF_HOST] == HOST
|
||||
@ -92,14 +92,14 @@ async def test_user_flow_all_fields(
|
||||
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=MOCK_USER_VALID_TV_CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == NAME
|
||||
assert result["data"][CONF_NAME] == NAME
|
||||
assert result["data"][CONF_HOST] == HOST
|
||||
@ -118,19 +118,19 @@ async def test_speaker_options_flow(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_SPEAKER_CONFIG
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
entry = result["result"]
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id, 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(
|
||||
result["flow_id"], user_input={CONF_VOLUME_STEP: VOLUME_STEP}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == ""
|
||||
assert result["data"][CONF_VOLUME_STEP] == VOLUME_STEP
|
||||
assert CONF_APPS not in result["data"]
|
||||
@ -146,12 +146,12 @@ async def test_tv_options_flow_no_apps(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_USER_VALID_TV_CONFIG
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
entry = result["result"]
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id, data=None)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
options = {CONF_VOLUME_STEP: VOLUME_STEP}
|
||||
@ -161,7 +161,7 @@ async def test_tv_options_flow_no_apps(
|
||||
result["flow_id"], user_input=options
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == ""
|
||||
assert result["data"][CONF_VOLUME_STEP] == VOLUME_STEP
|
||||
assert CONF_APPS not in result["data"]
|
||||
@ -177,12 +177,12 @@ async def test_tv_options_flow_with_apps(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_USER_VALID_TV_CONFIG
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
entry = result["result"]
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id, data=None)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
options = {CONF_VOLUME_STEP: VOLUME_STEP}
|
||||
@ -192,7 +192,7 @@ async def test_tv_options_flow_with_apps(
|
||||
result["flow_id"], user_input=options
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == ""
|
||||
assert result["data"][CONF_VOLUME_STEP] == VOLUME_STEP
|
||||
assert CONF_APPS in result["data"]
|
||||
@ -209,13 +209,13 @@ async def test_tv_options_flow_start_with_volume(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_USER_VALID_TV_CONFIG
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
entry = result["result"]
|
||||
|
||||
result = await hass.config_entries.options.async_init(
|
||||
entry.entry_id, data={CONF_VOLUME_STEP: VOLUME_STEP}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
assert entry.options
|
||||
assert entry.options == {CONF_VOLUME_STEP: VOLUME_STEP}
|
||||
@ -224,7 +224,7 @@ async def test_tv_options_flow_start_with_volume(
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id, data=None)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
options = {CONF_VOLUME_STEP: VOLUME_STEP}
|
||||
@ -234,7 +234,7 @@ async def test_tv_options_flow_start_with_volume(
|
||||
result["flow_id"], user_input=options
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == ""
|
||||
assert result["data"][CONF_VOLUME_STEP] == VOLUME_STEP
|
||||
assert CONF_APPS in result["data"]
|
||||
@ -261,7 +261,7 @@ async def test_user_host_already_configured(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=fail_entry
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {CONF_HOST: "existing_config_entry_found"}
|
||||
|
||||
|
||||
@ -285,7 +285,7 @@ async def test_user_serial_number_already_exists(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=fail_entry
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {CONF_HOST: "existing_config_entry_found"}
|
||||
|
||||
|
||||
@ -297,7 +297,7 @@ async def test_user_error_on_could_not_connect(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_USER_VALID_TV_CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {CONF_HOST: "cannot_connect"}
|
||||
|
||||
|
||||
@ -309,7 +309,7 @@ async def test_user_error_on_could_not_connect_invalid_token(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_USER_VALID_TV_CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@ -324,19 +324,19 @@ async def test_user_tv_pairing_no_apps(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_TV_CONFIG_NO_TOKEN
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair_tv"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=MOCK_PIN_CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing_complete"
|
||||
|
||||
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"] == NAME
|
||||
assert result["data"][CONF_NAME] == NAME
|
||||
assert result["data"][CONF_HOST] == HOST
|
||||
@ -355,7 +355,7 @@ async def test_user_start_pairing_failure(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_TV_CONFIG_NO_TOKEN
|
||||
)
|
||||
|
||||
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"}
|
||||
|
||||
@ -371,14 +371,14 @@ async def test_user_invalid_pin(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_TV_CONFIG_NO_TOKEN
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair_tv"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=MOCK_PIN_CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair_tv"
|
||||
assert result["errors"] == {CONF_PIN: "complete_pairing_failed"}
|
||||
|
||||
@ -400,7 +400,7 @@ async def test_user_ignore(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=MOCK_SPEAKER_CONFIG
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_import_flow_minimum_fields(
|
||||
@ -417,7 +417,7 @@ async def test_import_flow_minimum_fields(
|
||||
),
|
||||
)
|
||||
|
||||
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_NAME] == DEFAULT_NAME
|
||||
assert result["data"][CONF_HOST] == HOST
|
||||
@ -437,7 +437,7 @@ async def test_import_flow_all_fields(
|
||||
data=vol.Schema(VIZIO_SCHEMA)(MOCK_IMPORT_VALID_TV_CONFIG),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == NAME
|
||||
assert result["data"][CONF_NAME] == NAME
|
||||
assert result["data"][CONF_HOST] == HOST
|
||||
@ -464,7 +464,7 @@ async def test_import_entity_already_configured(
|
||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=fail_entry
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured_device"
|
||||
|
||||
|
||||
@ -482,7 +482,7 @@ async def test_import_flow_update_options(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["result"].options == {CONF_VOLUME_STEP: DEFAULT_VOLUME_STEP}
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
entry_id = result["result"].entry_id
|
||||
|
||||
updated_config = MOCK_SPEAKER_CONFIG.copy()
|
||||
@ -493,7 +493,7 @@ async def test_import_flow_update_options(
|
||||
data=vol.Schema(VIZIO_SCHEMA)(updated_config),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "updated_entry"
|
||||
config_entry = hass.config_entries.async_get_entry(entry_id)
|
||||
assert config_entry.options[CONF_VOLUME_STEP] == VOLUME_STEP + 1
|
||||
@ -513,7 +513,7 @@ async def test_import_flow_update_name_and_apps(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["result"].data[CONF_NAME] == NAME
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
entry_id = result["result"].entry_id
|
||||
|
||||
updated_config = MOCK_IMPORT_VALID_TV_CONFIG.copy()
|
||||
@ -525,7 +525,7 @@ async def test_import_flow_update_name_and_apps(
|
||||
data=vol.Schema(VIZIO_SCHEMA)(updated_config),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "updated_entry"
|
||||
config_entry = hass.config_entries.async_get_entry(entry_id)
|
||||
assert config_entry.data[CONF_NAME] == NAME2
|
||||
@ -547,7 +547,7 @@ async def test_import_flow_update_remove_apps(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["result"].data[CONF_NAME] == NAME
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
config_entry = hass.config_entries.async_get_entry(result["result"].entry_id)
|
||||
assert CONF_APPS in config_entry.data
|
||||
assert CONF_APPS in config_entry.options
|
||||
@ -560,7 +560,7 @@ async def test_import_flow_update_remove_apps(
|
||||
data=vol.Schema(VIZIO_SCHEMA)(updated_config),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "updated_entry"
|
||||
assert CONF_APPS not in config_entry.data
|
||||
assert CONF_APPS not in config_entry.options
|
||||
@ -577,26 +577,26 @@ async def test_import_needs_pairing(
|
||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=MOCK_TV_CONFIG_NO_TOKEN
|
||||
)
|
||||
|
||||
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=MOCK_TV_CONFIG_NO_TOKEN
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair_tv"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=MOCK_PIN_CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing_complete_import"
|
||||
|
||||
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"] == NAME
|
||||
assert result["data"][CONF_NAME] == NAME
|
||||
assert result["data"][CONF_HOST] == HOST
|
||||
@ -617,7 +617,7 @@ async def test_import_with_apps_needs_pairing(
|
||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=import_config
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
# Mock inputting info without apps to make sure apps get stored
|
||||
@ -626,19 +626,19 @@ async def test_import_with_apps_needs_pairing(
|
||||
user_input=_get_config_schema(MOCK_TV_CONFIG_NO_TOKEN)(MOCK_TV_CONFIG_NO_TOKEN),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pair_tv"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=MOCK_PIN_CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing_complete_import"
|
||||
|
||||
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"] == NAME
|
||||
assert result["data"][CONF_NAME] == NAME
|
||||
assert result["data"][CONF_HOST] == HOST
|
||||
@ -660,7 +660,7 @@ async def test_import_flow_additional_configs(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["result"].data[CONF_NAME] == NAME
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
config_entry = hass.config_entries.async_get_entry(result["result"].entry_id)
|
||||
assert CONF_APPS in config_entry.data
|
||||
assert CONF_APPS not in config_entry.options
|
||||
@ -689,7 +689,7 @@ async def test_import_error(
|
||||
data=vol.Schema(VIZIO_SCHEMA)(fail_entry),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
# Ensure error gets logged
|
||||
vizio_log_list = [
|
||||
@ -720,7 +720,7 @@ async def test_import_ignore(
|
||||
data=vol.Schema(VIZIO_SCHEMA)(MOCK_SPEAKER_CONFIG),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_zeroconf_flow(
|
||||
@ -736,7 +736,7 @@ async def test_zeroconf_flow(
|
||||
)
|
||||
|
||||
# Form should always show even if all required properties are discovered
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
# Apply discovery updates to entry to mimic when user hits submit without changing
|
||||
@ -753,7 +753,7 @@ async def test_zeroconf_flow(
|
||||
result["flow_id"], user_input=user_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_HOST] == HOST
|
||||
assert result["data"][CONF_NAME] == NAME
|
||||
@ -782,7 +782,7 @@ async def test_zeroconf_flow_already_configured(
|
||||
)
|
||||
|
||||
# Flow should abort because device is already setup
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -810,7 +810,7 @@ async def test_zeroconf_flow_with_port_in_host(
|
||||
)
|
||||
|
||||
# Flow should abort because device is already setup
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -827,7 +827,7 @@ async def test_zeroconf_dupe_fail(
|
||||
)
|
||||
|
||||
# Form should always show even if all required properties are discovered
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
discovery_info = dataclasses.replace(MOCK_ZEROCONF_SERVICE_INFO)
|
||||
@ -836,7 +836,7 @@ async def test_zeroconf_dupe_fail(
|
||||
)
|
||||
|
||||
# Flow should abort because device is already setup
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_in_progress"
|
||||
|
||||
|
||||
@ -860,7 +860,7 @@ async def test_zeroconf_ignore(
|
||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
|
||||
async def test_zeroconf_no_unique_id(
|
||||
@ -875,7 +875,7 @@ async def test_zeroconf_no_unique_id(
|
||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@ -900,7 +900,7 @@ async def test_zeroconf_abort_when_ignored(
|
||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -929,7 +929,7 @@ async def test_zeroconf_flow_already_configured_hostname(
|
||||
)
|
||||
|
||||
# Flow should abort because device is already setup
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -954,7 +954,7 @@ async def test_import_flow_already_configured_hostname(
|
||||
)
|
||||
|
||||
# Flow should abort because device was updated
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "updated_entry"
|
||||
|
||||
assert entry.data[CONF_HOST] == HOST
|
||||
|
@ -51,7 +51,7 @@ async def test_user_flow(
|
||||
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 (
|
||||
@ -69,7 +69,7 @@ async def test_user_flow(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == entry_data["host"]
|
||||
assert result["data"] == entry_data
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@ -94,7 +94,7 @@ async def test_abort_already_configured(hass: HomeAssistant, source: str) -> Non
|
||||
data=entry_data,
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -137,7 +137,7 @@ async def test_errors(
|
||||
{"password": "test-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": error}
|
||||
|
||||
|
||||
@ -178,7 +178,7 @@ async def test_reauth_flow(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"
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
assert dict(entry.data) == {**entry_data, "password": "new-password"}
|
||||
@ -237,7 +237,7 @@ async def test_reauth_errors(
|
||||
{"password": "test-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": error}
|
||||
|
||||
|
||||
@ -272,11 +272,11 @@ async def test_hassio_flow(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == test_data.config["name"]
|
||||
assert result2["data"] == test_data.config
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@ -303,7 +303,7 @@ async def test_hassio_already_configured(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@ -352,9 +352,9 @@ async def test_hassio_errors(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == error
|
||||
|
@ -5,7 +5,6 @@ from unittest.mock import patch
|
||||
from aiovodafone import exceptions as aiovodafone_exceptions
|
||||
import pytest
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.device_tracker import CONF_CONSIDER_HOME
|
||||
from homeassistant.components.vodafone_station.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, SOURCE_USER
|
||||
@ -34,13 +33,13 @@ async def test_user(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"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"][CONF_HOST] == "fake_host"
|
||||
assert result["data"][CONF_USERNAME] == "fake_username"
|
||||
assert result["data"][CONF_PASSWORD] == "fake_password"
|
||||
@ -66,7 +65,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 patch(
|
||||
@ -77,7 +76,7 @@ async def test_exception_connection(hass: HomeAssistant, side_effect, error) ->
|
||||
result["flow_id"], user_input=MOCK_USER_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
|
||||
@ -111,7 +110,7 @@ async def test_exception_connection(hass: HomeAssistant, side_effect, error) ->
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "fake_host"
|
||||
assert result2["data"] == {
|
||||
"host": "fake_host",
|
||||
@ -143,7 +142,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(
|
||||
@ -154,7 +153,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"
|
||||
|
||||
|
||||
@ -191,7 +190,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(
|
||||
@ -201,7 +200,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
|
||||
@ -233,7 +232,7 @@ async def test_reauth_not_successful(hass: HomeAssistant, side_effect, error) ->
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@ -253,7 +252,7 @@ async def test_options_flow(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_CONSIDER_HOME: 37,
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import voip
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
@ -29,7 +29,7 @@ async def test_form_user(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"] == {}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
@ -59,7 +59,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"
|
||||
|
||||
# Default
|
||||
@ -67,7 +67,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert config_entry.options == {"sip_port": 5060}
|
||||
|
||||
# Manual
|
||||
@ -78,5 +78,5 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={"sip_port": 5061},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert config_entry.options == {"sip_port": 5061}
|
||||
|
@ -17,7 +17,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 len(result["errors"]) == 0
|
||||
|
||||
with (
|
||||
@ -39,7 +39,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"] == {
|
||||
"username": "test-username",
|
||||
@ -74,7 +74,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ async def test_flow_already_configured(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 len(result["errors"]) == 0
|
||||
|
||||
with (
|
||||
@ -108,7 +108,7 @@ async def test_flow_already_configured(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"
|
||||
|
||||
|
||||
@ -133,7 +133,7 @@ async def test_form_other_exception(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@ -162,7 +162,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||
)
|
||||
|
||||
# the first form is just the confirmation prompt
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -171,7 +171,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# the second form is the user flow where reauth happens
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
|
||||
with patch("volvooncall.Connection.get"):
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@ -186,5 +186,5 @@ async def test_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"
|
||||
|
@ -14,11 +14,12 @@ from vulcan import (
|
||||
)
|
||||
from vulcan.model import Student
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.vulcan import config_flow, const, register
|
||||
from homeassistant.components.vulcan.config_flow import ClientConnectionError, Keystore
|
||||
from homeassistant.const import CONF_PIN, CONF_REGION, CONF_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry, load_fixture
|
||||
|
||||
@ -38,7 +39,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"] == "auth"
|
||||
|
||||
|
||||
@ -58,7 +59,7 @@ async def test_config_flow_auth_success(
|
||||
const.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"] == "auth"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -72,7 +73,7 @@ async def test_config_flow_auth_success(
|
||||
)
|
||||
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"] == "Jan Kowalski"
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
@ -97,7 +98,7 @@ async def test_config_flow_auth_success_with_multiple_students(
|
||||
const.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"] == "auth"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -106,7 +107,7 @@ async def test_config_flow_auth_success_with_multiple_students(
|
||||
{CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "select_student"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -119,7 +120,7 @@ async def test_config_flow_auth_success_with_multiple_students(
|
||||
{"student": "0"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Jan Kowalski"
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
@ -145,7 +146,7 @@ async def test_config_flow_reauth_success(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_REAUTH}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -158,7 +159,7 @@ async def test_config_flow_reauth_success(
|
||||
{CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
@ -184,7 +185,7 @@ async def test_config_flow_reauth_without_matching_entries(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_REAUTH}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -193,7 +194,7 @@ async def test_config_flow_reauth_without_matching_entries(
|
||||
{CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "no_matching_entries"
|
||||
|
||||
|
||||
@ -208,7 +209,7 @@ async def test_config_flow_reauth_with_errors(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_REAUTH}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["errors"] == {}
|
||||
with patch(
|
||||
@ -220,7 +221,7 @@ async def test_config_flow_reauth_with_errors(
|
||||
{CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
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_token"}
|
||||
|
||||
@ -233,7 +234,7 @@ async def test_config_flow_reauth_with_errors(
|
||||
{CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["errors"] == {"base": "expired_token"}
|
||||
|
||||
@ -246,7 +247,7 @@ async def test_config_flow_reauth_with_errors(
|
||||
{CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
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_pin"}
|
||||
|
||||
@ -259,7 +260,7 @@ async def test_config_flow_reauth_with_errors(
|
||||
{CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
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_symbol"}
|
||||
|
||||
@ -272,7 +273,7 @@ async def test_config_flow_reauth_with_errors(
|
||||
{CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@ -285,7 +286,7 @@ async def test_config_flow_reauth_with_errors(
|
||||
{CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["errors"] == {"base": "unknown"}
|
||||
|
||||
@ -312,7 +313,7 @@ async def test_multiple_config_entries(
|
||||
const.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"] == "add_next_config_entry"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -321,7 +322,7 @@ async def test_multiple_config_entries(
|
||||
{"use_saved_credentials": False},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -334,7 +335,7 @@ async def test_multiple_config_entries(
|
||||
{CONF_TOKEN: "token", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Jan Kowalski"
|
||||
assert len(mock_setup_entry.mock_calls) == 2
|
||||
|
||||
@ -357,7 +358,7 @@ async def test_multiple_config_entries_using_saved_credentials(
|
||||
const.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"] == "add_next_config_entry"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -370,7 +371,7 @@ async def test_multiple_config_entries_using_saved_credentials(
|
||||
{"use_saved_credentials": True},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Jan Kowalski"
|
||||
assert len(mock_setup_entry.mock_calls) == 2
|
||||
|
||||
@ -394,7 +395,7 @@ async def test_multiple_config_entries_using_saved_credentials_2(
|
||||
const.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"] == "add_next_config_entry"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -403,7 +404,7 @@ async def test_multiple_config_entries_using_saved_credentials_2(
|
||||
{"use_saved_credentials": True},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "select_student"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -416,7 +417,7 @@ async def test_multiple_config_entries_using_saved_credentials_2(
|
||||
{"student": "0"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Jan Kowalski"
|
||||
assert len(mock_setup_entry.mock_calls) == 2
|
||||
|
||||
@ -447,7 +448,7 @@ async def test_multiple_config_entries_using_saved_credentials_3(
|
||||
const.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"] == "add_next_config_entry"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -456,7 +457,7 @@ async def test_multiple_config_entries_using_saved_credentials_3(
|
||||
{"use_saved_credentials": True},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "select_saved_credentials"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -469,7 +470,7 @@ async def test_multiple_config_entries_using_saved_credentials_3(
|
||||
{"credentials": "123"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Jan Kowalski"
|
||||
assert len(mock_setup_entry.mock_calls) == 3
|
||||
|
||||
@ -501,7 +502,7 @@ async def test_multiple_config_entries_using_saved_credentials_4(
|
||||
const.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"] == "add_next_config_entry"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -510,7 +511,7 @@ async def test_multiple_config_entries_using_saved_credentials_4(
|
||||
{"use_saved_credentials": True},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "select_saved_credentials"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -519,7 +520,7 @@ async def test_multiple_config_entries_using_saved_credentials_4(
|
||||
{"credentials": "123"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "select_student"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -532,7 +533,7 @@ async def test_multiple_config_entries_using_saved_credentials_4(
|
||||
{"student": "0"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Jan Kowalski"
|
||||
assert len(mock_setup_entry.mock_calls) == 3
|
||||
|
||||
@ -559,7 +560,7 @@ async def test_multiple_config_entries_without_valid_saved_credentials(
|
||||
const.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"] == "add_next_config_entry"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -571,7 +572,7 @@ async def test_multiple_config_entries_without_valid_saved_credentials(
|
||||
"homeassistant.components.vulcan.config_flow.Vulcan.get_students",
|
||||
side_effect=UnauthorizedCertificateException,
|
||||
):
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "select_saved_credentials"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -580,7 +581,7 @@ async def test_multiple_config_entries_without_valid_saved_credentials(
|
||||
{"credentials": "123"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth"
|
||||
assert result["errors"] == {"base": "expired_credentials"}
|
||||
|
||||
@ -607,7 +608,7 @@ async def test_multiple_config_entries_using_saved_credentials_with_connections_
|
||||
const.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"] == "add_next_config_entry"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -619,7 +620,7 @@ async def test_multiple_config_entries_using_saved_credentials_with_connections_
|
||||
"homeassistant.components.vulcan.config_flow.Vulcan.get_students",
|
||||
side_effect=ClientConnectionError,
|
||||
):
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "select_saved_credentials"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -628,7 +629,7 @@ async def test_multiple_config_entries_using_saved_credentials_with_connections_
|
||||
{"credentials": "123"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "select_saved_credentials"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@ -655,7 +656,7 @@ async def test_multiple_config_entries_using_saved_credentials_with_unknown_erro
|
||||
const.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"] == "add_next_config_entry"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -667,7 +668,7 @@ async def test_multiple_config_entries_using_saved_credentials_with_unknown_erro
|
||||
"homeassistant.components.vulcan.config_flow.Vulcan.get_students",
|
||||
side_effect=Exception,
|
||||
):
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "select_saved_credentials"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -676,7 +677,7 @@ async def test_multiple_config_entries_using_saved_credentials_with_unknown_erro
|
||||
{"credentials": "123"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth"
|
||||
assert result["errors"] == {"base": "unknown"}
|
||||
|
||||
@ -706,7 +707,7 @@ async def test_student_already_exists(
|
||||
const.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"] == "add_next_config_entry"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -715,7 +716,7 @@ async def test_student_already_exists(
|
||||
{"use_saved_credentials": True},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "all_student_already_configured"
|
||||
|
||||
|
||||
@ -733,7 +734,7 @@ async def test_config_flow_auth_invalid_token(
|
||||
const.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"] == "auth"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -742,7 +743,7 @@ async def test_config_flow_auth_invalid_token(
|
||||
{CONF_TOKEN: "3S20000", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth"
|
||||
assert result["errors"] == {"base": "invalid_token"}
|
||||
|
||||
@ -761,7 +762,7 @@ async def test_config_flow_auth_invalid_region(
|
||||
const.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"] == "auth"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -770,7 +771,7 @@ async def test_config_flow_auth_invalid_region(
|
||||
{CONF_TOKEN: "3S10000", CONF_REGION: "invalid_region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth"
|
||||
assert result["errors"] == {"base": "invalid_symbol"}
|
||||
|
||||
@ -787,7 +788,7 @@ async def test_config_flow_auth_invalid_pin(mock_keystore, hass: HomeAssistant)
|
||||
const.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"] == "auth"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -796,7 +797,7 @@ async def test_config_flow_auth_invalid_pin(mock_keystore, hass: HomeAssistant)
|
||||
{CONF_TOKEN: "3S10000", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth"
|
||||
assert result["errors"] == {"base": "invalid_pin"}
|
||||
|
||||
@ -815,7 +816,7 @@ async def test_config_flow_auth_expired_token(
|
||||
const.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"] == "auth"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -824,7 +825,7 @@ async def test_config_flow_auth_expired_token(
|
||||
{CONF_TOKEN: "3S10000", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth"
|
||||
assert result["errors"] == {"base": "expired_token"}
|
||||
|
||||
@ -843,7 +844,7 @@ async def test_config_flow_auth_connection_error(
|
||||
const.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"] == "auth"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -852,7 +853,7 @@ async def test_config_flow_auth_connection_error(
|
||||
{CONF_TOKEN: "3S10000", CONF_REGION: "region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@ -871,7 +872,7 @@ async def test_config_flow_auth_unknown_error(
|
||||
const.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"] == "auth"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -880,6 +881,6 @@ async def test_config_flow_auth_unknown_error(
|
||||
{CONF_TOKEN: "3S10000", CONF_REGION: "invalid_region", CONF_PIN: "000000"},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth"
|
||||
assert result["errors"] == {"base": "unknown"}
|
||||
|
@ -5,7 +5,7 @@ import json
|
||||
|
||||
import requests_mock
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.wallbox import config_flow
|
||||
from homeassistant.components.wallbox.const import (
|
||||
CHARGER_ADDED_ENERGY_KEY,
|
||||
@ -18,6 +18,7 @@ from homeassistant.components.wallbox.const import (
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from . import (
|
||||
authorisation_response,
|
||||
@ -47,7 +48,7 @@ async def test_show_set_form(hass: HomeAssistant) -> None:
|
||||
flow.hass = hass
|
||||
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"
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ async def test_full_map_flow(
|
||||
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
|
||||
|
||||
with (
|
||||
patch(
|
||||
@ -71,7 +71,7 @@ async def test_full_map_flow(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == method
|
||||
|
||||
with (
|
||||
@ -97,7 +97,7 @@ async def test_full_map_flow(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "de Jongweg, Utrecht"
|
||||
assert result["data"] == {
|
||||
CONF_API_KEY: "asd",
|
||||
@ -137,7 +137,7 @@ async def test_flow_errors(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": error}
|
||||
|
||||
with (
|
||||
@ -157,7 +157,7 @@ async def test_flow_errors(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "map"
|
||||
|
||||
with (
|
||||
@ -179,7 +179,7 @@ async def test_flow_errors(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@ -231,7 +231,7 @@ async def test_error_in_second_step(
|
||||
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
|
||||
|
||||
with (
|
||||
patch(
|
||||
@ -250,7 +250,7 @@ async def test_error_in_second_step(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == method
|
||||
|
||||
with (
|
||||
@ -266,7 +266,7 @@ async def test_error_in_second_step(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": error}
|
||||
|
||||
with (
|
||||
@ -292,7 +292,7 @@ async def test_error_in_second_step(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "de Jongweg, Utrecht"
|
||||
assert result["data"] == {
|
||||
CONF_API_KEY: "asd",
|
||||
|
@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, patch
|
||||
from aiowatttime.errors import CoordinatesNotFoundError, InvalidCredentialsError
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.watttime.config_flow import (
|
||||
CONF_LOCATION_TYPE,
|
||||
LOCATION_TYPE_HOME,
|
||||
@ -41,7 +41,7 @@ async def test_auth_errors(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=config_auth
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": error}
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ async def test_coordinate_errors(
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=config_coordinates
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == errors
|
||||
|
||||
|
||||
@ -93,7 +93,7 @@ async def test_duplicate_error(
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=config_location_type
|
||||
)
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -104,13 +104,13 @@ async def test_options_flow(hass: HomeAssistant, config_entry) -> None:
|
||||
):
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
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}
|
||||
|
||||
|
||||
@ -128,7 +128,7 @@ async def test_show_form_coordinates(
|
||||
result["flow_id"], user_input=config_location_type
|
||||
)
|
||||
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"] == "coordinates"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -138,7 +138,7 @@ async def test_show_form_user(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"] is None
|
||||
|
||||
@ -164,7 +164,7 @@ async def test_step_reauth(
|
||||
user_input={CONF_PASSWORD: "password"},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
assert len(hass.config_entries.async_entries()) == 1
|
||||
|
||||
@ -186,7 +186,7 @@ async def test_step_user_coordinates(
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=config_coordinates
|
||||
)
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "32.87336, -117.22743"
|
||||
assert result["data"] == {
|
||||
CONF_USERNAME: "user",
|
||||
@ -211,7 +211,7 @@ async def test_step_user_home(
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=config_location_type
|
||||
)
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "32.87336, -117.22743"
|
||||
assert result["data"] == {
|
||||
CONF_USERNAME: "user",
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.waze_travel_time.const import (
|
||||
CONF_AVOID_FERRIES,
|
||||
CONF_AVOID_SUBSCRIPTION_ROADS,
|
||||
@ -21,6 +21,7 @@ from homeassistant.components.waze_travel_time.const import (
|
||||
)
|
||||
from homeassistant.const import CONF_NAME, CONF_REGION
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from .const import CONFIG_FLOW_USER_INPUT, MOCK_CONFIG
|
||||
|
||||
@ -33,7 +34,7 @@ async def test_minimum_fields(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"] == {}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@ -42,7 +43,7 @@ async def test_minimum_fields(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"] == DEFAULT_NAME
|
||||
assert result2["data"] == {
|
||||
CONF_NAME: DEFAULT_NAME,
|
||||
@ -65,7 +66,7 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id, 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(
|
||||
@ -81,7 +82,7 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||
CONF_VEHICLE_TYPE: "taxi",
|
||||
},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == ""
|
||||
assert result["data"] == {
|
||||
CONF_AVOID_FERRIES: True,
|
||||
@ -112,7 +113,7 @@ async def test_dupe(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"] == {}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@ -121,13 +122,13 @@ async def test_dupe(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
|
||||
|
||||
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(
|
||||
@ -136,7 +137,7 @@ async def test_dupe(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
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("invalidate_config_entry")
|
||||
@ -147,14 +148,14 @@ async def test_invalid_config_entry(
|
||||
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_FLOW_USER_INPUT,
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
assert "Error trying to validate entry" in caplog.text
|
||||
|
@ -30,7 +30,7 @@ async def test_single_instance(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_USER},
|
||||
)
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ async def test_devices_with_mocks(
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {}
|
||||
|
||||
|
||||
@ -80,12 +80,12 @@ async def test_devices_with_various_mocks_errors(
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"]["base"] == error_msg
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {}
|
||||
|
@ -17,7 +17,7 @@ async def test_config(hass: HomeAssistant, mock_get_stations) -> 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"] == {}
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -27,7 +27,7 @@ async def test_config(hass: HomeAssistant, mock_get_stations) -> None:
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_config_flow_abort(hass: HomeAssistant, mock_get_stations) -> None:
|
||||
@ -43,7 +43,7 @@ async def test_config_flow_abort(hass: HomeAssistant, mock_get_stations) -> 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
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{
|
||||
@ -51,7 +51,7 @@ async def test_config_flow_abort(hass: HomeAssistant, mock_get_stations) -> None
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ async def test_config_errors(
|
||||
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_configure(
|
||||
@ -80,7 +80,7 @@ async def test_config_errors(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": expected_error}
|
||||
|
||||
with mock_get_stations:
|
||||
@ -90,7 +90,7 @@ async def test_config_errors(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_reauth(hass: HomeAssistant, mock_get_stations_401_error) -> None:
|
||||
@ -110,7 +110,7 @@ async def test_reauth(hass: HomeAssistant, mock_get_stations_401_error) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_REAUTH, "entry_id": entry.entry_id}, data=None
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_REAUTH, "entry_id": entry.entry_id},
|
||||
@ -118,4 +118,4 @@ async def test_reauth(hass: HomeAssistant, mock_get_stations_401_error) -> None:
|
||||
)
|
||||
|
||||
assert result["reason"] == "reauth_successful"
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
|
@ -46,7 +46,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(
|
||||
@ -59,7 +59,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
location = EXAMPLE_USER_INPUT[CONF_LOCATION]
|
||||
assert result["title"] == f"{location[CONF_LATITUDE]}, {location[CONF_LONGITUDE]}"
|
||||
@ -94,7 +94,7 @@ async def test_error_handling(
|
||||
EXAMPLE_USER_INPUT,
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": expected_error}
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ async def test_form_unsupported_location(hass: HomeAssistant) -> None:
|
||||
EXAMPLE_USER_INPUT,
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "unsupported_location"}
|
||||
|
||||
# Test that we can recover from this error by changing the location
|
||||
@ -126,7 +126,7 @@ async def test_form_unsupported_location(hass: HomeAssistant) -> None:
|
||||
EXAMPLE_USER_INPUT,
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@ -159,7 +159,7 @@ async def test_auto_fix_key_input(
|
||||
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(
|
||||
@ -174,7 +174,7 @@ async def test_auto_fix_key_input(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
assert result["data"][CONF_KEY_PEM] == EXAMPLE_CONFIG_DATA[CONF_KEY_PEM]
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
@ -28,7 +28,7 @@ async def user_flow(hass: HomeAssistant) -> str:
|
||||
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
|
||||
return result["flow_id"]
|
||||
|
||||
@ -47,7 +47,7 @@ async def test_form_user(
|
||||
user_flow, TEST_USER_INPUT
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_USER_INPUT[CONF_HOST]
|
||||
assert result["options"] == TEST_USER_INPUT
|
||||
|
||||
@ -89,7 +89,7 @@ async def test_form_user_errors(
|
||||
user_flow, TEST_USER_INPUT
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": error_type}
|
||||
|
||||
@ -101,7 +101,7 @@ async def test_form_user_errors(
|
||||
result["flow_id"], TEST_USER_INPUT
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_USER_INPUT[CONF_HOST]
|
||||
assert result["options"] == TEST_USER_INPUT
|
||||
|
||||
@ -121,7 +121,7 @@ async def test_duplicate_entry(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_USER_INPUT[CONF_HOST]
|
||||
assert result["options"] == TEST_USER_INPUT
|
||||
|
||||
@ -137,5 +137,5 @@ async def test_duplicate_entry(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
@ -45,7 +45,7 @@ async def test_form(hass: HomeAssistant, client) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -55,7 +55,7 @@ async def test_form(hass: HomeAssistant, client) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -65,7 +65,7 @@ async def test_form(hass: HomeAssistant, client) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@ -74,7 +74,7 @@ async def test_form(hass: HomeAssistant, client) -> None:
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TV_NAME
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ async def test_options_flow_live_tv_in_apps(
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
result2 = await hass.config_entries.options.async_configure(
|
||||
@ -115,7 +115,7 @@ async def test_options_flow_live_tv_in_apps(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"][CONF_SOURCES] == ["Live TV", "Input01", "Input02"]
|
||||
|
||||
|
||||
@ -127,7 +127,7 @@ async def test_options_flow_cannot_retrieve(hass: HomeAssistant, client) -> None
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "cannot_retrieve"}
|
||||
|
||||
|
||||
@ -145,7 +145,7 @@ async def test_form_cannot_connect(hass: HomeAssistant, client) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@ async def test_form_pairexception(hass: HomeAssistant, client) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "error_pairing"
|
||||
|
||||
|
||||
@ -178,7 +178,7 @@ async def test_entry_already_configured(hass: HomeAssistant, client) -> None:
|
||||
data=MOCK_USER_CONFIG,
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -191,7 +191,7 @@ async def test_form_ssdp(hass: HomeAssistant, client) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
|
||||
|
||||
@ -206,7 +206,7 @@ async def test_ssdp_in_progress(hass: HomeAssistant, client) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_init(
|
||||
@ -214,7 +214,7 @@ async def test_ssdp_in_progress(hass: HomeAssistant, client) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_in_progress"
|
||||
|
||||
|
||||
@ -229,7 +229,7 @@ async def test_ssdp_update_uuid(hass: HomeAssistant, client) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.unique_id == MOCK_DISCOVERY_INFO.upnp[ssdp.ATTR_UPNP_UDN][5:]
|
||||
|
||||
@ -248,7 +248,7 @@ async def test_ssdp_not_update_uuid(hass: HomeAssistant, client) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "pairing"
|
||||
assert entry.unique_id is None
|
||||
|
||||
@ -266,7 +266,7 @@ async def test_form_abort_uuid_configured(hass: HomeAssistant, client) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
user_config = {
|
||||
@ -281,7 +281,7 @@ async def test_form_abort_uuid_configured(hass: HomeAssistant, client) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@ -290,7 +290,7 @@ async def test_form_abort_uuid_configured(hass: HomeAssistant, client) -> None:
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_HOST] == "new_host"
|
||||
|
||||
@ -309,7 +309,7 @@ async def test_reauth_successful(hass: HomeAssistant, client, monkeypatch) -> No
|
||||
|
||||
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 entry.data[CONF_CLIENT_SECRET] == CLIENT_KEY
|
||||
|
||||
@ -318,7 +318,7 @@ async def test_reauth_successful(hass: HomeAssistant, client, monkeypatch) -> No
|
||||
result["flow_id"], user_input={}
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
assert entry.data[CONF_CLIENT_SECRET] == "new_key"
|
||||
|
||||
@ -346,7 +346,7 @@ async def test_reauth_errors(
|
||||
|
||||
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"
|
||||
|
||||
monkeypatch.setattr(client, "connect", Mock(side_effect=side_effect))
|
||||
@ -354,5 +354,5 @@ async def test_reauth_errors(
|
||||
result["flow_id"], user_input={}
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == reason
|
||||
|
@ -21,7 +21,7 @@ async def test_not_discovered(hass: HomeAssistant) -> None:
|
||||
with patch("homeassistant.components.wemo.config_flow.pywemo") as mock_pywemo:
|
||||
mock_pywemo.discover_devices.return_value = []
|
||||
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"] == "no_devices_found"
|
||||
|
||||
|
||||
@ -33,14 +33,14 @@ async def test_options(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(
|
||||
result["flow_id"], user_input=asdict(options)
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert Options(**result["data"]) == options
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ async def test_invalid_options(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"
|
||||
|
||||
# enable_subscription must be True if enable_long_press is True (default).
|
||||
|
@ -202,7 +202,7 @@ async def test_no_appliances_flow(hass: HomeAssistant, region, brand) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == config_entries.SOURCE_USER
|
||||
|
||||
with (
|
||||
@ -222,7 +222,7 @@ async def test_no_appliances_flow(hass: HomeAssistant, region, brand) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "no_appliances"}
|
||||
|
||||
|
||||
@ -246,7 +246,7 @@ async def test_reauth_flow(hass: HomeAssistant, region, brand) -> None:
|
||||
)
|
||||
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@ -274,7 +274,7 @@ async def test_reauth_flow(hass: HomeAssistant, region, brand) -> None:
|
||||
)
|
||||
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",
|
||||
@ -310,7 +310,7 @@ async def test_reauth_flow_auth_error(hass: HomeAssistant, region, brand) -> Non
|
||||
)
|
||||
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
with (
|
||||
patch(
|
||||
@ -329,7 +329,7 @@ async def test_reauth_flow_auth_error(hass: HomeAssistant, region, brand) -> Non
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@ -356,7 +356,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"] == {}
|
||||
|
||||
with (
|
||||
@ -379,5 +379,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"}
|
||||
|
@ -31,7 +31,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(
|
||||
@ -39,7 +39,7 @@ async def test_full_user_flow(
|
||||
user_input={CONF_DOMAIN: "Example.com"},
|
||||
)
|
||||
|
||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result2 == snapshot
|
||||
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@ -71,7 +71,7 @@ async def test_full_flow_with_error(
|
||||
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_whois.side_effect = throw
|
||||
@ -80,7 +80,7 @@ async def test_full_flow_with_error(
|
||||
user_input={CONF_DOMAIN: "Example.com"},
|
||||
)
|
||||
|
||||
assert result2.get("type") == FlowResultType.FORM
|
||||
assert result2.get("type") is FlowResultType.FORM
|
||||
assert result2.get("step_id") == "user"
|
||||
assert result2.get("errors") == {"base": reason}
|
||||
|
||||
@ -93,7 +93,7 @@ async def test_full_flow_with_error(
|
||||
user_input={CONF_DOMAIN: "Example.com"},
|
||||
)
|
||||
|
||||
assert result3.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result3.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result3 == snapshot
|
||||
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@ -115,7 +115,7 @@ async def test_already_configured(
|
||||
data={CONF_DOMAIN: "HOME-Assistant.io"},
|
||||
)
|
||||
|
||||
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
|
||||
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.wiffi.const import DOMAIN
|
||||
from homeassistant.const import CONF_PORT, CONF_TIMEOUT
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -77,7 +77,7 @@ async def test_form(hass: HomeAssistant, dummy_tcp_server) -> 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"] == {}
|
||||
assert result["step_id"] == config_entries.SOURCE_USER
|
||||
|
||||
@ -85,7 +85,7 @@ async def test_form(hass: HomeAssistant, dummy_tcp_server) -> None:
|
||||
result["flow_id"],
|
||||
user_input=MOCK_CONFIG,
|
||||
)
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_form_addr_in_use(hass: HomeAssistant, addr_in_use) -> None:
|
||||
@ -98,7 +98,7 @@ async def test_form_addr_in_use(hass: HomeAssistant, addr_in_use) -> None:
|
||||
result["flow_id"],
|
||||
user_input=MOCK_CONFIG,
|
||||
)
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "addr_in_use"
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ async def test_form_start_server_failed(
|
||||
result["flow_id"],
|
||||
user_input=MOCK_CONFIG,
|
||||
)
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "start_server_failed"
|
||||
|
||||
|
||||
@ -127,13 +127,13 @@ async def test_option_flow(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id, 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(
|
||||
result["flow_id"], user_input={CONF_TIMEOUT: 9}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == ""
|
||||
assert result["data"][CONF_TIMEOUT] == 9
|
||||
|
@ -59,7 +59,7 @@ async def test_show_ssdp_form(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
assert result["description_placeholders"] == {
|
||||
CONF_NAME: f"WL{WILIGHT_ID}",
|
||||
@ -75,7 +75,7 @@ async def test_ssdp_not_wilight_abort_1(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_wilight_device"
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ async def test_ssdp_not_wilight_abort_2(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_wilight_device"
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ async def test_ssdp_not_wilight_abort_3(
|
||||
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_wilight_device"
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ async def test_ssdp_not_supported_abort(
|
||||
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_supported_device"
|
||||
|
||||
|
||||
@ -140,7 +140,7 @@ async def test_ssdp_device_exists_abort(hass: HomeAssistant) -> None:
|
||||
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_full_ssdp_flow_implementation(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
assert result["description_placeholders"] == {
|
||||
CONF_NAME: f"WL{WILIGHT_ID}",
|
||||
@ -163,7 +163,7 @@ async def test_full_ssdp_flow_implementation(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], user_input={}
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == f"WL{WILIGHT_ID}"
|
||||
|
||||
assert result["data"]
|
||||
|
@ -34,7 +34,7 @@ async def test_full_flow(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.EXTERNAL_STEP
|
||||
assert result["type"] is FlowResultType.EXTERNAL_STEP
|
||||
assert result["url"] == (
|
||||
"https://account.withings.com/oauth2_user/authorize2?"
|
||||
f"response_type=code&client_id={CLIENT_ID}&"
|
||||
@ -69,7 +69,7 @@ async def test_full_flow(
|
||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Withings"
|
||||
assert "result" in result
|
||||
assert result["result"].unique_id == "600"
|
||||
@ -100,7 +100,7 @@ async def test_config_non_unique_profile(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.EXTERNAL_STEP
|
||||
assert result["type"] is FlowResultType.EXTERNAL_STEP
|
||||
assert result["url"] == (
|
||||
"https://account.withings.com/oauth2_user/authorize2?"
|
||||
f"response_type=code&client_id={CLIENT_ID}&"
|
||||
@ -128,7 +128,7 @@ async def test_config_non_unique_profile(
|
||||
},
|
||||
)
|
||||
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"] == "already_configured"
|
||||
|
||||
|
||||
@ -190,7 +190,7 @@ async def test_config_reauth_profile(
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@ -252,7 +252,7 @@ async def test_config_reauth_wrong_account(
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "wrong_account"
|
||||
|
||||
|
||||
@ -276,7 +276,7 @@ async def test_config_flow_with_invalid_credentials(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.EXTERNAL_STEP
|
||||
assert result["type"] is FlowResultType.EXTERNAL_STEP
|
||||
assert result["url"] == (
|
||||
"https://account.withings.com/oauth2_user/authorize2?"
|
||||
f"response_type=code&client_id={CLIENT_ID}&"
|
||||
@ -303,5 +303,5 @@ async def test_config_flow_with_invalid_credentials(
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "oauth_error"
|
||||
|
@ -91,7 +91,7 @@ async def test_user_flow_enters_dns_name(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "no_ip"}
|
||||
|
||||
with (
|
||||
@ -193,7 +193,7 @@ async def test_discovered_by_dhcp_connection_fails(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@ -270,7 +270,7 @@ async def test_discovered_by_dhcp_or_integration_discovery(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "discovery_confirm"
|
||||
|
||||
with (
|
||||
@ -324,7 +324,7 @@ async def test_discovered_by_dhcp_or_integration_discovery_updates_host(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_HOST] == FAKE_IP
|
||||
|
||||
@ -353,7 +353,7 @@ async def test_discovered_by_dhcp_or_integration_discovery_avoid_waiting_for_ret
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.state is config_entries.ConfigEntryState.LOADED
|
||||
|
||||
@ -483,7 +483,7 @@ async def test_setup_via_discovery_exception_finds_nothing(hass: HomeAssistant)
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
@ -501,7 +501,7 @@ async def test_discovery_with_firmware_update(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "discovery_confirm"
|
||||
|
||||
# In between discovery and when the user clicks to set it up the firmware
|
||||
|
@ -25,14 +25,14 @@ async def test_full_user_flow_implementation(hass: HomeAssistant) -> None:
|
||||
)
|
||||
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={CONF_HOST: "192.168.1.123"}
|
||||
)
|
||||
|
||||
assert result.get("title") == "WLED RGB Light"
|
||||
assert result.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert "data" in result
|
||||
assert result["data"][CONF_HOST] == "192.168.1.123"
|
||||
assert "result" in result
|
||||
@ -64,14 +64,14 @@ async def test_full_zeroconf_flow_implementation(hass: HomeAssistant) -> None:
|
||||
)
|
||||
assert result.get("description_placeholders") == {CONF_NAME: "WLED RGB Light"}
|
||||
assert result.get("step_id") == "zeroconf_confirm"
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={}
|
||||
)
|
||||
|
||||
assert result2.get("title") == "WLED RGB Light"
|
||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||
|
||||
assert "data" in result2
|
||||
assert result2["data"][CONF_HOST] == "192.168.1.123"
|
||||
@ -101,7 +101,7 @@ async def test_zeroconf_during_onboarding(
|
||||
)
|
||||
|
||||
assert result.get("title") == "WLED RGB Light"
|
||||
assert result.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
|
||||
assert result.get("data") == {CONF_HOST: "192.168.1.123"}
|
||||
assert "result" in result
|
||||
@ -120,7 +120,7 @@ async def test_connection_error(hass: HomeAssistant, mock_wled: MagicMock) -> No
|
||||
data={CONF_HOST: "example.com"},
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("errors") == {"base": "cannot_connect"}
|
||||
|
||||
@ -145,7 +145,7 @@ async def test_zeroconf_connection_error(
|
||||
),
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "cannot_connect"
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@ async def test_user_device_exists_abort(
|
||||
data={CONF_HOST: "192.168.1.123"},
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
|
||||
|
||||
@ -180,7 +180,7 @@ async def test_user_with_cct_channel_abort(
|
||||
data={CONF_HOST: "192.168.1.123"},
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "cct_unsupported"
|
||||
|
||||
|
||||
@ -205,7 +205,7 @@ async def test_zeroconf_without_mac_device_exists_abort(
|
||||
),
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
|
||||
|
||||
@ -230,7 +230,7 @@ async def test_zeroconf_with_mac_device_exists_abort(
|
||||
),
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
|
||||
|
||||
@ -255,7 +255,7 @@ async def test_zeroconf_with_cct_channel_abort(
|
||||
),
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "cct_unsupported"
|
||||
|
||||
|
||||
@ -267,7 +267,7 @@ async def test_options_flow(
|
||||
|
||||
result = await hass.config_entries.options.async_init(mock_config_entry.entry_id)
|
||||
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "init"
|
||||
|
||||
result2 = await hass.config_entries.options.async_configure(
|
||||
@ -275,7 +275,7 @@ async def test_options_flow(
|
||||
user_input={CONF_KEEP_MAIN_LIGHT: True},
|
||||
)
|
||||
|
||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result2.get("data") == {
|
||||
CONF_KEEP_MAIN_LIGHT: True,
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ from httpcore import ConnectError
|
||||
from wolf_comm.models import Device
|
||||
from wolf_comm.token_auth import InvalidAuth
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.wolflink.const import (
|
||||
DEVICE_GATEWAY,
|
||||
DEVICE_ID,
|
||||
@ -15,6 +15,7 @@ from homeassistant.components.wolflink.const import (
|
||||
)
|
||||
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
|
||||
|
||||
@ -40,7 +41,7 @@ async def test_show_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["step_id"] == "user"
|
||||
|
||||
|
||||
@ -54,7 +55,7 @@ async def test_device_step_form(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=INPUT_CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "device"
|
||||
|
||||
|
||||
@ -76,7 +77,7 @@ async def test_create_entry(hass: HomeAssistant) -> None:
|
||||
{"device_name": CONFIG[DEVICE_NAME]},
|
||||
)
|
||||
|
||||
assert result_create_entry["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result_create_entry["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result_create_entry["title"] == CONFIG[DEVICE_NAME]
|
||||
assert result_create_entry["data"] == CONFIG
|
||||
|
||||
@ -145,5 +146,5 @@ async def test_already_configured_error(hass: HomeAssistant) -> None:
|
||||
{"device_name": CONFIG[DEVICE_NAME]},
|
||||
)
|
||||
|
||||
assert result_create_entry["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result_create_entry["type"] is FlowResultType.ABORT
|
||||
assert result_create_entry["reason"] == "already_configured"
|
||||
|
@ -35,7 +35,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
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -58,7 +58,7 @@ async def test_form(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"] == "Workday Sensor"
|
||||
assert result3["options"] == {
|
||||
"name": "Workday Sensor",
|
||||
@ -78,7 +78,7 @@ async def test_form_no_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
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -99,7 +99,7 @@ async def test_form_no_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"] == "Workday Sensor"
|
||||
assert result3["options"] == {
|
||||
"name": "Workday Sensor",
|
||||
@ -117,7 +117,7 @@ async def test_form_no_subdivision(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
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -139,7 +139,7 @@ async def test_form_no_subdivision(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"] == "Workday Sensor"
|
||||
assert result3["options"] == {
|
||||
"name": "Workday Sensor",
|
||||
@ -185,7 +185,7 @@ async def test_options_form(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == {
|
||||
"name": "Workday Sensor",
|
||||
"country": "DE",
|
||||
@ -205,7 +205,7 @@ async def test_form_incorrect_dates(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
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -257,7 +257,7 @@ async def test_form_incorrect_dates(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"] == "Workday Sensor"
|
||||
assert result3["options"] == {
|
||||
"name": "Workday Sensor",
|
||||
@ -333,7 +333,7 @@ async def test_options_form_incorrect_dates(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == {
|
||||
"name": "Workday Sensor",
|
||||
"country": "DE",
|
||||
@ -392,7 +392,7 @@ async def test_options_form_abort_duplicate(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "already_configured"}
|
||||
|
||||
|
||||
@ -402,7 +402,7 @@ async def test_form_incorrect_date_range(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
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@ -454,7 +454,7 @@ async def test_form_incorrect_date_range(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"] == "Workday Sensor"
|
||||
assert result3["options"] == {
|
||||
"name": "Workday Sensor",
|
||||
@ -530,7 +530,7 @@ async def test_options_form_incorrect_date_ranges(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == {
|
||||
"name": "Workday Sensor",
|
||||
"country": "DE",
|
||||
@ -563,7 +563,7 @@ async def test_language(
|
||||
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"],
|
||||
@ -586,7 +586,7 @@ async def test_language(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "Workday Sensor"
|
||||
assert result3["options"] == {
|
||||
"name": "Workday Sensor",
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.ws66i.const import (
|
||||
CONF_SOURCE_1,
|
||||
CONF_SOURCE_2,
|
||||
@ -16,6 +16,7 @@ from homeassistant.components.ws66i.const import (
|
||||
)
|
||||
from homeassistant.const import CONF_IP_ADDRESS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from .test_media_player import AttrDict
|
||||
|
||||
@ -130,7 +131,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(
|
||||
@ -145,7 +146,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_SOURCES] == {
|
||||
"1": "one",
|
||||
"2": "too",
|
||||
|
@ -46,7 +46,7 @@ async def test_form_stt(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> Non
|
||||
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(
|
||||
@ -62,7 +62,7 @@ async def test_form_stt(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> Non
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Test ASR"
|
||||
assert result2["data"] == {
|
||||
"host": "1.1.1.1",
|
||||
@ -76,7 +76,7 @@ async def test_form_tts(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> Non
|
||||
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(
|
||||
@ -92,7 +92,7 @@ async def test_form_tts(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> Non
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Test TTS"
|
||||
assert result2["data"] == {
|
||||
"host": "1.1.1.1",
|
||||
@ -119,7 +119,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"}
|
||||
|
||||
|
||||
@ -141,7 +141,7 @@ async def test_no_supported_services(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "no_services"
|
||||
|
||||
|
||||
@ -159,7 +159,7 @@ async def test_hassio_addon_discovery(
|
||||
context={"source": config_entries.SOURCE_HASSIO},
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "hassio_confirm"
|
||||
assert result.get("description_placeholders") == {"addon": "Piper"}
|
||||
|
||||
@ -169,7 +169,7 @@ async def test_hassio_addon_discovery(
|
||||
) as mock_wyoming:
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result2 == snapshot
|
||||
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@ -189,7 +189,7 @@ async def test_hassio_addon_already_configured(hass: HomeAssistant) -> None:
|
||||
data=ADDON_DISCOVERY,
|
||||
context={"source": config_entries.SOURCE_HASSIO},
|
||||
)
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
|
||||
|
||||
@ -207,7 +207,7 @@ async def test_hassio_addon_cannot_connect(hass: HomeAssistant) -> None:
|
||||
):
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result2.get("type") == FlowResultType.FORM
|
||||
assert result2.get("type") is FlowResultType.FORM
|
||||
assert result2.get("errors") == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@ -225,7 +225,7 @@ async def test_hassio_addon_no_supported_services(hass: HomeAssistant) -> None:
|
||||
):
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result2.get("type") == FlowResultType.ABORT
|
||||
assert result2.get("type") is FlowResultType.ABORT
|
||||
assert result2.get("reason") == "no_services"
|
||||
|
||||
|
||||
@ -245,14 +245,14 @@ async def test_zeroconf_discovery(
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "zeroconf_confirm"
|
||||
assert result.get("description_placeholders") == {
|
||||
"name": SATELLITE_INFO.satellite.name
|
||||
}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result2.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result2 == snapshot
|
||||
|
||||
|
||||
@ -275,7 +275,7 @@ async def test_zeroconf_discovery_no_port(
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "no_port"
|
||||
|
||||
|
||||
@ -295,5 +295,5 @@ async def test_zeroconf_discovery_no_services(
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "no_services"
|
||||
|
@ -3,13 +3,14 @@
|
||||
from http import HTTPStatus
|
||||
from unittest.mock import patch
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow, setup
|
||||
from homeassistant import config_entries, setup
|
||||
from homeassistant.components.application_credentials import (
|
||||
ClientCredential,
|
||||
async_import_client_credential,
|
||||
)
|
||||
from homeassistant.components.xbox.const import DOMAIN, OAUTH2_AUTHORIZE, OAUTH2_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
@ -27,7 +28,7 @@ async def test_abort_if_existing_entry(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"xbox", context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ async def test_async_step_bluetooth_valid_device(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=MMC_T201_1_SERVICE_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "bluetooth_confirm"
|
||||
with patch(
|
||||
"homeassistant.components.xiaomi_ble.async_setup_entry", return_value=True
|
||||
@ -38,7 +38,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"] == "Baby Thermometer 6FC1 (MMC-T201-1)"
|
||||
assert result2["data"] == {}
|
||||
assert result2["result"].unique_id == "00:81:F9:DD:6F:C1"
|
||||
@ -57,7 +57,7 @@ async def test_async_step_bluetooth_valid_device_but_missing_payload(
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=MISSING_PAYLOAD_ENCRYPTED,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm_slow"
|
||||
|
||||
with patch(
|
||||
@ -66,7 +66,7 @@ async def test_async_step_bluetooth_valid_device_but_missing_payload(
|
||||
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"] == "Temperature/Humidity Sensor 5384 (LYWSD03MMC)"
|
||||
assert result2["data"] == {}
|
||||
assert result2["result"].unique_id == "A4:C1:38:56:53:84"
|
||||
@ -96,7 +96,7 @@ async def test_async_step_bluetooth_valid_device_but_missing_payload_then_full(
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=MISSING_PAYLOAD_ENCRYPTED,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "get_encryption_key_4_5"
|
||||
|
||||
with patch(
|
||||
@ -107,7 +107,7 @@ async def test_async_step_bluetooth_valid_device_but_missing_payload_then_full(
|
||||
user_input={"bindkey": "a115210eed7a88e50ad52662e732a9fb"},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == {"bindkey": "a115210eed7a88e50ad52662e732a9fb"}
|
||||
assert result2["result"].unique_id == "A4:C1:38:56:53:84"
|
||||
|
||||
@ -129,7 +129,7 @@ async def test_async_step_bluetooth_during_onboarding(hass: HomeAssistant) -> No
|
||||
data=MMC_T201_1_SERVICE_INFO,
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Baby Thermometer 6FC1 (MMC-T201-1)"
|
||||
assert result["data"] == {}
|
||||
assert result["result"].unique_id == "00:81:F9:DD:6F:C1"
|
||||
@ -146,7 +146,7 @@ async def test_async_step_bluetooth_valid_device_legacy_encryption(
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=YLKG07YL_SERVICE_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "get_encryption_key_legacy"
|
||||
|
||||
with patch(
|
||||
@ -156,7 +156,7 @@ async def test_async_step_bluetooth_valid_device_legacy_encryption(
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "b853075158487ca39a5b5ea9"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Dimmer Switch 988B (YLKG07YL/YLKG08YL)"
|
||||
assert result2["data"] == {"bindkey": "b853075158487ca39a5b5ea9"}
|
||||
assert result2["result"].unique_id == "F8:24:41:C5:98:8B"
|
||||
@ -171,14 +171,14 @@ async def test_async_step_bluetooth_valid_device_legacy_encryption_wrong_key(
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=YLKG07YL_SERVICE_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "get_encryption_key_legacy"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "aaaaaaaaaaaaaaaaaaaaaaaa"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "get_encryption_key_legacy"
|
||||
assert result2["errors"]["bindkey"] == "decryption_failed"
|
||||
|
||||
@ -190,7 +190,7 @@ async def test_async_step_bluetooth_valid_device_legacy_encryption_wrong_key(
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "b853075158487ca39a5b5ea9"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Dimmer Switch 988B (YLKG07YL/YLKG08YL)"
|
||||
assert result2["data"] == {"bindkey": "b853075158487ca39a5b5ea9"}
|
||||
assert result2["result"].unique_id == "F8:24:41:C5:98:8B"
|
||||
@ -205,14 +205,14 @@ async def test_async_step_bluetooth_valid_device_legacy_encryption_wrong_key_len
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=YLKG07YL_SERVICE_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "get_encryption_key_legacy"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "aaaaaaaaaaaaaaaaaaaaaaa"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "get_encryption_key_legacy"
|
||||
assert result2["errors"]["bindkey"] == "expected_24_characters"
|
||||
|
||||
@ -224,7 +224,7 @@ async def test_async_step_bluetooth_valid_device_legacy_encryption_wrong_key_len
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "b853075158487ca39a5b5ea9"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Dimmer Switch 988B (YLKG07YL/YLKG08YL)"
|
||||
assert result2["data"] == {"bindkey": "b853075158487ca39a5b5ea9"}
|
||||
assert result2["result"].unique_id == "F8:24:41:C5:98:8B"
|
||||
@ -239,7 +239,7 @@ async def test_async_step_bluetooth_valid_device_v4_encryption(
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=JTYJGD03MI_SERVICE_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "get_encryption_key_4_5"
|
||||
|
||||
with patch(
|
||||
@ -250,7 +250,7 @@ async def test_async_step_bluetooth_valid_device_v4_encryption(
|
||||
user_input={"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Smoke Detector 9CBC (JTYJGD03MI)"
|
||||
assert result2["data"] == {"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"}
|
||||
assert result2["result"].unique_id == "54:EF:44:E3:9C:BC"
|
||||
@ -265,7 +265,7 @@ async def test_async_step_bluetooth_valid_device_v4_encryption_wrong_key(
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=JTYJGD03MI_SERVICE_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "get_encryption_key_4_5"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@ -273,7 +273,7 @@ async def test_async_step_bluetooth_valid_device_v4_encryption_wrong_key(
|
||||
user_input={"bindkey": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "get_encryption_key_4_5"
|
||||
assert result2["errors"]["bindkey"] == "decryption_failed"
|
||||
|
||||
@ -286,7 +286,7 @@ async def test_async_step_bluetooth_valid_device_v4_encryption_wrong_key(
|
||||
user_input={"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Smoke Detector 9CBC (JTYJGD03MI)"
|
||||
assert result2["data"] == {"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"}
|
||||
assert result2["result"].unique_id == "54:EF:44:E3:9C:BC"
|
||||
@ -301,7 +301,7 @@ async def test_async_step_bluetooth_valid_device_v4_encryption_wrong_key_length(
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=JTYJGD03MI_SERVICE_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "get_encryption_key_4_5"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@ -309,7 +309,7 @@ async def test_async_step_bluetooth_valid_device_v4_encryption_wrong_key_length(
|
||||
user_input={"bindkey": "5b51a7c91cde6707c9ef18fda143a58"},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "get_encryption_key_4_5"
|
||||
assert result2["errors"]["bindkey"] == "expected_32_characters"
|
||||
|
||||
@ -322,7 +322,7 @@ async def test_async_step_bluetooth_valid_device_v4_encryption_wrong_key_length(
|
||||
user_input={"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Smoke Detector 9CBC (JTYJGD03MI)"
|
||||
assert result2["data"] == {"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"}
|
||||
assert result2["result"].unique_id == "54:EF:44:E3:9C:BC"
|
||||
@ -335,7 +335,7 @@ async def test_async_step_bluetooth_not_xiaomi(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=NOT_SENSOR_PUSH_SERVICE_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_supported"
|
||||
|
||||
|
||||
@ -345,7 +345,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"
|
||||
|
||||
|
||||
@ -362,7 +362,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"
|
||||
|
||||
|
||||
@ -376,7 +376,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.xiaomi_ble.async_setup_entry", return_value=True
|
||||
@ -385,7 +385,7 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={"address": "58:2D:34:35:93:21"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Temperature/Humidity Sensor 9321 (LYWSDCGQ)"
|
||||
assert result2["data"] == {}
|
||||
assert result2["result"].unique_id == "58:2D:34:35:93:21"
|
||||
@ -401,7 +401,7 @@ async def test_async_step_user_short_payload(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.xiaomi_ble.config_flow.async_process_advertisements",
|
||||
@ -411,7 +411,7 @@ async def test_async_step_user_short_payload(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={"address": "A4:C1:38:56:53:84"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "confirm_slow"
|
||||
|
||||
with patch(
|
||||
@ -420,7 +420,7 @@ async def test_async_step_user_short_payload(hass: HomeAssistant) -> None:
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={}
|
||||
)
|
||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "Temperature/Humidity Sensor 5384 (LYWSD03MMC)"
|
||||
assert result3["data"] == {}
|
||||
assert result3["result"].unique_id == "A4:C1:38:56:53:84"
|
||||
@ -436,7 +436,7 @@ async def test_async_step_user_short_payload_then_full(hass: HomeAssistant) -> N
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_USER},
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
async def _async_process_advertisements(
|
||||
@ -457,7 +457,7 @@ async def test_async_step_user_short_payload_then_full(hass: HomeAssistant) -> N
|
||||
result["flow_id"],
|
||||
user_input={"address": "A4:C1:38:56:53:84"},
|
||||
)
|
||||
assert result1["type"] == FlowResultType.FORM
|
||||
assert result1["type"] is FlowResultType.FORM
|
||||
assert result1["step_id"] == "get_encryption_key_4_5"
|
||||
|
||||
with patch(
|
||||
@ -468,7 +468,7 @@ async def test_async_step_user_short_payload_then_full(hass: HomeAssistant) -> N
|
||||
user_input={"bindkey": "a115210eed7a88e50ad52662e732a9fb"},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Temperature/Humidity Sensor 5384 (LYWSD03MMC)"
|
||||
assert result2["data"] == {"bindkey": "a115210eed7a88e50ad52662e732a9fb"}
|
||||
|
||||
@ -485,14 +485,14 @@ async def test_async_step_user_with_found_devices_v4_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:EF:44:E3:9C:BC"},
|
||||
)
|
||||
assert result1["type"] == FlowResultType.FORM
|
||||
assert result1["type"] is FlowResultType.FORM
|
||||
assert result1["step_id"] == "get_encryption_key_4_5"
|
||||
|
||||
with patch(
|
||||
@ -503,7 +503,7 @@ async def test_async_step_user_with_found_devices_v4_encryption(
|
||||
user_input={"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Smoke Detector 9CBC (JTYJGD03MI)"
|
||||
assert result2["data"] == {"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"}
|
||||
assert result2["result"].unique_id == "54:EF:44:E3:9C:BC"
|
||||
@ -522,7 +522,7 @@ async def test_async_step_user_with_found_devices_v4_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
|
||||
@ -530,7 +530,7 @@ async def test_async_step_user_with_found_devices_v4_encryption_wrong_key(
|
||||
result["flow_id"],
|
||||
user_input={"address": "54:EF:44:E3:9C:BC"},
|
||||
)
|
||||
assert result1["type"] == FlowResultType.FORM
|
||||
assert result1["type"] is FlowResultType.FORM
|
||||
assert result1["step_id"] == "get_encryption_key_4_5"
|
||||
|
||||
# Try an incorrect key
|
||||
@ -538,7 +538,7 @@ async def test_async_step_user_with_found_devices_v4_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_4_5"
|
||||
assert result2["errors"]["bindkey"] == "decryption_failed"
|
||||
|
||||
@ -551,7 +551,7 @@ async def test_async_step_user_with_found_devices_v4_encryption_wrong_key(
|
||||
user_input={"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Smoke Detector 9CBC (JTYJGD03MI)"
|
||||
assert result2["data"] == {"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"}
|
||||
assert result2["result"].unique_id == "54:EF:44:E3:9C:BC"
|
||||
@ -570,7 +570,7 @@ async def test_async_step_user_with_found_devices_v4_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
|
||||
@ -578,7 +578,7 @@ async def test_async_step_user_with_found_devices_v4_encryption_wrong_key_length
|
||||
result["flow_id"],
|
||||
user_input={"address": "54:EF:44:E3:9C:BC"},
|
||||
)
|
||||
assert result1["type"] == FlowResultType.FORM
|
||||
assert result1["type"] is FlowResultType.FORM
|
||||
assert result1["step_id"] == "get_encryption_key_4_5"
|
||||
|
||||
# Try an incorrect key
|
||||
@ -587,8 +587,8 @@ async def test_async_step_user_with_found_devices_v4_encryption_wrong_key_length
|
||||
user_input={"bindkey": "5b51a7c91cde6707c9ef1dfda143a58"},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "get_encryption_key_4_5"
|
||||
assert result2["errors"]["bindkey"] == "expected_32_characters"
|
||||
|
||||
@ -601,7 +601,7 @@ async def test_async_step_user_with_found_devices_v4_encryption_wrong_key_length
|
||||
user_input={"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Smoke Detector 9CBC (JTYJGD03MI)"
|
||||
assert result2["data"] == {"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"}
|
||||
assert result2["result"].unique_id == "54:EF:44:E3:9C:BC"
|
||||
@ -619,14 +619,14 @@ async def test_async_step_user_with_found_devices_legacy_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": "F8:24:41:C5:98:8B"},
|
||||
)
|
||||
assert result1["type"] == FlowResultType.FORM
|
||||
assert result1["type"] is FlowResultType.FORM
|
||||
assert result1["step_id"] == "get_encryption_key_legacy"
|
||||
|
||||
with patch(
|
||||
@ -636,7 +636,7 @@ async def test_async_step_user_with_found_devices_legacy_encryption(
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "b853075158487ca39a5b5ea9"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Dimmer Switch 988B (YLKG07YL/YLKG08YL)"
|
||||
assert result2["data"] == {"bindkey": "b853075158487ca39a5b5ea9"}
|
||||
assert result2["result"].unique_id == "F8:24:41:C5:98:8B"
|
||||
@ -654,14 +654,14 @@ async def test_async_step_user_with_found_devices_legacy_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"
|
||||
|
||||
result1 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={"address": "F8:24:41:C5:98:8B"},
|
||||
)
|
||||
assert result1["type"] == FlowResultType.FORM
|
||||
assert result1["type"] is FlowResultType.FORM
|
||||
assert result1["step_id"] == "get_encryption_key_legacy"
|
||||
|
||||
# Enter an incorrect code
|
||||
@ -669,7 +669,7 @@ async def test_async_step_user_with_found_devices_legacy_encryption_wrong_key(
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "aaaaaaaaaaaaaaaaaaaaaaaa"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "get_encryption_key_legacy"
|
||||
assert result2["errors"]["bindkey"] == "decryption_failed"
|
||||
|
||||
@ -681,7 +681,7 @@ async def test_async_step_user_with_found_devices_legacy_encryption_wrong_key(
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "b853075158487ca39a5b5ea9"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Dimmer Switch 988B (YLKG07YL/YLKG08YL)"
|
||||
assert result2["data"] == {"bindkey": "b853075158487ca39a5b5ea9"}
|
||||
assert result2["result"].unique_id == "F8:24:41:C5:98:8B"
|
||||
@ -699,14 +699,14 @@ async def test_async_step_user_with_found_devices_legacy_encryption_wrong_key_le
|
||||
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": "F8:24:41:C5:98:8B"},
|
||||
)
|
||||
assert result1["type"] == FlowResultType.FORM
|
||||
assert result1["type"] is FlowResultType.FORM
|
||||
assert result1["step_id"] == "get_encryption_key_legacy"
|
||||
|
||||
# Enter an incorrect code
|
||||
@ -714,7 +714,7 @@ async def test_async_step_user_with_found_devices_legacy_encryption_wrong_key_le
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "b85307518487ca39a5b5ea9"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "get_encryption_key_legacy"
|
||||
assert result2["errors"]["bindkey"] == "expected_24_characters"
|
||||
|
||||
@ -726,7 +726,7 @@ async def test_async_step_user_with_found_devices_legacy_encryption_wrong_key_le
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "b853075158487ca39a5b5ea9"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Dimmer Switch 988B (YLKG07YL/YLKG08YL)"
|
||||
assert result2["data"] == {"bindkey": "b853075158487ca39a5b5ea9"}
|
||||
assert result2["result"].unique_id == "F8:24:41:C5:98:8B"
|
||||
@ -742,7 +742,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(
|
||||
@ -758,7 +758,7 @@ async def test_async_step_user_device_added_between_steps(hass: HomeAssistant) -
|
||||
result["flow_id"],
|
||||
user_input={"address": "58:2D:34:35:93:21"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -780,7 +780,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"
|
||||
|
||||
|
||||
@ -797,7 +797,7 @@ async def test_async_step_bluetooth_devices_already_setup(hass: HomeAssistant) -
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=MMC_T201_1_SERVICE_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -808,7 +808,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=MMC_T201_1_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(
|
||||
@ -816,7 +816,7 @@ async def test_async_step_bluetooth_already_in_progress(hass: HomeAssistant) ->
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=MMC_T201_1_SERVICE_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_in_progress"
|
||||
|
||||
|
||||
@ -829,7 +829,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=MMC_T201_1_SERVICE_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "bluetooth_confirm"
|
||||
|
||||
with patch(
|
||||
@ -840,7 +840,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.xiaomi_ble.async_setup_entry", return_value=True
|
||||
@ -849,7 +849,7 @@ async def test_async_step_user_takes_precedence_over_discovery(
|
||||
result["flow_id"],
|
||||
user_input={"address": "00:81:F9:DD:6F:C1"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Baby Thermometer 6FC1 (MMC-T201-1)"
|
||||
assert result2["data"] == {}
|
||||
assert result2["result"].unique_id == "00:81:F9:DD:6F:C1"
|
||||
@ -903,7 +903,7 @@ async def test_async_step_reauth_legacy(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "b853075158487ca39a5b5ea9"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@ -952,7 +952,7 @@ async def test_async_step_reauth_legacy_wrong_key(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "b85307515a487ca39a5b5ea9"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "get_encryption_key_legacy"
|
||||
assert result2["errors"]["bindkey"] == "decryption_failed"
|
||||
|
||||
@ -960,7 +960,7 @@ async def test_async_step_reauth_legacy_wrong_key(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "b853075158487ca39a5b5ea9"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@ -1009,7 +1009,7 @@ async def test_async_step_reauth_v4(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@ -1058,7 +1058,7 @@ async def test_async_step_reauth_v4_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_4_5"
|
||||
assert result2["errors"]["bindkey"] == "decryption_failed"
|
||||
|
||||
@ -1066,7 +1066,7 @@ async def test_async_step_reauth_v4_wrong_key(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={"bindkey": "5b51a7c91cde6707c9ef18dfda143a58"},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@ -1094,5 +1094,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"
|
||||
|
@ -8,11 +8,12 @@ from micloud.micloudexception import MiCloudAccessDenied
|
||||
from miio import DeviceException
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.components.xiaomi_miio import const
|
||||
from homeassistant.const import CONF_DEVICE, CONF_HOST, CONF_MAC, CONF_MODEL, CONF_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from . import TEST_MAC
|
||||
|
||||
@ -897,7 +898,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(
|
||||
@ -907,7 +908,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 == {
|
||||
const.CONF_CLOUD_SUBDEVICES: True,
|
||||
}
|
||||
@ -937,7 +938,7 @@ async def test_options_flow_incomplete(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"],
|
||||
@ -946,7 +947,7 @@ async def test_options_flow_incomplete(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
assert result["errors"] == {"base": "cloud_credentials_incomplete"}
|
||||
|
||||
|
@ -21,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"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
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"] == "test-username"
|
||||
assert result2["data"] == {
|
||||
"username": "test-username",
|
||||
@ -85,7 +85,7 @@ async def test_form_invalid_auth(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": p_error}
|
||||
|
||||
with (
|
||||
@ -107,7 +107,7 @@ async def test_form_invalid_auth(
|
||||
)
|
||||
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"] == {
|
||||
"username": "test-username",
|
||||
@ -142,7 +142,7 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:
|
||||
data=entry.data,
|
||||
)
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@ -163,7 +163,7 @@ async def test_reauth_flow(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 entry.data == {
|
||||
"username": "test-username",
|
||||
@ -226,7 +226,7 @@ async def test_reauth_flow_error(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["step_id"] == "reauth_confirm"
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": p_error}
|
||||
|
||||
with (
|
||||
@ -248,7 +248,7 @@ async def test_reauth_flow_error(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
assert entry.data == {
|
||||
"username": "test-username",
|
||||
@ -288,7 +288,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(
|
||||
@ -296,5 +296,5 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||
user_input={"lock_code_digits": 6},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {"lock_code_digits": 6}
|
||||
|
@ -57,7 +57,7 @@ async def test_user_step_success(hass: HomeAssistant, slot: int) -> 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"] == {}
|
||||
|
||||
@ -80,7 +80,7 @@ async def test_user_step_success(hass: HomeAssistant, slot: int) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == YALE_ACCESS_LOCK_DISCOVERY_INFO.name
|
||||
assert result2["data"] == {
|
||||
CONF_LOCAL_NAME: YALE_ACCESS_LOCK_DISCOVERY_INFO.name,
|
||||
@ -101,7 +101,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"
|
||||
|
||||
|
||||
@ -125,7 +125,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"
|
||||
|
||||
|
||||
@ -138,7 +138,7 @@ async def test_user_step_invalid_keys(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"] == {}
|
||||
|
||||
@ -150,7 +150,7 @@ async def test_user_step_invalid_keys(hass: HomeAssistant) -> None:
|
||||
CONF_SLOT: 66,
|
||||
},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "user"
|
||||
assert result2["errors"] == {CONF_KEY: "invalid_key_format"}
|
||||
|
||||
@ -162,7 +162,7 @@ async def test_user_step_invalid_keys(hass: HomeAssistant) -> None:
|
||||
CONF_SLOT: 66,
|
||||
},
|
||||
)
|
||||
assert result3["type"] == FlowResultType.FORM
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "user"
|
||||
assert result3["errors"] == {CONF_KEY: "invalid_key_format"}
|
||||
|
||||
@ -174,7 +174,7 @@ async def test_user_step_invalid_keys(hass: HomeAssistant) -> None:
|
||||
CONF_SLOT: 999,
|
||||
},
|
||||
)
|
||||
assert result4["type"] == FlowResultType.FORM
|
||||
assert result4["type"] is FlowResultType.FORM
|
||||
assert result4["step_id"] == "user"
|
||||
assert result4["errors"] == {CONF_SLOT: "invalid_key_index"}
|
||||
|
||||
@ -197,7 +197,7 @@ async def test_user_step_invalid_keys(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result5["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result5["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result5["title"] == YALE_ACCESS_LOCK_DISCOVERY_INFO.name
|
||||
assert result5["data"] == {
|
||||
CONF_LOCAL_NAME: YALE_ACCESS_LOCK_DISCOVERY_INFO.name,
|
||||
@ -218,7 +218,7 @@ async def test_user_step_cannot_connect(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"] == {}
|
||||
|
||||
@ -236,7 +236,7 @@ async def test_user_step_cannot_connect(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": "cannot_connect"}
|
||||
|
||||
@ -259,7 +259,7 @@ async def test_user_step_cannot_connect(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"] == YALE_ACCESS_LOCK_DISCOVERY_INFO.name
|
||||
assert result3["data"] == {
|
||||
CONF_LOCAL_NAME: YALE_ACCESS_LOCK_DISCOVERY_INFO.name,
|
||||
@ -280,7 +280,7 @@ async def test_user_step_auth_exception(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"] == {}
|
||||
|
||||
@ -298,7 +298,7 @@ async def test_user_step_auth_exception(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"] == {CONF_KEY: "invalid_auth"}
|
||||
|
||||
@ -321,7 +321,7 @@ async def test_user_step_auth_exception(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"] == YALE_ACCESS_LOCK_DISCOVERY_INFO.name
|
||||
assert result3["data"] == {
|
||||
CONF_LOCAL_NAME: YALE_ACCESS_LOCK_DISCOVERY_INFO.name,
|
||||
@ -342,7 +342,7 @@ async def test_user_step_unknown_exception(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"] == {}
|
||||
|
||||
@ -360,7 +360,7 @@ async def test_user_step_unknown_exception(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": "unknown"}
|
||||
|
||||
@ -383,7 +383,7 @@ async def test_user_step_unknown_exception(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"] == YALE_ACCESS_LOCK_DISCOVERY_INFO.name
|
||||
assert result3["data"] == {
|
||||
CONF_LOCAL_NAME: YALE_ACCESS_LOCK_DISCOVERY_INFO.name,
|
||||
@ -402,7 +402,7 @@ async def test_bluetooth_step_success(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=YALE_ACCESS_LOCK_DISCOVERY_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@ -425,7 +425,7 @@ async def test_bluetooth_step_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"] == YALE_ACCESS_LOCK_DISCOVERY_INFO.name
|
||||
assert result2["data"] == {
|
||||
CONF_LOCAL_NAME: YALE_ACCESS_LOCK_DISCOVERY_INFO.name,
|
||||
@ -454,7 +454,7 @@ async def test_integration_discovery_success(hass: HomeAssistant) -> None:
|
||||
"serial": "M1XXX012LU",
|
||||
},
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "integration_discovery_confirm"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -468,7 +468,7 @@ async def test_integration_discovery_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"] == "Front Door"
|
||||
assert result2["data"] == {
|
||||
CONF_LOCAL_NAME: YALE_ACCESS_LOCK_DISCOVERY_INFO.name,
|
||||
@ -497,7 +497,7 @@ async def test_integration_discovery_device_not_found(hass: HomeAssistant) -> No
|
||||
"serial": "M1XXX012LU",
|
||||
},
|
||||
)
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
@ -510,7 +510,7 @@ async def test_integration_discovery_takes_precedence_over_bluetooth(
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=YALE_ACCESS_LOCK_DISCOVERY_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
flows = [
|
||||
@ -538,7 +538,7 @@ async def test_integration_discovery_takes_precedence_over_bluetooth(
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "integration_discovery_confirm"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -563,7 +563,7 @@ async def test_integration_discovery_takes_precedence_over_bluetooth(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Front Door"
|
||||
assert result2["data"] == {
|
||||
CONF_LOCAL_NAME: YALE_ACCESS_LOCK_DISCOVERY_INFO.name,
|
||||
@ -619,7 +619,7 @@ async def test_integration_discovery_updates_key_unique_local_name(
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_KEY] == "2fd51b8621c6a139eaffbedcb846b60f"
|
||||
assert entry.data[CONF_SLOT] == 66
|
||||
@ -658,7 +658,7 @@ async def test_integration_discovery_updates_key_without_unique_local_name(
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_KEY] == "2fd51b8621c6a139eaffbedcb846b60f"
|
||||
assert entry.data[CONF_SLOT] == 66
|
||||
@ -707,7 +707,7 @@ async def test_integration_discovery_updates_key_duplicate_local_name(
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_KEY] == "2fd51b8621c6a139eaffbedcb846b60f"
|
||||
assert entry.data[CONF_SLOT] == 66
|
||||
@ -725,7 +725,7 @@ async def test_integration_discovery_takes_precedence_over_bluetooth_uuid_addres
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=LOCK_DISCOVERY_INFO_UUID_ADDRESS,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
flows = [
|
||||
@ -753,7 +753,7 @@ async def test_integration_discovery_takes_precedence_over_bluetooth_uuid_addres
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "integration_discovery_confirm"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -778,7 +778,7 @@ async def test_integration_discovery_takes_precedence_over_bluetooth_uuid_addres
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Front Door"
|
||||
assert result2["data"] == {
|
||||
CONF_LOCAL_NAME: LOCK_DISCOVERY_INFO_UUID_ADDRESS.name,
|
||||
@ -805,7 +805,7 @@ async def test_integration_discovery_takes_precedence_over_bluetooth_non_unique_
|
||||
context={"source": config_entries.SOURCE_BLUETOOTH},
|
||||
data=OLD_FIRMWARE_LOCK_DISCOVERY_INFO,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
flows = [
|
||||
@ -833,7 +833,7 @@ async def test_integration_discovery_takes_precedence_over_bluetooth_non_unique_
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "integration_discovery_confirm"
|
||||
assert result["errors"] is None
|
||||
|
||||
@ -863,7 +863,7 @@ async def test_user_is_setting_up_lock_and_discovery_happens_in_the_middle(
|
||||
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"] == {}
|
||||
|
||||
@ -912,13 +912,13 @@ async def test_user_is_setting_up_lock_and_discovery_happens_in_the_middle(
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert discovery_result["type"] == FlowResultType.ABORT
|
||||
assert discovery_result["type"] is FlowResultType.ABORT
|
||||
assert discovery_result["reason"] == "already_in_progress"
|
||||
|
||||
user_flow_event.set()
|
||||
user_flow_result = await user_flow_task
|
||||
|
||||
assert user_flow_result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert user_flow_result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert user_flow_result["title"] == YALE_ACCESS_LOCK_DISCOVERY_INFO.name
|
||||
assert user_flow_result["data"] == {
|
||||
CONF_LOCAL_NAME: YALE_ACCESS_LOCK_DISCOVERY_INFO.name,
|
||||
@ -950,7 +950,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_validate"
|
||||
|
||||
with patch(
|
||||
@ -966,7 +966,7 @@ async def test_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_validate"
|
||||
assert result2["errors"] == {"base": "no_longer_in_range"}
|
||||
|
||||
@ -992,7 +992,7 @@ async def test_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
|
||||
|
||||
@ -1022,7 +1022,7 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||
entry.entry_id,
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "device_options"
|
||||
|
||||
with patch(
|
||||
@ -1037,6 +1037,6 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert entry.options == {CONF_ALWAYS_CONNECTED: True}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
@ -5,12 +5,13 @@ from unittest.mock import patch
|
||||
from aiomusiccast import MusicCastConnectionException
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components import ssdp
|
||||
from homeassistant.components.yamaha_musiccast.const import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@ -135,13 +136,13 @@ async def test_user_input_device_not_found(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"host": "none"},
|
||||
)
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@ -153,13 +154,13 @@ async def test_user_input_non_yamaha_device_found(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"host": "127.0.0.1"},
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "no_musiccast_device"}
|
||||
|
||||
|
||||
@ -183,7 +184,7 @@ async def test_user_input_device_already_existing(
|
||||
{"host": "192.168.188.18"},
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -195,13 +196,13 @@ async def test_user_input_unknown_error(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"host": "127.0.0.1"},
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@ -216,13 +217,13 @@ async def test_user_input_device_found(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"host": "127.0.0.1"},
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert isinstance(result2["result"], ConfigEntry)
|
||||
assert result2["data"] == {
|
||||
"host": "127.0.0.1",
|
||||
@ -242,13 +243,13 @@ async def test_user_input_device_found_no_ssdp(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"host": "127.0.0.1"},
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert isinstance(result2["result"], ConfigEntry)
|
||||
assert result2["data"] == {
|
||||
"host": "127.0.0.1",
|
||||
@ -278,7 +279,7 @@ async def test_ssdp_discovery_failed(
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "yxc_control_url_missing"
|
||||
|
||||
|
||||
@ -300,7 +301,7 @@ async def test_ssdp_discovery_successful_add_device(
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
@ -309,7 +310,7 @@ async def test_ssdp_discovery_successful_add_device(
|
||||
{},
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert isinstance(result2["result"], ConfigEntry)
|
||||
assert result2["data"] == {
|
||||
"host": "127.0.0.1",
|
||||
@ -341,7 +342,7 @@ async def test_ssdp_discovery_existing_device_update(
|
||||
},
|
||||
),
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert mock_entry.data[CONF_HOST] == "127.0.0.1"
|
||||
assert mock_entry.data["upnp_description"] == "http://127.0.0.1/desc.xml"
|
||||
|
@ -18,7 +18,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(
|
||||
@ -34,7 +34,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"] == PRODUCT_NAME
|
||||
assert result2["data"] == {
|
||||
"host": "fake_host",
|
||||
@ -65,7 +65,7 @@ async def test_form_invalid_auth(
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
# Should be recoverable after hits error
|
||||
@ -82,7 +82,7 @@ async def test_form_invalid_auth(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == PRODUCT_NAME
|
||||
assert result3["data"] == {
|
||||
"host": "fake_host",
|
||||
@ -113,7 +113,7 @@ async def test_form_cannot_connect(
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
# Should be recoverable after hits error
|
||||
@ -130,7 +130,7 @@ async def test_form_cannot_connect(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == PRODUCT_NAME
|
||||
assert result3["data"] == {
|
||||
"host": "fake_host",
|
||||
@ -161,7 +161,7 @@ async def test_form_uncategorized_error(
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
# Should be recoverable after hits error
|
||||
@ -178,7 +178,7 @@ async def test_form_uncategorized_error(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == PRODUCT_NAME
|
||||
assert result3["data"] == {
|
||||
"host": "fake_host",
|
||||
|
@ -500,7 +500,7 @@ async def test_discovered_by_homekit_and_dhcp(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@ -516,7 +516,7 @@ async def test_discovered_by_homekit_and_dhcp(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_in_progress"
|
||||
|
||||
with (
|
||||
@ -532,7 +532,7 @@ async def test_discovered_by_homekit_and_dhcp(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result3["type"] == FlowResultType.ABORT
|
||||
assert result3["type"] is FlowResultType.ABORT
|
||||
assert result3["reason"] == "already_in_progress"
|
||||
|
||||
with (
|
||||
@ -549,7 +549,7 @@ async def test_discovered_by_homekit_and_dhcp(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result3["type"] == FlowResultType.ABORT
|
||||
assert result3["type"] is FlowResultType.ABORT
|
||||
assert result3["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@ -590,7 +590,7 @@ async def test_discovered_by_dhcp_or_homekit(hass: HomeAssistant, source, data)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@ -623,7 +623,7 @@ async def test_discovered_by_dhcp_or_homekit(hass: HomeAssistant, source, data)
|
||||
DOMAIN, context={"source": source}, data=data
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result3["type"] == FlowResultType.ABORT
|
||||
assert result3["type"] is FlowResultType.ABORT
|
||||
assert result3["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -665,7 +665,7 @@ async def test_discovered_by_dhcp_or_homekit_failed_to_get_id(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": source}, data=data
|
||||
)
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@ -683,7 +683,7 @@ async def test_discovered_ssdp(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@ -717,7 +717,7 @@ async def test_discovered_ssdp(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"
|
||||
|
||||
|
||||
@ -737,7 +737,7 @@ async def test_discovered_zeroconf(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@ -773,7 +773,7 @@ async def test_discovered_zeroconf(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"
|
||||
|
||||
mocked_bulb = _mocked_bulb()
|
||||
@ -789,7 +789,7 @@ async def test_discovered_zeroconf(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"
|
||||
|
||||
|
||||
@ -813,7 +813,7 @@ async def test_discovery_updates_ip(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] == IP_ADDRESS
|
||||
|
||||
@ -844,7 +844,7 @@ async def test_discovery_updates_ip_no_reload_setup_in_progress(
|
||||
)
|
||||
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] == IP_ADDRESS
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
@ -868,7 +868,7 @@ async def test_discovery_adds_missing_ip_id_only(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] == IP_ADDRESS
|
||||
|
||||
|
@ -5,9 +5,10 @@ from unittest.mock import patch
|
||||
|
||||
from yolink.const import OAUTH2_AUTHORIZE, OAUTH2_TOKEN
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow, setup
|
||||
from homeassistant import config_entries, setup
|
||||
from homeassistant.components import application_credentials
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
@ -24,7 +25,7 @@ async def test_abort_if_no_configuration(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.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "missing_credentials"
|
||||
|
||||
|
||||
@ -34,7 +35,7 @@ async def test_abort_if_existing_entry(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.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -65,7 +66,7 @@ async def test_full_flow(
|
||||
"redirect_uri": "https://example.com/auth/external/callback",
|
||||
},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.FlowResultType.EXTERNAL_STEP
|
||||
assert result["type"] is FlowResultType.EXTERNAL_STEP
|
||||
assert result["url"] == (
|
||||
f"{OAUTH2_AUTHORIZE}?response_type=code&client_id={CLIENT_ID}"
|
||||
"&redirect_uri=https://example.com/auth/external/callback"
|
||||
@ -136,7 +137,7 @@ async def test_abort_if_authorization_timeout(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "authorize_url_timeout"
|
||||
|
||||
|
||||
@ -217,6 +218,6 @@ async def test_reauthentication(
|
||||
assert token_data["refresh_token"] == "mock-refresh-token"
|
||||
assert token_data["type"] == "Bearer"
|
||||
assert token_data["expires_in"] == 60
|
||||
assert result["type"] == data_entry_flow.FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
|
@ -65,7 +65,7 @@ async def test_full_flow(
|
||||
),
|
||||
):
|
||||
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"] == "channels"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@ -122,7 +122,7 @@ async def test_flow_abort_without_channel(
|
||||
),
|
||||
):
|
||||
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"] == "no_channel"
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@ async def test_flow_abort_without_subscriptions(
|
||||
),
|
||||
):
|
||||
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"] == "no_subscriptions"
|
||||
|
||||
|
||||
@ -203,7 +203,7 @@ async def test_flow_http_error(
|
||||
),
|
||||
):
|
||||
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"] == "access_not_configured"
|
||||
assert result["description_placeholders"]["message"] == (
|
||||
"YouTube Data API v3 has not been used in project 0 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=0 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry."
|
||||
@ -345,7 +345,7 @@ async def test_flow_exception(
|
||||
"homeassistant.components.youtube.config_flow.YouTube", side_effect=Exception
|
||||
):
|
||||
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"
|
||||
|
||||
|
||||
@ -362,7 +362,7 @@ async def test_options_flow(
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@ -371,5 +371,5 @@ 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"] == {CONF_CHANNELS: ["UC_x5XG1OV2P6uZZ5FSM9Ttw"]}
|
||||
|
@ -23,14 +23,14 @@ async def test_full_user_flow_implementation(
|
||||
context={"source": SOURCE_USER},
|
||||
)
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
LOGGER.debug(result)
|
||||
assert result.get("data_schema") != ""
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={CONF_STATION_ID: TEST_STATION_ID},
|
||||
)
|
||||
assert result.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert "data" in result
|
||||
assert result["data"][CONF_STATION_ID] == TEST_STATION_ID
|
||||
assert "result" in result
|
||||
@ -48,7 +48,7 @@ async def test_error_closest_station(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
)
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "cannot_connect"
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ async def test_error_update(
|
||||
context={"source": SOURCE_USER},
|
||||
)
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
LOGGER.debug(result)
|
||||
assert result.get("data_schema") != ""
|
||||
mock_zamg.update.side_effect = ZamgApiError
|
||||
@ -71,7 +71,7 @@ async def test_error_update(
|
||||
result["flow_id"],
|
||||
user_input={CONF_STATION_ID: TEST_STATION_ID},
|
||||
)
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "cannot_connect"
|
||||
|
||||
|
||||
@ -87,12 +87,12 @@ async def test_user_flow_duplicate(
|
||||
)
|
||||
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={CONF_STATION_ID: TEST_STATION_ID},
|
||||
)
|
||||
assert result.get("type") == FlowResultType.CREATE_ENTRY
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert "data" in result
|
||||
assert result["data"][CONF_STATION_ID] == TEST_STATION_ID
|
||||
assert "result" in result
|
||||
@ -103,10 +103,10 @@ async def test_user_flow_duplicate(
|
||||
context={"source": SOURCE_USER},
|
||||
)
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("type") == FlowResultType.FORM
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={CONF_STATION_ID: TEST_STATION_ID},
|
||||
)
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
|
@ -23,7 +23,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
|
||||
|
||||
await _set_up_zeversolar(hass=hass, flow_id=result["flow_id"])
|
||||
@ -71,7 +71,7 @@ async def test_form_errors(
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == errors
|
||||
|
||||
await _set_up_zeversolar(hass=hass, flow_id=result["flow_id"])
|
||||
@ -90,7 +90,7 @@ async def test_abort_already_configured(hass: HomeAssistant) -> None:
|
||||
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 result.get("errors") is None
|
||||
assert "flow_id" in result
|
||||
|
||||
@ -110,7 +110,7 @@ async def test_abort_already_configured(hass: HomeAssistant) -> None:
|
||||
)
|
||||
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"
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
||||
@ -134,7 +134,7 @@ async def _set_up_zeversolar(hass: HomeAssistant, flow_id: str) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Zeversolar"
|
||||
assert result2["data"] == {
|
||||
CONF_HOST: "test_ip",
|
||||
|
@ -169,7 +169,7 @@ async def test_zeroconf_discovery_znp(hass: HomeAssistant) -> None:
|
||||
result1["flow_id"], user_input={}
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.MENU
|
||||
assert result2["type"] is FlowResultType.MENU
|
||||
assert result2["step_id"] == "choose_formation_strategy"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@ -178,7 +178,7 @@ async def test_zeroconf_discovery_znp(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"] == "socket://192.168.1.200:6638"
|
||||
assert result3["data"] == {
|
||||
CONF_DEVICE: {
|
||||
@ -226,7 +226,7 @@ async def test_zigate_via_zeroconf(setup_entry_mock, hass: HomeAssistant) -> Non
|
||||
result1["flow_id"], user_input={}
|
||||
)
|
||||
|
||||
assert result3["type"] == FlowResultType.MENU
|
||||
assert result3["type"] is FlowResultType.MENU
|
||||
assert result3["step_id"] == "choose_formation_strategy"
|
||||
|
||||
result4 = await hass.config_entries.flow.async_configure(
|
||||
@ -235,7 +235,7 @@ async def test_zigate_via_zeroconf(setup_entry_mock, hass: HomeAssistant) -> Non
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result4["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["title"] == "socket://192.168.1.200:1234"
|
||||
assert result4["data"] == {
|
||||
CONF_DEVICE: {
|
||||
@ -276,7 +276,7 @@ async def test_efr32_via_zeroconf(hass: HomeAssistant) -> None:
|
||||
result1["flow_id"], user_input={}
|
||||
)
|
||||
|
||||
assert result2["type"] == FlowResultType.MENU
|
||||
assert result2["type"] is FlowResultType.MENU
|
||||
assert result2["step_id"] == "choose_formation_strategy"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@ -285,7 +285,7 @@ async def test_efr32_via_zeroconf(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"] == "socket://192.168.1.200:1234"
|
||||
assert result3["data"] == {
|
||||
CONF_DEVICE: {
|
||||
@ -321,7 +321,7 @@ async def test_discovery_via_zeroconf_ip_change_ignored(hass: HomeAssistant) ->
|
||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=service_info
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_DEVICE] == {
|
||||
CONF_DEVICE_PATH: "socket://192.168.1.22:6638",
|
||||
@ -355,7 +355,7 @@ async def test_discovery_confirm_final_abort_if_entries(hass: HomeAssistant) ->
|
||||
)
|
||||
|
||||
# Config will fail
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
@ -375,7 +375,7 @@ async def test_discovery_via_usb(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result1["type"] == FlowResultType.FORM
|
||||
assert result1["type"] is FlowResultType.FORM
|
||||
assert result1["step_id"] == "confirm"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@ -383,7 +383,7 @@ async def test_discovery_via_usb(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.MENU
|
||||
assert result2["type"] is FlowResultType.MENU
|
||||
assert result2["step_id"] == "choose_formation_strategy"
|
||||
|
||||
with patch("homeassistant.components.zha.async_setup_entry", return_value=True):
|
||||
@ -393,7 +393,7 @@ async def test_discovery_via_usb(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"] == "zigbee radio"
|
||||
assert result3["data"] == {
|
||||
"device": {
|
||||
@ -420,7 +420,7 @@ async def test_zigate_discovery_via_usb(probe_mock, hass: HomeAssistant) -> None
|
||||
DOMAIN, context={"source": SOURCE_USB}, data=discovery_info
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@ -433,7 +433,7 @@ async def test_zigate_discovery_via_usb(probe_mock, hass: HomeAssistant) -> None
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == FlowResultType.MENU
|
||||
assert result3["type"] is FlowResultType.MENU
|
||||
assert result3["step_id"] == "choose_formation_strategy"
|
||||
|
||||
with patch("homeassistant.components.zha.async_setup_entry", return_value=True):
|
||||
@ -443,7 +443,7 @@ async def test_zigate_discovery_via_usb(probe_mock, hass: HomeAssistant) -> None
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result4["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["title"] == "zigate radio"
|
||||
assert result4["data"] == {
|
||||
"device": {
|
||||
@ -473,7 +473,7 @@ async def test_discovery_via_usb_no_radio(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": SOURCE_USB}, data=discovery_info
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
with patch("homeassistant.components.zha.async_setup_entry", return_value=True):
|
||||
@ -482,7 +482,7 @@ async def test_discovery_via_usb_no_radio(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "usb_probe_failed"
|
||||
|
||||
|
||||
@ -507,7 +507,7 @@ async def test_discovery_via_usb_already_setup(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
@ -541,7 +541,7 @@ async def test_discovery_via_usb_path_does_not_change(hass: HomeAssistant) -> No
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_DEVICE] == {
|
||||
CONF_DEVICE_PATH: "/dev/ttyUSB1",
|
||||
@ -626,7 +626,7 @@ async def test_discovery_via_usb_deconz_ignored(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
|
||||
@ -654,7 +654,7 @@ async def test_discovery_via_usb_zha_ignored_updates(hass: HomeAssistant) -> Non
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_DEVICE] == {
|
||||
CONF_DEVICE_PATH: "/dev/ttyZIGBEE",
|
||||
@ -706,7 +706,7 @@ async def test_user_flow(hass: HomeAssistant) -> None:
|
||||
zigpy.config.CONF_DEVICE_PATH: port_select,
|
||||
},
|
||||
)
|
||||
assert result["type"] == FlowResultType.MENU
|
||||
assert result["type"] is FlowResultType.MENU
|
||||
assert result["step_id"] == "choose_formation_strategy"
|
||||
|
||||
with patch("homeassistant.components.zha.async_setup_entry", return_value=True):
|
||||
@ -716,7 +716,7 @@ async def test_user_flow(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"].startswith(port.description)
|
||||
assert result2["data"] == {
|
||||
"device": {
|
||||
@ -749,7 +749,7 @@ async def test_user_flow_not_detected(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual_pick_radio_type"
|
||||
|
||||
|
||||
@ -761,7 +761,7 @@ async def test_user_flow_show_form(hass: HomeAssistant) -> None:
|
||||
context={CONF_SOURCE: SOURCE_USER},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "choose_serial_port"
|
||||
|
||||
|
||||
@ -773,7 +773,7 @@ async def test_user_flow_show_manual(hass: HomeAssistant) -> None:
|
||||
context={CONF_SOURCE: SOURCE_USER},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual_pick_radio_type"
|
||||
|
||||
|
||||
@ -785,7 +785,7 @@ async def test_user_flow_manual(hass: HomeAssistant) -> None:
|
||||
context={CONF_SOURCE: SOURCE_USER},
|
||||
data={zigpy.config.CONF_DEVICE_PATH: config_flow.CONF_MANUAL_PATH},
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual_pick_radio_type"
|
||||
|
||||
|
||||
@ -798,7 +798,7 @@ async def test_pick_radio_flow(hass: HomeAssistant, radio_type) -> None:
|
||||
context={CONF_SOURCE: "manual_pick_radio_type"},
|
||||
data={CONF_RADIO_TYPE: radio_type},
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual_port_config"
|
||||
|
||||
|
||||
@ -885,7 +885,7 @@ async def test_user_port_config_fail(probe_mock, hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
user_input={zigpy.config.CONF_DEVICE_PATH: "/dev/ttyUSB33"},
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual_port_config"
|
||||
assert result["errors"]["base"] == "cannot_connect"
|
||||
assert probe_mock.await_count == 1
|
||||
@ -907,7 +907,7 @@ async def test_user_port_config(probe_mock, hass: HomeAssistant) -> None:
|
||||
user_input={zigpy.config.CONF_DEVICE_PATH: "/dev/ttyUSB33"},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.MENU
|
||||
assert result["type"] is FlowResultType.MENU
|
||||
assert result["step_id"] == "choose_formation_strategy"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@ -946,7 +946,7 @@ async def test_hardware(onboarded, hass: HomeAssistant) -> None:
|
||||
|
||||
if onboarded:
|
||||
# Confirm discovery
|
||||
assert result1["type"] == FlowResultType.FORM
|
||||
assert result1["type"] is FlowResultType.FORM
|
||||
assert result1["step_id"] == "confirm"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@ -957,7 +957,7 @@ async def test_hardware(onboarded, hass: HomeAssistant) -> None:
|
||||
# No need to confirm
|
||||
result2 = result1
|
||||
|
||||
assert result2["type"] == FlowResultType.MENU
|
||||
assert result2["type"] is FlowResultType.MENU
|
||||
assert result2["step_id"] == "choose_formation_strategy"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@ -997,7 +997,7 @@ async def test_hardware_already_setup(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_HARDWARE}, data=data
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
@ -1011,7 +1011,7 @@ async def test_hardware_invalid_data(hass: HomeAssistant, data) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_HARDWARE}, data=data
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "invalid_hardware_data"
|
||||
|
||||
|
||||
@ -1056,7 +1056,7 @@ def pick_radio(hass):
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.MENU
|
||||
assert result["type"] is FlowResultType.MENU
|
||||
assert result["step_id"] == "choose_formation_strategy"
|
||||
|
||||
return result, port
|
||||
@ -1096,7 +1096,7 @@ async def test_formation_strategy_form_new_network(
|
||||
# A new network will be formed
|
||||
mock_app.form_network.assert_called_once()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
async def test_formation_strategy_form_initial_network(
|
||||
@ -1115,7 +1115,7 @@ async def test_formation_strategy_form_initial_network(
|
||||
# A new network will be formed
|
||||
mock_app.form_network.assert_called_once()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@patch(f"zigpy_znp.{PROBE_FUNCTION_PATH}", AsyncMock(return_value=True))
|
||||
@ -1143,7 +1143,7 @@ async def test_onboarding_auto_formation_new_hardware(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "zigbee radio"
|
||||
assert result["data"] == {
|
||||
"device": {
|
||||
@ -1170,7 +1170,7 @@ async def test_formation_strategy_reuse_settings(
|
||||
# Nothing will be written when settings are reused
|
||||
mock_app.write_network_info.assert_not_called()
|
||||
|
||||
assert result2["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
|
||||
|
||||
@patch("homeassistant.components.zha.config_flow.process_uploaded_file")
|
||||
@ -1200,7 +1200,7 @@ async def test_formation_strategy_restore_manual_backup_non_ezsp(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "upload_manual_backup"
|
||||
|
||||
with patch(
|
||||
@ -1215,7 +1215,7 @@ async def test_formation_strategy_restore_manual_backup_non_ezsp(
|
||||
mock_app.backups.restore_backup.assert_called_once()
|
||||
allow_overwrite_ieee_mock.assert_not_called()
|
||||
|
||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["data"][CONF_RADIO_TYPE] == "znp"
|
||||
|
||||
|
||||
@ -1232,7 +1232,7 @@ async def test_formation_strategy_restore_manual_backup_overwrite_ieee_ezsp(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "upload_manual_backup"
|
||||
|
||||
with patch(
|
||||
@ -1244,7 +1244,7 @@ async def test_formation_strategy_restore_manual_backup_overwrite_ieee_ezsp(
|
||||
user_input={config_flow.UPLOADED_BACKUP_FILE: str(uuid.uuid4())},
|
||||
)
|
||||
|
||||
assert result3["type"] == FlowResultType.FORM
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "maybe_confirm_ezsp_restore"
|
||||
|
||||
result4 = await hass.config_entries.flow.async_configure(
|
||||
@ -1255,7 +1255,7 @@ async def test_formation_strategy_restore_manual_backup_overwrite_ieee_ezsp(
|
||||
allow_overwrite_ieee_mock.assert_called_once()
|
||||
mock_app.backups.restore_backup.assert_called_once()
|
||||
|
||||
assert result4["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["data"][CONF_RADIO_TYPE] == "ezsp"
|
||||
|
||||
|
||||
@ -1272,7 +1272,7 @@ async def test_formation_strategy_restore_manual_backup_ezsp(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "upload_manual_backup"
|
||||
|
||||
backup = zigpy.backups.NetworkBackup()
|
||||
@ -1286,7 +1286,7 @@ async def test_formation_strategy_restore_manual_backup_ezsp(
|
||||
user_input={config_flow.UPLOADED_BACKUP_FILE: str(uuid.uuid4())},
|
||||
)
|
||||
|
||||
assert result3["type"] == FlowResultType.FORM
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "maybe_confirm_ezsp_restore"
|
||||
|
||||
result4 = await hass.config_entries.flow.async_configure(
|
||||
@ -1297,7 +1297,7 @@ async def test_formation_strategy_restore_manual_backup_ezsp(
|
||||
allow_overwrite_ieee_mock.assert_not_called()
|
||||
mock_app.backups.restore_backup.assert_called_once_with(backup)
|
||||
|
||||
assert result4["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["data"][CONF_RADIO_TYPE] == "ezsp"
|
||||
|
||||
|
||||
@ -1313,7 +1313,7 @@ async def test_formation_strategy_restore_manual_backup_invalid_upload(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "upload_manual_backup"
|
||||
|
||||
with patch(
|
||||
@ -1327,7 +1327,7 @@ async def test_formation_strategy_restore_manual_backup_invalid_upload(
|
||||
|
||||
mock_app.backups.restore_backup.assert_not_called()
|
||||
|
||||
assert result3["type"] == FlowResultType.FORM
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "upload_manual_backup"
|
||||
assert result3["errors"]["base"] == "invalid_backup_json"
|
||||
|
||||
@ -1372,7 +1372,7 @@ async def test_formation_strategy_restore_automatic_backup_ezsp(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "choose_automatic_backup"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@ -1382,7 +1382,7 @@ async def test_formation_strategy_restore_automatic_backup_ezsp(
|
||||
},
|
||||
)
|
||||
|
||||
assert result3["type"] == FlowResultType.FORM
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "maybe_confirm_ezsp_restore"
|
||||
|
||||
result4 = await hass.config_entries.flow.async_configure(
|
||||
@ -1392,7 +1392,7 @@ async def test_formation_strategy_restore_automatic_backup_ezsp(
|
||||
|
||||
mock_app.backups.restore_backup.assert_called_once()
|
||||
|
||||
assert result4["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["data"][CONF_RADIO_TYPE] == "ezsp"
|
||||
|
||||
|
||||
@ -1428,7 +1428,7 @@ async def test_formation_strategy_restore_automatic_backup_non_ezsp(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "choose_automatic_backup"
|
||||
|
||||
# We don't prompt for overwriting the IEEE address, since only EZSP needs this
|
||||
@ -1450,7 +1450,7 @@ async def test_formation_strategy_restore_automatic_backup_non_ezsp(
|
||||
|
||||
mock_app.backups.restore_backup.assert_called_once_with(backup)
|
||||
|
||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["data"][CONF_RADIO_TYPE] == "znp"
|
||||
|
||||
|
||||
@ -1480,7 +1480,7 @@ async def test_ezsp_restore_without_settings_change_ieee(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == FlowResultType.FORM
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "upload_manual_backup"
|
||||
|
||||
with patch(
|
||||
@ -1496,7 +1496,7 @@ async def test_ezsp_restore_without_settings_change_ieee(
|
||||
allow_overwrite_ieee_mock.assert_not_called()
|
||||
mock_app.backups.restore_backup.assert_called_once_with(backup, create_new=False)
|
||||
|
||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["data"][CONF_RADIO_TYPE] == "ezsp"
|
||||
|
||||
|
||||
@ -1609,7 +1609,7 @@ async def test_options_flow_defaults(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result6["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result6["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result6["data"] == {}
|
||||
|
||||
# The updated entry contains correct settings
|
||||
@ -1884,7 +1884,7 @@ async def test_probe_wrong_firmware_installed(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "wrong_firmware_installed"
|
||||
|
||||
|
||||
@ -1906,7 +1906,7 @@ async def test_discovery_wrong_firmware_installed(hass: HomeAssistant) -> None:
|
||||
data={},
|
||||
)
|
||||
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "wrong_firmware_installed"
|
||||
|
||||
|
||||
|
@ -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") == "Zodiac"
|
||||
assert result.get("data") == {}
|
||||
assert result.get("options") == {}
|
||||
@ -51,5 +51,5 @@ async def test_single_instance_allowed(
|
||||
DOMAIN, context={"source": source}
|
||||
)
|
||||
|
||||
assert result.get("type") == FlowResultType.ABORT
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "single_instance_allowed"
|
||||
|
@ -42,7 +42,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(
|
||||
result["flow_id"],
|
||||
@ -53,7 +53,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"] == "ws://192.168.1.14"
|
||||
assert result2["data"] == {
|
||||
"url": "ws://192.168.1.14",
|
||||
@ -79,7 +79,7 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=MOCK_ZEROCONF_DATA,
|
||||
)
|
||||
assert result["type"] == FlowResultType.FORM
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@ -90,7 +90,7 @@ async def test_zeroconf(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"] == "ws://192.168.1.14"
|
||||
assert result2["data"] == {
|
||||
"url": "ws://192.168.1.14",
|
||||
@ -107,7 +107,7 @@ async def test_error_handling_zeroconf(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=MOCK_ZEROCONF_DATA,
|
||||
)
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "no_valid_uuid_set"
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ async def test_handle_error_user(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(
|
||||
result["flow_id"],
|
||||
@ -148,7 +148,7 @@ async def test_duplicate_user(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(
|
||||
result["flow_id"],
|
||||
@ -157,7 +157,7 @@ async def test_duplicate_user(hass: HomeAssistant) -> None:
|
||||
"token": "test-token",
|
||||
},
|
||||
)
|
||||
assert result2["type"] == FlowResultType.ABORT
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
@ -183,5 +183,5 @@ async def test_duplicate_zeroconf(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=MOCK_ZEROCONF_DATA,
|
||||
)
|
||||
assert result["type"] == FlowResultType.ABORT
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
Loading…
x
Reference in New Issue
Block a user