mirror of
https://github.com/home-assistant/core.git
synced 2025-08-01 03:35:09 +02:00
Use FlowResultType enum in config flow tests N-Z (#114682)
Use FlowResultType enum in config flow tests
This commit is contained in:
committed by
GitHub
parent
7a543af8ee
commit
f3ba713289
@@ -13,6 +13,7 @@ from homeassistant.components import ssdp, zeroconf
|
||||
from homeassistant.components.nanoleaf.const import DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -55,7 +56,7 @@ async def test_user_unavailable_user_step_link_step(hass: HomeAssistant) -> None
|
||||
CONF_HOST: TEST_HOST,
|
||||
},
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "user"
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
assert not result2["last_step"]
|
||||
@@ -70,7 +71,7 @@ async def test_user_unavailable_user_step_link_step(hass: HomeAssistant) -> None
|
||||
CONF_HOST: TEST_HOST,
|
||||
},
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "link"
|
||||
|
||||
with patch(
|
||||
@@ -78,7 +79,7 @@ async def test_user_unavailable_user_step_link_step(hass: HomeAssistant) -> None
|
||||
side_effect=Unavailable,
|
||||
):
|
||||
result3 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result3["type"] == "abort"
|
||||
assert result3["type"] is FlowResultType.ABORT
|
||||
assert result3["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@@ -106,7 +107,7 @@ async def test_user_error_setup_finish(
|
||||
CONF_HOST: TEST_HOST,
|
||||
},
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "link"
|
||||
|
||||
with (
|
||||
@@ -119,7 +120,7 @@ async def test_user_error_setup_finish(
|
||||
),
|
||||
):
|
||||
result3 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result3["type"] == "abort"
|
||||
assert result3["type"] is FlowResultType.ABORT
|
||||
assert result3["reason"] == reason
|
||||
|
||||
|
||||
@@ -139,7 +140,7 @@ async def test_user_not_authorizing_new_tokens_user_step_link_step(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["last_step"]
|
||||
@@ -150,24 +151,24 @@ async def test_user_not_authorizing_new_tokens_user_step_link_step(
|
||||
CONF_HOST: TEST_HOST,
|
||||
},
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] is None
|
||||
assert result2["step_id"] == "link"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] is None
|
||||
assert result3["step_id"] == "link"
|
||||
|
||||
result4 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result4["type"] == "form"
|
||||
assert result4["type"] is FlowResultType.FORM
|
||||
assert result4["errors"] == {"base": "not_allowing_new_tokens"}
|
||||
assert result4["step_id"] == "link"
|
||||
|
||||
mock_nanoleaf.return_value.authorize.side_effect = None
|
||||
|
||||
result5 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result5["type"] == "create_entry"
|
||||
assert result5["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result5["title"] == TEST_NAME
|
||||
assert result5["data"] == {
|
||||
CONF_HOST: TEST_HOST,
|
||||
@@ -192,7 +193,7 @@ async def test_user_exception_user_step(hass: HomeAssistant) -> None:
|
||||
CONF_HOST: TEST_HOST,
|
||||
},
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "user"
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
assert not result2["last_step"]
|
||||
@@ -212,14 +213,14 @@ async def test_user_exception_user_step(hass: HomeAssistant) -> None:
|
||||
mock_nanoleaf.return_value.authorize.side_effect = Exception()
|
||||
|
||||
result4 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result4["type"] == "form"
|
||||
assert result4["type"] is FlowResultType.FORM
|
||||
assert result4["step_id"] == "link"
|
||||
assert result4["errors"] == {"base": "unknown"}
|
||||
|
||||
mock_nanoleaf.return_value.authorize.side_effect = None
|
||||
mock_nanoleaf.return_value.get_info.side_effect = Exception()
|
||||
result5 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result5["type"] == "abort"
|
||||
assert result5["type"] is FlowResultType.ABORT
|
||||
assert result5["reason"] == "unknown"
|
||||
|
||||
|
||||
@@ -257,7 +258,7 @@ async def test_discovery_link_unavailable(
|
||||
type=type_in_discovery_info,
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "link"
|
||||
|
||||
context = next(
|
||||
@@ -273,7 +274,7 @@ async def test_discovery_link_unavailable(
|
||||
side_effect=Unavailable,
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@@ -305,11 +306,11 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||
},
|
||||
data=entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "link"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
|
||||
assert entry.data[CONF_HOST] == TEST_HOST
|
||||
@@ -403,7 +404,7 @@ async def test_import_discovery_integration(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_NAME
|
||||
assert result["data"] == {
|
||||
CONF_HOST: TEST_HOST,
|
||||
@@ -451,14 +452,14 @@ async def test_ssdp_discovery(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
assert result["step_id"] == "link"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == TEST_NAME
|
||||
assert result2["data"] == {
|
||||
CONF_HOST: TEST_HOST,
|
||||
|
@@ -19,7 +19,7 @@ from homeassistant.components import dhcp
|
||||
from homeassistant.components.nest.const import DOMAIN, OAUTH2_AUTHORIZE, OAUTH2_TOKEN
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.data_entry_flow import FlowResult, FlowResultType
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from .common import (
|
||||
@@ -67,13 +67,13 @@ class OAuthFixture:
|
||||
project_id: str = PROJECT_ID,
|
||||
) -> None:
|
||||
"""Invoke multiple steps in the app credentials based flow."""
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "cloud_project"
|
||||
|
||||
result = await self.async_configure(
|
||||
result, {"cloud_project_id": CLOUD_PROJECT_ID}
|
||||
)
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "device_project"
|
||||
|
||||
result = await self.async_configure(result, {"project_id": project_id})
|
||||
@@ -82,7 +82,7 @@ class OAuthFixture:
|
||||
async def async_oauth_web_flow(self, result: dict, project_id=PROJECT_ID) -> None:
|
||||
"""Invoke the oauth flow for Web Auth with fake responses."""
|
||||
state = self.create_state(result, WEB_REDIRECT_URL)
|
||||
assert result["type"] == "external"
|
||||
assert result["type"] is FlowResultType.EXTERNAL_STEP
|
||||
assert result["url"] == self.authorize_url(
|
||||
state,
|
||||
WEB_REDIRECT_URL,
|
||||
@@ -175,7 +175,7 @@ class OAuthFixture:
|
||||
async def async_pubsub_flow(self, result: dict, cloud_project_id="") -> None:
|
||||
"""Verify the pubsub creation step."""
|
||||
# Render form with a link to get an auth token
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pubsub"
|
||||
assert "description_placeholders" in result
|
||||
assert "url" in result["description_placeholders"]
|
||||
@@ -246,14 +246,14 @@ async def test_config_flow_restart(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "cloud_project"
|
||||
|
||||
# Change the values to show they are reflected below
|
||||
result = await oauth.async_configure(
|
||||
result, {"cloud_project_id": "new-cloud-project-id"}
|
||||
)
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "device_project"
|
||||
|
||||
result = await oauth.async_configure(result, {"project_id": "new-project-id"})
|
||||
@@ -291,17 +291,17 @@ async def test_config_flow_wrong_project_id(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "cloud_project"
|
||||
|
||||
result = await oauth.async_configure(result, {"cloud_project_id": CLOUD_PROJECT_ID})
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "device_project"
|
||||
|
||||
# Enter the cloud project id instead of device access project id (really we just check
|
||||
# they are the same value which is never correct)
|
||||
result = await oauth.async_configure(result, {"project_id": CLOUD_PROJECT_ID})
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert "errors" in result
|
||||
assert "project_id" in result["errors"]
|
||||
assert result["errors"]["project_id"] == "wrong_project_id"
|
||||
@@ -351,7 +351,7 @@ async def test_config_flow_pubsub_configuration_error(
|
||||
|
||||
mock_subscriber.create_subscription.side_effect = ConfigurationException
|
||||
result = await oauth.async_configure(result, {"code": "1234"})
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert "errors" in result
|
||||
assert "cloud_project_id" in result["errors"]
|
||||
assert result["errors"]["cloud_project_id"] == "bad_project_id"
|
||||
@@ -372,7 +372,7 @@ async def test_config_flow_pubsub_subscriber_error(
|
||||
mock_subscriber.create_subscription.side_effect = SubscriberException()
|
||||
result = await oauth.async_configure(result, {"code": "1234"})
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert "errors" in result
|
||||
assert "cloud_project_id" in result["errors"]
|
||||
assert result["errors"]["cloud_project_id"] == "subscriber_error"
|
||||
@@ -414,15 +414,15 @@ async def test_duplicate_config_entries(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "cloud_project"
|
||||
|
||||
result = await oauth.async_configure(result, {"cloud_project_id": CLOUD_PROJECT_ID})
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "device_project"
|
||||
|
||||
result = await oauth.async_configure(result, {"project_id": PROJECT_ID})
|
||||
assert result.get("type") == "abort"
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "already_configured"
|
||||
|
||||
|
||||
@@ -522,7 +522,7 @@ async def test_pubsub_subscription_auth_failure(
|
||||
oauth.async_mock_refresh()
|
||||
result = await oauth.async_configure(result, {"code": "1234"})
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "invalid_access_token"
|
||||
|
||||
|
||||
@@ -693,11 +693,11 @@ async def test_dhcp_discovery(
|
||||
data=FAKE_DHCP_DATA,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "create_cloud_project"
|
||||
|
||||
result = await oauth.async_configure(result, {})
|
||||
assert result.get("type") == "abort"
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "missing_credentials"
|
||||
|
||||
|
||||
@@ -713,11 +713,11 @@ async def test_dhcp_discovery_with_creds(
|
||||
data=FAKE_DHCP_DATA,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "cloud_project"
|
||||
|
||||
result = await oauth.async_configure(result, {"cloud_project_id": CLOUD_PROJECT_ID})
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "device_project"
|
||||
|
||||
result = await oauth.async_configure(result, {"project_id": PROJECT_ID})
|
||||
@@ -775,5 +775,5 @@ async def test_token_error(
|
||||
)
|
||||
|
||||
result = await oauth.async_configure(result, user_input=None)
|
||||
assert result.get("type") == "abort"
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == error_reason
|
||||
|
@@ -10,6 +10,7 @@ from homeassistant import config_entries
|
||||
from homeassistant.components.nexia.const import CONF_BRAND, DOMAIN
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
|
||||
@pytest.mark.parametrize("brand", [BRAND_ASAIR, BRAND_NEXIA])
|
||||
@@ -19,7 +20,7 @@ async def test_form(hass: HomeAssistant, brand) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -42,7 +43,7 @@ async def test_form(hass: HomeAssistant, brand) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "myhouse"
|
||||
assert result2["data"] == {
|
||||
CONF_BRAND: brand,
|
||||
@@ -76,7 +77,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -99,7 +100,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -124,7 +125,7 @@ async def test_form_invalid_auth_http_401(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -149,7 +150,7 @@ async def test_form_cannot_connect_not_found(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -172,5 +173,5 @@ async def test_form_broad_exception(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
@@ -124,7 +124,7 @@ async def test_user_config(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "route"
|
||||
|
||||
# Select route
|
||||
|
@@ -31,7 +31,7 @@ async def test_form(hass: HomeAssistant, hosts: str, mock_get_source_ip) -> None
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
schema_defaults = result["data_schema"]({})
|
||||
@@ -52,7 +52,7 @@ async def test_form(hass: HomeAssistant, hosts: str, mock_get_source_ip) -> None
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == f"Nmap Tracker {hosts}"
|
||||
assert result2["data"] == {}
|
||||
assert result2["options"] == {
|
||||
@@ -70,7 +70,7 @@ async def test_form_range(hass: HomeAssistant, mock_get_source_ip) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch(
|
||||
@@ -88,7 +88,7 @@ async def test_form_range(hass: HomeAssistant, mock_get_source_ip) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Nmap Tracker 192.168.0.5-12"
|
||||
assert result2["data"] == {}
|
||||
assert result2["options"] == {
|
||||
@@ -106,7 +106,7 @@ async def test_form_invalid_hosts(hass: HomeAssistant, mock_get_source_ip) -> No
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@@ -120,7 +120,7 @@ async def test_form_invalid_hosts(hass: HomeAssistant, mock_get_source_ip) -> No
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {CONF_HOSTS: "invalid_hosts"}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ async def test_form_already_configured(hass: HomeAssistant, mock_get_source_ip)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@@ -155,7 +155,7 @@ async def test_form_already_configured(hass: HomeAssistant, mock_get_source_ip)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ async def test_form_invalid_excludes(hass: HomeAssistant, mock_get_source_ip) ->
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@@ -179,7 +179,7 @@ async def test_form_invalid_excludes(hass: HomeAssistant, mock_get_source_ip) ->
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {CONF_EXCLUDE: "invalid_hosts"}
|
||||
|
||||
|
||||
|
@@ -5,6 +5,7 @@ from unittest.mock import PropertyMock, patch
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.nobo_hub.const import CONF_OVERRIDE_TYPE, DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -18,7 +19,7 @@ async def test_configure_with_discover(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@@ -27,7 +28,7 @@ async def test_configure_with_discover(hass: HomeAssistant) -> None:
|
||||
"device": "1.1.1.1",
|
||||
},
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {}
|
||||
assert result2["step_id"] == "selected"
|
||||
|
||||
@@ -52,7 +53,7 @@ async def test_configure_with_discover(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "My Nobø Ecohub"
|
||||
assert result3["data"] == {
|
||||
"ip_address": "1.1.1.1",
|
||||
@@ -72,7 +73,7 @@ async def test_configure_manual(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "manual"
|
||||
|
||||
@@ -98,7 +99,7 @@ async def test_configure_manual(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "My Nobø Ecohub"
|
||||
assert result2["data"] == {
|
||||
"serial": "123456789012",
|
||||
@@ -125,7 +126,7 @@ async def test_configure_user_selected_manual(hass: HomeAssistant) -> None:
|
||||
"device": "manual",
|
||||
},
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {}
|
||||
assert result2["step_id"] == "manual"
|
||||
|
||||
@@ -151,7 +152,7 @@ async def test_configure_user_selected_manual(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "My Nobø Ecohub"
|
||||
assert result2["data"] == {
|
||||
"serial": "123456789012",
|
||||
@@ -183,7 +184,7 @@ async def test_configure_invalid_serial_suffix(hass: HomeAssistant) -> None:
|
||||
{"serial_suffix": "ABC"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] == {"base": "invalid_serial"}
|
||||
|
||||
|
||||
@@ -202,7 +203,7 @@ async def test_configure_invalid_serial_undiscovered(hass: HomeAssistant) -> Non
|
||||
{"ip_address": "1.1.1.1", "serial": "123456789"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_serial"}
|
||||
|
||||
|
||||
@@ -221,7 +222,7 @@ async def test_configure_invalid_ip_address(hass: HomeAssistant) -> None:
|
||||
{"serial": "123456789012", "ip_address": "ABCD"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_ip"}
|
||||
|
||||
|
||||
@@ -250,7 +251,7 @@ async def test_configure_cannot_connect(hass: HomeAssistant) -> None:
|
||||
result2["flow_id"],
|
||||
{"serial_suffix": "012"},
|
||||
)
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] == {"base": "cannot_connect"}
|
||||
mock_connect.assert_awaited_once_with("1.1.1.1", "123456789012")
|
||||
|
||||
@@ -271,7 +272,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -281,7 +282,7 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert config_entry.options == {CONF_OVERRIDE_TYPE: "Constant"}
|
||||
|
||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||
@@ -292,5 +293,5 @@ async def test_options_flow(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert config_entry.options == {CONF_OVERRIDE_TYPE: "Now"}
|
||||
|
@@ -9,6 +9,7 @@ from homeassistant import config_entries
|
||||
from homeassistant.components.nuheat.const import CONF_SERIAL_NUMBER, DOMAIN
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from .mocks import _get_mock_thermostat_run
|
||||
|
||||
@@ -19,7 +20,7 @@ async def test_form_user(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
mock_thermostat = _get_mock_thermostat_run()
|
||||
@@ -47,7 +48,7 @@ async def test_form_user(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Master bathroom"
|
||||
assert result2["data"] == {
|
||||
CONF_SERIAL_NUMBER: "12345",
|
||||
@@ -76,7 +77,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
response_mock = MagicMock()
|
||||
@@ -94,7 +95,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -126,7 +127,7 @@ async def test_form_invalid_thermostat(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_thermostat"}
|
||||
|
||||
|
||||
@@ -149,5 +150,5 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
@@ -7,6 +7,7 @@ import aiohttp
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.nws.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
|
||||
async def test_form(hass: HomeAssistant, mock_simple_nws_config) -> None:
|
||||
@@ -17,7 +18,7 @@ async def test_form(hass: HomeAssistant, mock_simple_nws_config) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch(
|
||||
@@ -29,7 +30,7 @@ async def test_form(hass: HomeAssistant, mock_simple_nws_config) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "ABC"
|
||||
assert result2["data"] == {
|
||||
"api_key": "test",
|
||||
@@ -54,7 +55,7 @@ async def test_form_cannot_connect(hass: HomeAssistant, mock_simple_nws_config)
|
||||
{"api_key": "test"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -72,7 +73,7 @@ async def test_form_unknown_error(hass: HomeAssistant, mock_simple_nws_config) -
|
||||
{"api_key": "test"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@@ -94,7 +95,7 @@ async def test_form_already_configured(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -111,6 +112,6 @@ async def test_form_already_configured(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
@@ -19,7 +19,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert not result["errors"]
|
||||
|
||||
with patch(
|
||||
@@ -37,7 +37,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
with (
|
||||
patch(
|
||||
@@ -61,7 +61,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "1.1.1.1"
|
||||
assert result2["data"] == {
|
||||
"username": "testuser",
|
||||
@@ -94,7 +94,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
"path": "/",
|
||||
},
|
||||
)
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
with patch(
|
||||
"pyoctoprintapi.OctoprintClient.request_app_key", return_value="test-key"
|
||||
@@ -103,7 +103,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
with patch(
|
||||
"pyoctoprintapi.OctoprintClient.get_discovery_info",
|
||||
@@ -123,7 +123,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"]["base"] == "cannot_connect"
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||
"path": "/",
|
||||
},
|
||||
)
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
with patch(
|
||||
"pyoctoprintapi.OctoprintClient.request_app_key", return_value="test-key"
|
||||
@@ -153,7 +153,7 @@ async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||
result["flow_id"],
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
with patch(
|
||||
"pyoctoprintapi.OctoprintClient.get_discovery_info",
|
||||
@@ -173,7 +173,7 @@ async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"]["base"] == "unknown"
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ async def test_show_zerconf_form(hass: HomeAssistant) -> None:
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert not result["errors"]
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -202,7 +202,7 @@ async def test_show_zerconf_form(hass: HomeAssistant) -> None:
|
||||
"username": "testuser",
|
||||
},
|
||||
)
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
with patch(
|
||||
"pyoctoprintapi.OctoprintClient.request_app_key", return_value="test-key"
|
||||
@@ -212,7 +212,7 @@ async def test_show_zerconf_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
with (
|
||||
patch(
|
||||
@@ -262,7 +262,7 @@ async def test_show_ssdp_form(hass: HomeAssistant) -> None:
|
||||
},
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert not result["errors"]
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -271,7 +271,7 @@ async def test_show_ssdp_form(hass: HomeAssistant) -> None:
|
||||
"username": "testuser",
|
||||
},
|
||||
)
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
with patch(
|
||||
"pyoctoprintapi.OctoprintClient.request_app_key", return_value="test-key"
|
||||
@@ -281,7 +281,7 @@ async def test_show_ssdp_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
with (
|
||||
patch(
|
||||
@@ -406,7 +406,7 @@ async def test_failed_auth(hass: HomeAssistant) -> None:
|
||||
"path": "/",
|
||||
},
|
||||
)
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
with patch("pyoctoprintapi.OctoprintClient.request_app_key", side_effect=ApiError):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -414,10 +414,10 @@ async def test_failed_auth(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "auth_failed"
|
||||
|
||||
|
||||
@@ -438,7 +438,7 @@ async def test_failed_auth_unexpected_error(hass: HomeAssistant) -> None:
|
||||
"path": "/",
|
||||
},
|
||||
)
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
with patch("pyoctoprintapi.OctoprintClient.request_app_key", side_effect=Exception):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -446,10 +446,10 @@ async def test_failed_auth_unexpected_error(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "auth_failed"
|
||||
|
||||
|
||||
@@ -465,7 +465,7 @@ async def test_user_duplicate_entry(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert not result["errors"]
|
||||
|
||||
with patch(
|
||||
@@ -483,7 +483,7 @@ async def test_user_duplicate_entry(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
with (
|
||||
patch(
|
||||
@@ -507,7 +507,7 @@ async def test_user_duplicate_entry(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
assert len(mock_setup.mock_calls) == 0
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
@@ -535,7 +535,7 @@ async def test_duplicate_zerconf_ignored(hass: HomeAssistant) -> None:
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -561,7 +561,7 @@ async def test_duplicate_ssdp_ignored(hass: HomeAssistant) -> None:
|
||||
},
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -589,7 +589,7 @@ async def test_reauth_form(hass: HomeAssistant) -> None:
|
||||
},
|
||||
data=entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert not result["errors"]
|
||||
|
||||
with patch(
|
||||
@@ -602,7 +602,7 @@ async def test_reauth_form(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.octoprint.async_setup_entry",
|
||||
@@ -613,5 +613,5 @@ async def test_reauth_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
|
@@ -20,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"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -39,7 +39,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Omnilogic"
|
||||
assert result2["data"] == DATA
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -53,7 +53,7 @@ async def test_already_configured(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ async def test_with_invalid_credentials(hass: HomeAssistant) -> None:
|
||||
DATA,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
@@ -94,7 +94,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
DATA,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@@ -115,7 +115,7 @@ async def test_with_unknown_error(hass: HomeAssistant) -> None:
|
||||
DATA,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": "unknown"}
|
||||
|
||||
|
@@ -235,6 +235,6 @@ async def test_reauth(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
@@ -35,7 +35,7 @@ async def test_form_user(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -60,7 +60,7 @@ async def test_form_user(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Test Entry 1"
|
||||
assert result2["data"] == {
|
||||
CONF_NAME: "Test Entry 1",
|
||||
@@ -99,7 +99,7 @@ async def test_form_import(hass: HomeAssistant) -> None:
|
||||
data={CONF_ID: "legacy_gateway", CONF_DEVICE: "/dev/ttyUSB1"},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "legacy_gateway"
|
||||
assert result["data"] == {
|
||||
CONF_NAME: "legacy_gateway",
|
||||
@@ -150,10 +150,10 @@ async def test_form_duplicate_entries(hass: HomeAssistant) -> None:
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
flow3["flow_id"], {CONF_NAME: "Test Entry 2", CONF_DEVICE: "/dev/ttyUSB0"}
|
||||
)
|
||||
assert result1["type"] == "create_entry"
|
||||
assert result2["type"] == "form"
|
||||
assert result1["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "id_exists"}
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] == {"base": "already_configured"}
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -178,7 +178,7 @@ async def test_form_connection_timeout(hass: HomeAssistant) -> None:
|
||||
{CONF_NAME: "Test Entry 1", CONF_DEVICE: "socket://192.0.2.254:1234"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "timeout_connect"}
|
||||
assert len(mock_connect.mock_calls) == 1
|
||||
|
||||
@@ -199,7 +199,7 @@ async def test_form_connection_error(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], {CONF_NAME: "Test Entry 1", CONF_DEVICE: "/dev/ttyUSB0"}
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
assert len(mock_connect.mock_calls) == 1
|
||||
|
||||
|
@@ -79,14 +79,14 @@ async def test_form_cloud(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> N
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"hub": TEST_SERVER},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "local_or_cloud"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@@ -94,7 +94,7 @@ async def test_form_cloud(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> N
|
||||
{"api_type": "cloud"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "cloud"
|
||||
|
||||
with (
|
||||
@@ -122,14 +122,14 @@ async def test_form_only_cloud_supported(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"hub": TEST_SERVER2},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "cloud"
|
||||
|
||||
with (
|
||||
@@ -157,14 +157,14 @@ async def test_form_local_happy_flow(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"hub": TEST_SERVER},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "local_or_cloud"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@@ -172,7 +172,7 @@ async def test_form_local_happy_flow(
|
||||
{"api_type": "local"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "local"
|
||||
|
||||
with patch.multiple(
|
||||
@@ -218,14 +218,14 @@ async def test_form_invalid_auth_cloud(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"hub": TEST_SERVER},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "local_or_cloud"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@@ -233,7 +233,7 @@ async def test_form_invalid_auth_cloud(
|
||||
{"api_type": "cloud"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "cloud"
|
||||
|
||||
with patch("pyoverkiz.client.OverkizClient.login", side_effect=side_effect):
|
||||
@@ -274,14 +274,14 @@ async def test_form_invalid_auth_local(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"hub": TEST_SERVER},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "local_or_cloud"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@@ -289,7 +289,7 @@ async def test_form_invalid_auth_local(
|
||||
{"api_type": "local"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "local"
|
||||
|
||||
with patch("pyoverkiz.client.OverkizClient.login", side_effect=side_effect):
|
||||
@@ -317,14 +317,14 @@ async def test_form_local_developer_mode_disabled(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"hub": TEST_SERVER},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "local_or_cloud"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@@ -332,7 +332,7 @@ async def test_form_local_developer_mode_disabled(
|
||||
{"api_type": "local"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "local"
|
||||
|
||||
with patch.multiple(
|
||||
@@ -369,14 +369,14 @@ async def test_form_invalid_cozytouch_auth(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"hub": TEST_SERVER_COZYTOUCH},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "cloud"
|
||||
|
||||
with patch("pyoverkiz.client.OverkizClient.login", side_effect=side_effect):
|
||||
@@ -407,14 +407,14 @@ async def test_cloud_abort_on_duplicate_entry(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"hub": TEST_SERVER},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "local_or_cloud"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@@ -422,7 +422,7 @@ async def test_cloud_abort_on_duplicate_entry(
|
||||
{"api_type": "cloud"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "cloud"
|
||||
|
||||
with (
|
||||
@@ -461,14 +461,14 @@ async def test_local_abort_on_duplicate_entry(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"hub": TEST_SERVER},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "local_or_cloud"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@@ -476,7 +476,7 @@ async def test_local_abort_on_duplicate_entry(
|
||||
{"api_type": "local"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "local"
|
||||
|
||||
with patch.multiple(
|
||||
@@ -517,14 +517,14 @@ async def test_cloud_allow_multiple_unique_entries(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"hub": TEST_SERVER},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "local_or_cloud"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@@ -532,7 +532,7 @@ async def test_cloud_allow_multiple_unique_entries(
|
||||
{"api_type": "cloud"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "cloud"
|
||||
|
||||
with (
|
||||
@@ -547,7 +547,7 @@ async def test_cloud_allow_multiple_unique_entries(
|
||||
{"username": TEST_EMAIL, "password": TEST_PASSWORD},
|
||||
)
|
||||
|
||||
assert result4["type"] == "create_entry"
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["title"] == TEST_EMAIL
|
||||
assert result4["data"] == {
|
||||
"api_type": "cloud",
|
||||
@@ -790,7 +790,7 @@ async def test_dhcp_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> No
|
||||
{"hub": TEST_SERVER},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "local_or_cloud"
|
||||
|
||||
await hass.config_entries.flow.async_configure(
|
||||
@@ -810,7 +810,7 @@ async def test_dhcp_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> No
|
||||
},
|
||||
)
|
||||
|
||||
assert result4["type"] == "create_entry"
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["title"] == TEST_EMAIL
|
||||
assert result4["data"] == {
|
||||
"username": TEST_EMAIL,
|
||||
@@ -861,7 +861,7 @@ async def test_zeroconf_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) -
|
||||
{"hub": TEST_SERVER},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "local_or_cloud"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@@ -869,7 +869,7 @@ async def test_zeroconf_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) -
|
||||
{"api_type": "cloud"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "cloud"
|
||||
|
||||
with (
|
||||
@@ -884,7 +884,7 @@ async def test_zeroconf_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock) -
|
||||
{"username": TEST_EMAIL, "password": TEST_PASSWORD},
|
||||
)
|
||||
|
||||
assert result4["type"] == "create_entry"
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["title"] == TEST_EMAIL
|
||||
assert result4["data"] == {
|
||||
"username": TEST_EMAIL,
|
||||
@@ -914,7 +914,7 @@ async def test_local_zeroconf_flow(
|
||||
{"hub": TEST_SERVER},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "local_or_cloud"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@@ -922,7 +922,7 @@ async def test_local_zeroconf_flow(
|
||||
{"api_type": "local"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["step_id"] == "local"
|
||||
|
||||
with patch.multiple(
|
||||
@@ -938,7 +938,7 @@ async def test_local_zeroconf_flow(
|
||||
{"username": TEST_EMAIL, "password": TEST_PASSWORD, "verify_ssl": False},
|
||||
)
|
||||
|
||||
assert result4["type"] == "create_entry"
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["title"] == "gateway-1234-5678-9123.local:8443"
|
||||
assert result4["data"] == {
|
||||
"username": TEST_EMAIL,
|
||||
|
@@ -13,6 +13,7 @@ from homeassistant.components.panasonic_viera.const import (
|
||||
)
|
||||
from homeassistant.const import CONF_PIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from .conftest import (
|
||||
MOCK_BASIC_DATA,
|
||||
@@ -32,7 +33,7 @@ async def test_flow_non_encrypted(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
mock_remote = get_mock_remote(encrypted=False)
|
||||
@@ -46,7 +47,7 @@ async def test_flow_non_encrypted(hass: HomeAssistant) -> None:
|
||||
{**MOCK_BASIC_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == DEFAULT_NAME
|
||||
assert result["data"] == {**MOCK_CONFIG_DATA, ATTR_DEVICE_INFO: MOCK_DEVICE_INFO}
|
||||
|
||||
@@ -58,7 +59,7 @@ async def test_flow_not_connected_error(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
with patch(
|
||||
@@ -70,7 +71,7 @@ async def test_flow_not_connected_error(hass: HomeAssistant) -> None:
|
||||
{**MOCK_BASIC_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@@ -82,7 +83,7 @@ async def test_flow_unknown_abort(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
with patch(
|
||||
@@ -94,7 +95,7 @@ async def test_flow_unknown_abort(hass: HomeAssistant) -> None:
|
||||
{**MOCK_BASIC_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
@@ -107,7 +108,7 @@ async def test_flow_encrypted_not_connected_pin_code_request(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
mock_remote = get_mock_remote(encrypted=True, request_error=TimeoutError)
|
||||
@@ -121,7 +122,7 @@ async def test_flow_encrypted_not_connected_pin_code_request(
|
||||
{**MOCK_BASIC_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@@ -132,7 +133,7 @@ async def test_flow_encrypted_unknown_pin_code_request(hass: HomeAssistant) -> N
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
mock_remote = get_mock_remote(encrypted=True, request_error=Exception)
|
||||
@@ -146,7 +147,7 @@ async def test_flow_encrypted_unknown_pin_code_request(hass: HomeAssistant) -> N
|
||||
{**MOCK_BASIC_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
@@ -157,7 +158,7 @@ async def test_flow_encrypted_valid_pin_code(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
mock_remote = get_mock_remote(
|
||||
@@ -175,7 +176,7 @@ async def test_flow_encrypted_valid_pin_code(hass: HomeAssistant) -> None:
|
||||
{**MOCK_BASIC_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -183,7 +184,7 @@ async def test_flow_encrypted_valid_pin_code(hass: HomeAssistant) -> None:
|
||||
{CONF_PIN: "1234"},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == DEFAULT_NAME
|
||||
assert result["data"] == {
|
||||
**MOCK_CONFIG_DATA,
|
||||
@@ -199,7 +200,7 @@ async def test_flow_encrypted_invalid_pin_code_error(hass: HomeAssistant) -> Non
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
mock_remote = get_mock_remote(encrypted=True, authorize_error=SOAPError)
|
||||
@@ -213,7 +214,7 @@ async def test_flow_encrypted_invalid_pin_code_error(hass: HomeAssistant) -> Non
|
||||
{**MOCK_BASIC_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
|
||||
with patch(
|
||||
@@ -225,7 +226,7 @@ async def test_flow_encrypted_invalid_pin_code_error(hass: HomeAssistant) -> Non
|
||||
{CONF_PIN: "0000"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
assert result["errors"] == {"base": ERROR_INVALID_PIN_CODE}
|
||||
|
||||
@@ -237,7 +238,7 @@ async def test_flow_encrypted_not_connected_abort(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
mock_remote = get_mock_remote(encrypted=True, authorize_error=TimeoutError)
|
||||
@@ -251,7 +252,7 @@ async def test_flow_encrypted_not_connected_abort(hass: HomeAssistant) -> None:
|
||||
{**MOCK_BASIC_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -259,7 +260,7 @@ async def test_flow_encrypted_not_connected_abort(hass: HomeAssistant) -> None:
|
||||
{CONF_PIN: "0000"},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@@ -270,7 +271,7 @@ async def test_flow_encrypted_unknown_abort(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
mock_remote = get_mock_remote(encrypted=True, authorize_error=Exception)
|
||||
@@ -284,7 +285,7 @@ async def test_flow_encrypted_unknown_abort(hass: HomeAssistant) -> None:
|
||||
{**MOCK_BASIC_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -292,7 +293,7 @@ async def test_flow_encrypted_unknown_abort(hass: HomeAssistant) -> None:
|
||||
{CONF_PIN: "0000"},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
@@ -311,7 +312,7 @@ async def test_flow_non_encrypted_already_configured_abort(hass: HomeAssistant)
|
||||
data={**MOCK_BASIC_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -330,7 +331,7 @@ async def test_flow_encrypted_already_configured_abort(hass: HomeAssistant) -> N
|
||||
data={**MOCK_BASIC_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -349,7 +350,7 @@ async def test_imported_flow_non_encrypted(hass: HomeAssistant) -> None:
|
||||
data={**MOCK_CONFIG_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == DEFAULT_NAME
|
||||
assert result["data"] == {**MOCK_CONFIG_DATA, ATTR_DEVICE_INFO: MOCK_DEVICE_INFO}
|
||||
|
||||
@@ -373,7 +374,7 @@ async def test_imported_flow_encrypted_valid_pin_code(hass: HomeAssistant) -> No
|
||||
data={**MOCK_CONFIG_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -381,7 +382,7 @@ async def test_imported_flow_encrypted_valid_pin_code(hass: HomeAssistant) -> No
|
||||
{CONF_PIN: "1234"},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == DEFAULT_NAME
|
||||
assert result["data"] == {
|
||||
**MOCK_CONFIG_DATA,
|
||||
@@ -407,7 +408,7 @@ async def test_imported_flow_encrypted_invalid_pin_code_error(
|
||||
data={**MOCK_CONFIG_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
|
||||
with patch(
|
||||
@@ -419,7 +420,7 @@ async def test_imported_flow_encrypted_invalid_pin_code_error(
|
||||
{CONF_PIN: "0000"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
assert result["errors"] == {"base": ERROR_INVALID_PIN_CODE}
|
||||
|
||||
@@ -439,7 +440,7 @@ async def test_imported_flow_encrypted_not_connected_abort(hass: HomeAssistant)
|
||||
data={**MOCK_CONFIG_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -447,7 +448,7 @@ async def test_imported_flow_encrypted_not_connected_abort(hass: HomeAssistant)
|
||||
{CONF_PIN: "0000"},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@@ -466,7 +467,7 @@ async def test_imported_flow_encrypted_unknown_abort(hass: HomeAssistant) -> Non
|
||||
data={**MOCK_CONFIG_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "pairing"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -474,7 +475,7 @@ async def test_imported_flow_encrypted_unknown_abort(hass: HomeAssistant) -> Non
|
||||
{CONF_PIN: "0000"},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
@@ -491,7 +492,7 @@ async def test_imported_flow_not_connected_error(hass: HomeAssistant) -> None:
|
||||
data={**MOCK_CONFIG_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@@ -509,7 +510,7 @@ async def test_imported_flow_unknown_abort(hass: HomeAssistant) -> None:
|
||||
data={**MOCK_CONFIG_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
@@ -530,7 +531,7 @@ async def test_imported_flow_non_encrypted_already_configured_abort(
|
||||
data={**MOCK_BASIC_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -551,5 +552,5 @@ async def test_imported_flow_encrypted_already_configured_abort(
|
||||
data={**MOCK_BASIC_DATA},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
@@ -44,7 +44,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@@ -53,7 +53,7 @@ async def test_form(hass: HomeAssistant, mock_setup_entry) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Philips TV (1234567890)"
|
||||
assert result2["data"] == MOCK_CONFIG
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -106,7 +106,7 @@ async def test_form_cannot_connect(hass: HomeAssistant, mock_tv) -> None:
|
||||
result["flow_id"], MOCK_USERINPUT
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ async def test_form_unexpected_error(hass: HomeAssistant, mock_tv) -> None:
|
||||
result["flow_id"], MOCK_USERINPUT
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ async def test_pairing(hass: HomeAssistant, mock_tv_pairable, mock_setup_entry)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -140,7 +140,7 @@ async def test_pairing(hass: HomeAssistant, mock_tv_pairable, mock_setup_entry)
|
||||
MOCK_USERINPUT,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
mock_tv.setTransport.assert_called_with(True)
|
||||
@@ -179,7 +179,7 @@ async def test_pair_request_failed(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -205,14 +205,14 @@ async def test_pair_grant_failed(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
MOCK_USERINPUT,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
mock_tv.setTransport.assert_called_with(True)
|
||||
@@ -224,7 +224,7 @@ async def test_pair_grant_failed(
|
||||
result["flow_id"], {"pin": "1234"}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"pin": "invalid_pin"}
|
||||
|
||||
# Test with unexpected failure
|
||||
|
@@ -60,7 +60,7 @@ async def test_form(hass: HomeAssistant, picnic_api) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Picnic"
|
||||
assert result2["data"] == {
|
||||
CONF_ACCESS_TOKEN: picnic_api().session.auth_token,
|
||||
@@ -238,7 +238,7 @@ async def test_step_reauth_failed(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Check that the returned flow has type form with error set
|
||||
assert result_configure["type"] == "form"
|
||||
assert result_configure["type"] is FlowResultType.FORM
|
||||
assert result_configure["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
assert len(hass.config_entries.async_entries()) == 1
|
||||
@@ -277,7 +277,7 @@ async def test_step_reauth_different_account(hass: HomeAssistant, picnic_api) ->
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Check that the returned flow has type form with error set
|
||||
assert result_configure["type"] == "form"
|
||||
assert result_configure["type"] is FlowResultType.FORM
|
||||
assert result_configure["errors"] == {"base": "different_account"}
|
||||
|
||||
assert len(hass.config_entries.async_entries()) == 1
|
||||
|
@@ -47,7 +47,7 @@ async def test_show_config_form(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
|
||||
|
@@ -7,6 +7,7 @@ from requests.exceptions import ConnectTimeout
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.plum_lightpad.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -17,7 +18,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"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -33,7 +34,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "test-plum-username"
|
||||
assert result2["data"] == {
|
||||
"username": "test-plum-username",
|
||||
@@ -57,7 +58,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
{"username": "test-plum-username", "password": "test-plum-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -84,6 +85,6 @@ async def test_form_one_entry_per_email_allowed(hass: HomeAssistant) -> None:
|
||||
{"username": "test-plum-username", "password": "test-plum-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
@@ -31,7 +31,7 @@ async def test_invalid_credentials(hass: HomeAssistant) -> None:
|
||||
data={CONF_EMAIL: "test-email", CONF_PASSWORD: "test-password"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
|
@@ -36,7 +36,7 @@ async def test_form_source_user(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
mock_powerwall = await _mock_powerwall_site_name(hass, "MySite")
|
||||
@@ -57,7 +57,7 @@ async def test_form_source_user(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "MySite"
|
||||
assert result2["data"] == VALID_CONFIG
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -81,7 +81,7 @@ async def test_form_cannot_connect(hass: HomeAssistant, exc: Exception) -> None:
|
||||
VALID_CONFIG,
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {CONF_IP_ADDRESS: "cannot_connect"}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ async def test_invalid_auth(hass: HomeAssistant) -> None:
|
||||
VALID_CONFIG,
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {CONF_PASSWORD: "invalid_auth"}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ async def test_form_unknown_exeption(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], VALID_CONFIG
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ async def test_form_wrong_version(hass: HomeAssistant) -> None:
|
||||
VALID_CONFIG,
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] == {"base": "wrong_version"}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ async def test_already_configured(hass: HomeAssistant) -> None:
|
||||
hostname="any",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ async def test_already_configured_with_ignored(hass: HomeAssistant) -> None:
|
||||
hostname="00GGX",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@@ -212,7 +212,7 @@ async def test_already_configured_with_ignored(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Some site"
|
||||
assert result2["data"] == {"ip_address": "1.1.1.1", "password": "00GGX"}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -235,7 +235,7 @@ async def test_dhcp_discovery_manual_configure(hass: HomeAssistant) -> None:
|
||||
hostname="any",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -254,7 +254,7 @@ async def test_dhcp_discovery_manual_configure(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Some site"
|
||||
assert result2["data"] == VALID_CONFIG
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -277,7 +277,7 @@ async def test_dhcp_discovery_auto_configure(hass: HomeAssistant) -> None:
|
||||
hostname="00GGX",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@@ -296,7 +296,7 @@ async def test_dhcp_discovery_auto_configure(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Some site"
|
||||
assert result2["data"] == {"ip_address": "1.1.1.1", "password": "00GGX"}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -340,7 +340,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_REAUTH, "entry_id": entry.entry_id},
|
||||
data=entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
mock_powerwall = await _mock_powerwall_site_name(hass, "My site")
|
||||
@@ -363,7 +363,7 @@ async def test_form_reauth(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
@@ -13,7 +13,7 @@ from tests.components.bluetooth import inject_bluetooth_service_info
|
||||
|
||||
def assert_form_error(result: FlowResult, key: str, value: str) -> None:
|
||||
"""Assert that a flow returned a form error."""
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"]
|
||||
assert result["errors"][key] == value
|
||||
|
||||
@@ -35,7 +35,7 @@ async def test_invalid_irk(hass: HomeAssistant, enable_bluetooth: None) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"irk": "irk:000000"}
|
||||
@@ -48,7 +48,7 @@ async def test_invalid_irk_base64(hass: HomeAssistant, enable_bluetooth: None) -
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"irk": "Ucredacted4T8n!!ZZZ=="}
|
||||
@@ -61,7 +61,7 @@ async def test_invalid_irk_hex(hass: HomeAssistant, enable_bluetooth: None) -> N
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"irk": "irk:abcdefghi"}
|
||||
@@ -74,7 +74,7 @@ async def test_irk_not_found(hass: HomeAssistant, enable_bluetooth: None) -> Non
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@@ -102,7 +102,7 @@ async def test_flow_works(hass: HomeAssistant, enable_bluetooth: None) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
# Check you can finish the flow
|
||||
with patch(
|
||||
@@ -141,7 +141,7 @@ async def test_flow_works_by_base64(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
# Check you can finish the flow
|
||||
with patch(
|
||||
|
@@ -5,6 +5,7 @@ from unittest.mock import patch
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.profiler.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -15,7 +16,7 @@ async def test_form_user(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with patch(
|
||||
@@ -28,7 +29,7 @@ async def test_form_user(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Profiler"
|
||||
assert result2["data"] == {}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -41,5 +42,5 @@ async def test_form_user_only_once(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
@@ -19,7 +19,7 @@ async def test_form(hass: HomeAssistant, mock_list_contracts) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -48,7 +48,7 @@ async def test_form(hass: HomeAssistant, mock_list_contracts) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "Contract 123"
|
||||
assert result3["data"] == {
|
||||
"contract": "123",
|
||||
@@ -80,7 +80,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
|
@@ -189,7 +189,7 @@ async def test_reauth_failed(hass: HomeAssistant, mock_pushover: MagicMock) -> N
|
||||
data=MOCK_CONFIG,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
mock_pushover.side_effect = BadAPIRequestError("400: application token is invalid")
|
||||
|
@@ -103,7 +103,7 @@ async def test_form_duplicated_id(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ async def test_form_unique_id_error(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "invalid_id"
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ async def test_dhcp_flow(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == {
|
||||
CONF_USERNAME: TEST_USERNAME,
|
||||
CONF_PASSWORD: TEST_PASSWORD,
|
||||
|
@@ -12,6 +12,7 @@ from homeassistant.components.rachio.const import (
|
||||
)
|
||||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -31,7 +32,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"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
rachio_mock = _mock_rachio_return_value(
|
||||
@@ -59,7 +60,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "myusername"
|
||||
assert result2["data"] == {
|
||||
CONF_API_KEY: "api_key",
|
||||
@@ -87,7 +88,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
{CONF_API_KEY: "api_key"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -109,7 +110,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
{CONF_API_KEY: "api_key"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -129,7 +130,7 @@ async def test_form_homekit(hass: HomeAssistant) -> None:
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
flow = next(
|
||||
flow
|
||||
@@ -154,7 +155,7 @@ async def test_form_homekit(hass: HomeAssistant) -> None:
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -180,5 +181,5 @@ async def test_form_homekit_ignored(hass: HomeAssistant) -> None:
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
@@ -31,7 +31,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
|
@@ -102,7 +102,7 @@ async def test_controller_flow(
|
||||
"""Test the controller is setup correctly."""
|
||||
|
||||
result = await complete_flow(hass)
|
||||
assert result.get("type") == "create_entry"
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result.get("title") == HOST
|
||||
assert "result" in result
|
||||
assert dict(result["result"].data) == expected_config_entry
|
||||
@@ -291,7 +291,7 @@ async def test_options_flow(hass: HomeAssistant, mock_setup: Mock) -> None:
|
||||
|
||||
# Setup config flow
|
||||
result = await complete_flow(hass)
|
||||
assert result.get("type") == "create_entry"
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result.get("title") == HOST
|
||||
assert "result" in result
|
||||
assert result["result"].data == CONFIG_ENTRY_DATA
|
||||
|
@@ -45,7 +45,7 @@ async def test_setup_network(transport_mock, hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -54,7 +54,7 @@ async def test_setup_network(transport_mock, hass: HomeAssistant) -> None:
|
||||
{"type": "Network"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "setup_network"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -63,7 +63,7 @@ async def test_setup_network(transport_mock, hass: HomeAssistant) -> None:
|
||||
result["flow_id"], {"host": "10.10.0.1", "port": 1234}
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "RFXTRX"
|
||||
assert result["data"] == {
|
||||
"host": "10.10.0.1",
|
||||
@@ -83,7 +83,7 @@ async def test_setup_serial(com_mock, transport_mock, hass: HomeAssistant) -> No
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -92,7 +92,7 @@ async def test_setup_serial(com_mock, transport_mock, hass: HomeAssistant) -> No
|
||||
{"type": "Serial"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "setup_serial"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -101,7 +101,7 @@ async def test_setup_serial(com_mock, transport_mock, hass: HomeAssistant) -> No
|
||||
result["flow_id"], {"device": port.device}
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "RFXTRX"
|
||||
assert result["data"] == {
|
||||
"host": None,
|
||||
@@ -121,7 +121,7 @@ async def test_setup_serial_manual(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -130,7 +130,7 @@ async def test_setup_serial_manual(
|
||||
{"type": "Serial"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "setup_serial"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -138,7 +138,7 @@ async def test_setup_serial_manual(
|
||||
result["flow_id"], {"device": "Enter Manually"}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "setup_serial_manual_path"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -147,7 +147,7 @@ async def test_setup_serial_manual(
|
||||
result["flow_id"], {"device": "/dev/ttyUSB0"}
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "RFXTRX"
|
||||
assert result["data"] == {
|
||||
"host": None,
|
||||
@@ -165,7 +165,7 @@ async def test_setup_network_fail(transport_mock, hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -174,7 +174,7 @@ async def test_setup_network_fail(transport_mock, hass: HomeAssistant) -> None:
|
||||
{"type": "Network"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "setup_network"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -182,7 +182,7 @@ async def test_setup_network_fail(transport_mock, hass: HomeAssistant) -> None:
|
||||
result["flow_id"], {"host": "10.10.0.1", "port": 1234}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "setup_network"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@@ -197,7 +197,7 @@ async def test_setup_serial_fail(com_mock, transport_mock, hass: HomeAssistant)
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -206,7 +206,7 @@ async def test_setup_serial_fail(com_mock, transport_mock, hass: HomeAssistant)
|
||||
{"type": "Serial"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "setup_serial"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -214,7 +214,7 @@ async def test_setup_serial_fail(com_mock, transport_mock, hass: HomeAssistant)
|
||||
result["flow_id"], {"device": port.device}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "setup_serial"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@@ -229,7 +229,7 @@ async def test_setup_serial_manual_fail(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -238,7 +238,7 @@ async def test_setup_serial_manual_fail(
|
||||
{"type": "Serial"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "setup_serial"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -246,7 +246,7 @@ async def test_setup_serial_manual_fail(
|
||||
result["flow_id"], {"device": "Enter Manually"}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "setup_serial_manual_path"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -254,7 +254,7 @@ async def test_setup_serial_manual_fail(
|
||||
result["flow_id"], {"device": "/dev/ttyUSB0"}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "setup_serial_manual_path"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@@ -277,7 +277,7 @@ async def test_options_global(hass: HomeAssistant) -> None:
|
||||
with patch("homeassistant.components.rfxtrx.async_setup_entry", return_value=True):
|
||||
result = await start_options_flow(hass, entry)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -312,7 +312,7 @@ async def test_no_protocols(hass: HomeAssistant) -> None:
|
||||
with patch("homeassistant.components.rfxtrx.async_setup_entry", return_value=True):
|
||||
result = await start_options_flow(hass, entry)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -345,7 +345,7 @@ async def test_options_add_device(hass: HomeAssistant) -> None:
|
||||
)
|
||||
result = await start_options_flow(hass, entry)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
||||
# Try with invalid event code
|
||||
@@ -354,7 +354,7 @@ async def test_options_add_device(hass: HomeAssistant) -> None:
|
||||
user_input={"automatic_add": True, "event_code": "1234"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "prompt_options"
|
||||
assert result["errors"]
|
||||
assert result["errors"]["event_code"] == "invalid_event_code"
|
||||
@@ -368,7 +368,7 @@ async def test_options_add_device(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "set_device_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -409,7 +409,7 @@ async def test_options_add_duplicate_device(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -420,7 +420,7 @@ async def test_options_add_duplicate_device(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "prompt_options"
|
||||
assert result["errors"]
|
||||
assert result["errors"]["event_code"] == "already_configured_device"
|
||||
@@ -508,7 +508,7 @@ async def test_options_replace_sensor_device(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -519,7 +519,7 @@ async def test_options_replace_sensor_device(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "set_device_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -641,7 +641,7 @@ async def test_options_replace_control_device(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -652,7 +652,7 @@ async def test_options_replace_control_device(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "set_device_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -702,7 +702,7 @@ async def test_options_add_and_configure_device(hass: HomeAssistant) -> None:
|
||||
)
|
||||
result = await start_options_flow(hass, entry)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -713,7 +713,7 @@ async def test_options_add_and_configure_device(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "set_device_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -726,7 +726,7 @@ async def test_options_add_and_configure_device(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "set_device_options"
|
||||
assert result["errors"]
|
||||
assert result["errors"]["off_delay"] == "invalid_input_off_delay"
|
||||
@@ -764,7 +764,7 @@ async def test_options_add_and_configure_device(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -775,7 +775,7 @@ async def test_options_add_and_configure_device(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "set_device_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -811,7 +811,7 @@ async def test_options_configure_rfy_cover_device(hass: HomeAssistant) -> None:
|
||||
)
|
||||
result = await start_options_flow(hass, entry)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -822,7 +822,7 @@ async def test_options_configure_rfy_cover_device(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "set_device_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -849,7 +849,7 @@ async def test_options_configure_rfy_cover_device(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "prompt_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -860,7 +860,7 @@ async def test_options_configure_rfy_cover_device(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "set_device_options"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
|
@@ -24,7 +24,7 @@ async def test_form(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@@ -33,7 +33,7 @@ async def test_form(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "hello@home-assistant.io"
|
||||
assert result2["data"] == {
|
||||
"username": "hello@home-assistant.io",
|
||||
@@ -63,7 +63,7 @@ async def test_form_error(
|
||||
{"username": "hello@home-assistant.io", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": errors_msg}
|
||||
|
||||
|
||||
|
@@ -158,7 +158,7 @@ async def test_form_reauth(hass: HomeAssistant, cloud_config_entry) -> None:
|
||||
context={"source": config_entries.SOURCE_REAUTH},
|
||||
data=cloud_config_entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -183,7 +183,7 @@ async def test_form_reauth(hass: HomeAssistant, cloud_config_entry) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
assert cloud_config_entry.data[CONF_PASSWORD] == "new_password"
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -199,7 +199,7 @@ async def test_form_reauth_with_new_username(
|
||||
context={"source": config_entries.SOURCE_REAUTH},
|
||||
data=cloud_config_entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -224,7 +224,7 @@ async def test_form_reauth_with_new_username(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
assert cloud_config_entry.data[CONF_USERNAME] == "new_user"
|
||||
assert cloud_config_entry.unique_id == "new_user"
|
||||
|
@@ -10,6 +10,7 @@ from homeassistant import config_entries
|
||||
from homeassistant.components.rituals_perfume_genie.const import ACCOUNT_HASH, DOMAIN
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
TEST_EMAIL = "rituals@example.com"
|
||||
VALID_PASSWORD = "passw0rd"
|
||||
@@ -29,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"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@@ -51,7 +52,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == TEST_EMAIL
|
||||
assert isinstance(result2["data"][ACCOUNT_HASH], str)
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -75,7 +76,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -97,7 +98,7 @@ async def test_form_auth_exception(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@@ -121,5 +122,5 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
@@ -1009,7 +1009,7 @@ async def test_dhcp_discovery_partial_hostname(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "link"
|
||||
|
||||
with patch(
|
||||
|
@@ -94,7 +94,7 @@ async def test_successful_discovery_and_auth(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Should go straight to link if server was discovered
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "link"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -136,7 +136,7 @@ async def test_unsuccessful_discovery_user_form_and_auth(hass: HomeAssistant) ->
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Should show the form if server was not discovered
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "fallback"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -183,7 +183,7 @@ async def test_duplicate_config(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Should show the form if server was not discovered
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "fallback"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -230,7 +230,7 @@ async def test_successful_discovery_no_auth(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Should go straight to link if server was discovered
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "link"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -265,7 +265,7 @@ async def test_unexpected_exception(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# Should go straight to link if server was discovered
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "link"
|
||||
assert result["errors"] == {}
|
||||
|
||||
|
@@ -11,6 +11,7 @@ from homeassistant.components.hassio import HassioServiceInfo
|
||||
from homeassistant.components.rtsp_to_webrtc import DOMAIN
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from .conftest import ComponentSetup
|
||||
|
||||
@@ -22,7 +23,7 @@ async def test_web_full_flow(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("data_schema").schema.get("server_url") == str
|
||||
assert not result.get("errors")
|
||||
@@ -36,7 +37,7 @@ async def test_web_full_flow(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"server_url": "https://example.com"}
|
||||
)
|
||||
assert result.get("type") == "create_entry"
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result.get("title") == "https://example.com"
|
||||
assert "result" in result
|
||||
assert result["result"].data == {"server_url": "https://example.com"}
|
||||
@@ -52,7 +53,7 @@ async def test_single_config_entry(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == "abort"
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "single_instance_allowed"
|
||||
|
||||
|
||||
@@ -61,7 +62,7 @@ async def test_invalid_url(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("data_schema").schema.get("server_url") == str
|
||||
assert not result.get("errors")
|
||||
@@ -69,7 +70,7 @@ async def test_invalid_url(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], {"server_url": "not-a-url"}
|
||||
)
|
||||
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("errors") == {"server_url": "invalid_url"}
|
||||
|
||||
@@ -79,7 +80,7 @@ async def test_server_unreachable(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "user"
|
||||
assert not result.get("errors")
|
||||
with patch(
|
||||
@@ -89,7 +90,7 @@ async def test_server_unreachable(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"server_url": "https://example.com"}
|
||||
)
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("errors") == {"base": "server_unreachable"}
|
||||
|
||||
@@ -99,7 +100,7 @@ async def test_server_failure(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "user"
|
||||
assert not result.get("errors")
|
||||
with patch(
|
||||
@@ -109,7 +110,7 @@ async def test_server_failure(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"server_url": "https://example.com"}
|
||||
)
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "user"
|
||||
assert result.get("errors") == {"base": "server_failure"}
|
||||
|
||||
@@ -130,7 +131,7 @@ async def test_hassio_discovery(hass: HomeAssistant) -> None:
|
||||
),
|
||||
context={"source": config_entries.SOURCE_HASSIO},
|
||||
)
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "hassio_confirm"
|
||||
assert result.get("description_placeholders") == {"addon": "RTSPtoWebRTC"}
|
||||
|
||||
@@ -146,7 +147,7 @@ async def test_hassio_discovery(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result.get("type") == "create_entry"
|
||||
assert result.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result.get("title") == "RTSPtoWebRTC"
|
||||
assert "result" in result
|
||||
assert result["result"].data == {"server_url": "http://fake-server:8083"}
|
||||
@@ -173,7 +174,7 @@ async def test_hassio_single_config_entry(hass: HomeAssistant) -> None:
|
||||
),
|
||||
context={"source": config_entries.SOURCE_HASSIO},
|
||||
)
|
||||
assert result.get("type") == "abort"
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "single_instance_allowed"
|
||||
|
||||
|
||||
@@ -196,7 +197,7 @@ async def test_hassio_ignored(hass: HomeAssistant) -> None:
|
||||
),
|
||||
context={"source": config_entries.SOURCE_HASSIO},
|
||||
)
|
||||
assert result.get("type") == "abort"
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "single_instance_allowed"
|
||||
|
||||
|
||||
@@ -217,7 +218,7 @@ async def test_hassio_discovery_server_failure(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_HASSIO},
|
||||
)
|
||||
|
||||
assert result.get("type") == "form"
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
assert result.get("step_id") == "hassio_confirm"
|
||||
assert not result.get("errors")
|
||||
|
||||
@@ -226,7 +227,7 @@ async def test_hassio_discovery_server_failure(hass: HomeAssistant) -> None:
|
||||
side_effect=rtsp_to_webrtc.exceptions.ResponseError(),
|
||||
):
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result.get("type") == "abort"
|
||||
assert result.get("type") is FlowResultType.ABORT
|
||||
assert result.get("reason") == "server_failure"
|
||||
|
||||
|
||||
@@ -246,7 +247,7 @@ async def test_options_flow(
|
||||
assert not config_entry.options
|
||||
|
||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
data_schema = result["data_schema"].schema
|
||||
assert set(data_schema) == {"stun_server"}
|
||||
@@ -257,17 +258,17 @@ async def test_options_flow(
|
||||
"stun_server": "example.com:1234",
|
||||
},
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
await hass.async_block_till_done()
|
||||
assert config_entry.options == {"stun_server": "example.com:1234"}
|
||||
|
||||
# Clear the value
|
||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||
assert result["type"] == "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={}
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
await hass.async_block_till_done()
|
||||
assert config_entry.options == {}
|
||||
|
@@ -171,7 +171,7 @@ async def test_form_reauth(hass: HomeAssistant, config_entry) -> None:
|
||||
},
|
||||
data=config_entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@@ -197,7 +197,7 @@ async def test_form_reauth(hass: HomeAssistant, config_entry) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
assert config_entry.data[CONF_PASSWORD] == "new_password"
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -214,7 +214,7 @@ async def test_form_reauth_with_new_account(hass: HomeAssistant, config_entry) -
|
||||
},
|
||||
data=config_entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@@ -240,7 +240,7 @@ async def test_form_reauth_with_new_account(hass: HomeAssistant, config_entry) -
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
assert config_entry.data[CONF_UNIQUE_ID] == "new-account-number"
|
||||
assert config_entry.unique_id == "new-account-number"
|
||||
|
@@ -214,7 +214,7 @@ async def test_user_legacy(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
# entry was added
|
||||
@@ -222,7 +222,7 @@ async def test_user_legacy(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], user_input=MOCK_USER_DATA
|
||||
)
|
||||
# legacy tv entry created
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "fake_name"
|
||||
assert result["data"][CONF_HOST] == "fake_host"
|
||||
assert result["data"][CONF_NAME] == "fake_name"
|
||||
@@ -243,7 +243,7 @@ async def test_user_legacy_does_not_ok_first_time(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
# entry was added
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@@ -257,7 +257,7 @@ async def test_user_legacy_does_not_ok_first_time(hass: HomeAssistant) -> None:
|
||||
)
|
||||
|
||||
# legacy tv entry created
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "fake_name"
|
||||
assert result3["data"][CONF_HOST] == "fake_host"
|
||||
assert result3["data"][CONF_NAME] == "fake_name"
|
||||
@@ -277,7 +277,7 @@ async def test_user_websocket(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
# entry was added
|
||||
@@ -285,7 +285,7 @@ async def test_user_websocket(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], user_input=MOCK_USER_DATA
|
||||
)
|
||||
# websocket tv entry created
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Living Room (82GXARRS)"
|
||||
assert result["data"][CONF_HOST] == "fake_host"
|
||||
assert result["data"][CONF_NAME] == "Living Room"
|
||||
@@ -304,7 +304,7 @@ async def test_user_encrypted_websocket(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
with patch(
|
||||
@@ -321,7 +321,7 @@ async def test_user_encrypted_websocket(
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input=MOCK_USER_DATA
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "encrypted_pairing"
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@@ -334,7 +334,7 @@ async def test_user_encrypted_websocket(
|
||||
result3["flow_id"], user_input={"pin": "1234"}
|
||||
)
|
||||
|
||||
assert result4["type"] == "create_entry"
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["title"] == "TV-UE48JU6470 (UE48JU6400)"
|
||||
assert result4["data"][CONF_HOST] == "fake_host"
|
||||
assert result4["data"][CONF_NAME] == "TV-UE48JU6470"
|
||||
@@ -385,7 +385,7 @@ async def test_user_legacy_not_supported(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_NOT_SUPPORTED
|
||||
|
||||
|
||||
@@ -406,7 +406,7 @@ async def test_user_websocket_not_supported(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_NOT_SUPPORTED
|
||||
|
||||
|
||||
@@ -429,7 +429,7 @@ async def test_user_websocket_access_denied(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_NOT_SUPPORTED
|
||||
assert "Please check the Device Connection Manager on your TV" in caplog.text
|
||||
|
||||
@@ -491,7 +491,7 @@ async def test_user_not_successful(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_CANNOT_CONNECT
|
||||
|
||||
|
||||
@@ -511,7 +511,7 @@ async def test_user_not_successful_2(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_CANNOT_CONNECT
|
||||
|
||||
|
||||
@@ -522,14 +522,14 @@ async def test_ssdp(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
# entry was added
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input="whatever"
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "fake_model"
|
||||
assert result["data"][CONF_HOST] == "fake_host"
|
||||
assert result["data"][CONF_NAME] == "fake_model"
|
||||
@@ -546,7 +546,7 @@ async def test_ssdp_no_manufacturer(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=MOCK_SSDP_DATA_NO_MANUFACTURER,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_supported"
|
||||
|
||||
|
||||
@@ -574,13 +574,13 @@ async def test_ssdp_noprefix(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=MOCK_SSDP_DATA_NOPREFIX,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
# entry was added
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input="whatever"
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "fake2_model"
|
||||
assert result["data"][CONF_HOST] == "fake2_host"
|
||||
assert result["data"][CONF_NAME] == "fake2_model"
|
||||
@@ -600,7 +600,7 @@ async def test_ssdp_legacy_missing_auth(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
# missing authentication
|
||||
@@ -650,13 +650,13 @@ async def test_ssdp_websocket_success_populates_mac_address_and_ssdp_location(
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=MOCK_SSDP_DATA_RENDERING_CONTROL_ST,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input="whatever"
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Living Room (82GXARRS)"
|
||||
assert result["data"][CONF_HOST] == "fake_host"
|
||||
assert result["data"][CONF_NAME] == "Living Room"
|
||||
@@ -680,13 +680,13 @@ async def test_ssdp_websocket_success_populates_mac_address_and_main_tv_ssdp_loc
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=MOCK_SSDP_DATA_MAIN_TV_AGENT_ST,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input="whatever"
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Living Room (82GXARRS)"
|
||||
assert result["data"][CONF_HOST] == "fake_host"
|
||||
assert result["data"][CONF_NAME] == "Living Room"
|
||||
@@ -710,7 +710,7 @@ async def test_ssdp_encrypted_websocket_success_populates_mac_address_and_ssdp_l
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=MOCK_SSDP_DATA_RENDERING_CONTROL_ST,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
with patch(
|
||||
@@ -738,7 +738,7 @@ async def test_ssdp_encrypted_websocket_success_populates_mac_address_and_ssdp_l
|
||||
result3["flow_id"], user_input={"pin": "1234"}
|
||||
)
|
||||
|
||||
assert result4["type"] == "create_entry"
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["title"] == "TV-UE48JU6470 (UE48JU6400)"
|
||||
assert result4["data"][CONF_HOST] == "fake_host"
|
||||
assert result4["data"][CONF_NAME] == "TV-UE48JU6470"
|
||||
@@ -793,7 +793,7 @@ async def test_ssdp_websocket_cannot_connect(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_CANNOT_CONNECT
|
||||
|
||||
|
||||
@@ -807,7 +807,7 @@ async def test_ssdp_model_not_supported(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_SSDP},
|
||||
data=MOCK_SSDP_DATA_WRONGMODEL,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_NOT_SUPPORTED
|
||||
|
||||
|
||||
@@ -832,14 +832,14 @@ async def test_ssdp_not_successful(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
# device not found
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input="whatever"
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_CANNOT_CONNECT
|
||||
|
||||
|
||||
@@ -864,14 +864,14 @@ async def test_ssdp_not_successful_2(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
# device not found
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input="whatever"
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_CANNOT_CONNECT
|
||||
|
||||
|
||||
@@ -886,14 +886,14 @@ async def test_ssdp_already_in_progress(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
# failed as already in progress
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_ALREADY_IN_PROGRESS
|
||||
|
||||
|
||||
@@ -908,7 +908,7 @@ async def test_ssdp_already_configured(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
entry = result["result"]
|
||||
assert entry.data[CONF_MANUFACTURER] == DEFAULT_MANUFACTURER
|
||||
assert entry.data[CONF_MODEL] == "fake_model"
|
||||
@@ -918,7 +918,7 @@ async def test_ssdp_already_configured(hass: HomeAssistant) -> None:
|
||||
result2 = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||
)
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == RESULT_ALREADY_CONFIGURED
|
||||
|
||||
# check updated device info
|
||||
@@ -935,14 +935,14 @@ async def test_dhcp_wireless(hass: HomeAssistant) -> None:
|
||||
data=MOCK_DHCP_DATA,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
# entry was added
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input="whatever"
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "TV-UE48JU6470 (UE48JU6400)"
|
||||
assert result["data"][CONF_HOST] == "fake_host"
|
||||
assert result["data"][CONF_NAME] == "TV-UE48JU6470"
|
||||
@@ -964,14 +964,14 @@ async def test_dhcp_wired(hass: HomeAssistant, rest_api: Mock) -> None:
|
||||
data=MOCK_DHCP_DATA,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
# entry was added
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input="whatever"
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Samsung Frame (43) (UE43LS003)"
|
||||
assert result["data"][CONF_HOST] == "fake_host"
|
||||
assert result["data"][CONF_NAME] == "Samsung Frame (43)"
|
||||
@@ -990,14 +990,14 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
|
||||
data=MOCK_ZEROCONF_DATA,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
# entry was added
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input="whatever"
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Living Room (82GXARRS)"
|
||||
assert result["data"][CONF_HOST] == "127.0.0.1"
|
||||
assert result["data"][CONF_NAME] == "Living Room"
|
||||
@@ -1026,7 +1026,7 @@ async def test_zeroconf_ignores_soundbar(hass: HomeAssistant, rest_api: Mock) ->
|
||||
data=MOCK_ZEROCONF_DATA,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_supported"
|
||||
|
||||
|
||||
@@ -1039,7 +1039,7 @@ async def test_zeroconf_no_device_info(hass: HomeAssistant) -> None:
|
||||
data=MOCK_ZEROCONF_DATA,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_supported"
|
||||
|
||||
|
||||
@@ -1052,7 +1052,7 @@ async def test_zeroconf_and_dhcp_same_time(hass: HomeAssistant) -> None:
|
||||
data=MOCK_DHCP_DATA,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_init(
|
||||
@@ -1061,7 +1061,7 @@ async def test_zeroconf_and_dhcp_same_time(hass: HomeAssistant) -> None:
|
||||
data=MOCK_ZEROCONF_DATA,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_in_progress"
|
||||
|
||||
|
||||
@@ -1103,7 +1103,7 @@ async def test_autodetect_websocket(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"][CONF_METHOD] == "websocket"
|
||||
assert result["data"][CONF_TOKEN] == "123456789"
|
||||
remotews.assert_called_once_with(**AUTODETECT_WEBSOCKET_SSL)
|
||||
@@ -1153,7 +1153,7 @@ async def test_websocket_no_mac(hass: HomeAssistant, mac_address: Mock) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"][CONF_METHOD] == "websocket"
|
||||
assert result["data"][CONF_TOKEN] == "123456789"
|
||||
assert result["data"][CONF_MAC] == "gg:ee:tt:mm:aa:cc"
|
||||
@@ -1205,7 +1205,7 @@ async def test_autodetect_not_supported(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_NOT_SUPPORTED
|
||||
assert remote.call_count == 1
|
||||
assert remote.call_args_list == [call(AUTODETECT_LEGACY)]
|
||||
@@ -1217,7 +1217,7 @@ async def test_autodetect_legacy(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"][CONF_METHOD] == "legacy"
|
||||
assert result["data"][CONF_NAME] == "fake_name"
|
||||
assert result["data"][CONF_MAC] is None
|
||||
@@ -1239,7 +1239,7 @@ async def test_autodetect_none(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=MOCK_USER_DATA
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_CANNOT_CONNECT
|
||||
assert remote.call_count == 1
|
||||
assert remote.call_args_list == [
|
||||
@@ -1268,7 +1268,7 @@ async def test_update_old_entry(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_SSDP}, data=MOCK_SSDP_DATA
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == RESULT_ALREADY_CONFIGURED
|
||||
|
||||
config_entries_domain = hass.config_entries.async_entries(DOMAIN)
|
||||
@@ -1297,7 +1297,7 @@ async def test_update_missing_mac_unique_id_added_from_dhcp(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:cc:dd:ee:ff"
|
||||
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
|
||||
@@ -1321,7 +1321,7 @@ async def test_update_incorrectly_formatted_mac_unique_id_added_from_dhcp(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:cc:dd:ee:ff"
|
||||
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
|
||||
@@ -1345,7 +1345,7 @@ async def test_update_missing_mac_unique_id_added_from_zeroconf(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:zz:ee:rr:oo"
|
||||
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
|
||||
@@ -1371,7 +1371,7 @@ async def test_update_missing_model_added_from_ssdp(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MODEL] == "fake_model"
|
||||
|
||||
@@ -1392,7 +1392,7 @@ async def test_update_missing_mac_unique_id_ssdp_location_added_from_ssdp(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:aa:aa:aa:aa"
|
||||
# Wrong st
|
||||
@@ -1419,7 +1419,7 @@ async def test_update_zeroconf_discovery_preserved_unique_id(
|
||||
data=MOCK_ZEROCONF_DATA,
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_supported"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:zz:ee:rr:oo"
|
||||
assert entry.unique_id == "original"
|
||||
@@ -1448,7 +1448,7 @@ async def test_update_missing_mac_unique_id_added_ssdp_location_updated_from_ssd
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:aa:aa:aa:aa"
|
||||
# Wrong ST, ssdp location should not change
|
||||
@@ -1481,7 +1481,7 @@ async def test_update_missing_mac_unique_id_added_ssdp_location_rendering_st_upd
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:aa:aa:aa:aa"
|
||||
# Correct ST, ssdp location should change
|
||||
@@ -1516,7 +1516,7 @@ async def test_update_missing_mac_unique_id_added_ssdp_location_main_tv_agent_st
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:aa:aa:aa:aa"
|
||||
# Main TV Agent ST, ssdp location should change
|
||||
@@ -1551,7 +1551,7 @@ async def test_update_ssdp_location_rendering_st_updated_from_ssdp(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:aa:aa:aa:aa"
|
||||
# Correct ST, ssdp location should be added
|
||||
@@ -1582,7 +1582,7 @@ async def test_update_main_tv_ssdp_location_rendering_st_updated_from_ssdp(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:aa:aa:aa:aa"
|
||||
# Correct ST for MainTV, ssdp location should be added
|
||||
@@ -1613,7 +1613,7 @@ async def test_update_missing_mac_added_unique_id_preserved_from_zeroconf(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:zz:ee:rr:oo"
|
||||
assert entry.unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172de"
|
||||
@@ -1641,7 +1641,7 @@ async def test_update_legacy_missing_mac_from_dhcp(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:cc:dd:ee:ff"
|
||||
assert entry.unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172de"
|
||||
@@ -1678,7 +1678,7 @@ async def test_update_legacy_missing_mac_from_dhcp_no_unique_id(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_supported"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:cc:dd:ee:ff"
|
||||
assert entry.unique_id is None
|
||||
@@ -1704,7 +1704,7 @@ async def test_update_ssdp_location_unique_id_added_from_ssdp(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:aa:aa:aa:aa"
|
||||
# Wrong st
|
||||
@@ -1732,7 +1732,7 @@ async def test_update_ssdp_location_unique_id_added_from_ssdp_with_rendering_con
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:aa:aa:aa:aa"
|
||||
# Correct st
|
||||
@@ -1753,7 +1753,7 @@ async def test_form_reauth_legacy(hass: HomeAssistant) -> None:
|
||||
context={"entry_id": entry.entry_id, "source": config_entries.SOURCE_REAUTH},
|
||||
data=entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@@ -1761,7 +1761,7 @@ async def test_form_reauth_legacy(hass: HomeAssistant) -> None:
|
||||
{},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@@ -1777,7 +1777,7 @@ async def test_form_reauth_websocket(hass: HomeAssistant) -> None:
|
||||
context={"entry_id": entry.entry_id, "source": config_entries.SOURCE_REAUTH},
|
||||
data=entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@@ -1785,7 +1785,7 @@ async def test_form_reauth_websocket(hass: HomeAssistant) -> None:
|
||||
{},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
assert entry.state == config_entries.ConfigEntryState.LOADED
|
||||
|
||||
@@ -1802,7 +1802,7 @@ async def test_form_reauth_websocket_cannot_connect(
|
||||
context={"entry_id": entry.entry_id, "source": config_entries.SOURCE_REAUTH},
|
||||
data=entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch.object(remotews, "open", side_effect=ConnectionFailure):
|
||||
@@ -1812,7 +1812,7 @@ async def test_form_reauth_websocket_cannot_connect(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": RESULT_AUTH_MISSING}
|
||||
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
@@ -1821,7 +1821,7 @@ async def test_form_reauth_websocket_cannot_connect(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == "abort"
|
||||
assert result3["type"] is FlowResultType.ABORT
|
||||
assert result3["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@@ -1834,7 +1834,7 @@ async def test_form_reauth_websocket_not_supported(hass: HomeAssistant) -> None:
|
||||
context={"entry_id": entry.entry_id, "source": config_entries.SOURCE_REAUTH},
|
||||
data=entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch(
|
||||
@@ -1847,7 +1847,7 @@ async def test_form_reauth_websocket_not_supported(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "not_supported"
|
||||
|
||||
|
||||
@@ -1867,7 +1867,7 @@ async def test_form_reauth_encrypted(hass: HomeAssistant) -> None:
|
||||
context={"entry_id": entry.entry_id, "source": config_entries.SOURCE_REAUTH},
|
||||
data=entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch(
|
||||
@@ -1882,7 +1882,7 @@ async def test_form_reauth_encrypted(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -1891,14 +1891,14 @@ async def test_form_reauth_encrypted(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm_encrypted"
|
||||
|
||||
# Invalid PIN
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"pin": "invalid"}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm_encrypted"
|
||||
|
||||
# Valid PIN
|
||||
@@ -1906,7 +1906,7 @@ async def test_form_reauth_encrypted(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], user_input={"pin": "1234"}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
assert entry.state == config_entries.ConfigEntryState.LOADED
|
||||
|
||||
@@ -1945,7 +1945,7 @@ async def test_update_incorrect_udn_matching_upnp_udn_unique_id_added_from_ssdp(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:aa:aa:aa:aa"
|
||||
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
|
||||
@@ -1971,7 +1971,7 @@ async def test_update_incorrect_udn_matching_mac_unique_id_added_from_ssdp(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:aa:aa:aa:aa"
|
||||
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
|
||||
@@ -1998,7 +1998,7 @@ async def test_update_incorrect_udn_matching_mac_from_dhcp(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:aa:aa:aa:aa"
|
||||
assert entry.unique_id == "be9554b9-c9fb-41f4-8920-22da015376a4"
|
||||
@@ -2025,7 +2025,7 @@ async def test_no_update_incorrect_udn_not_matching_mac_from_dhcp(
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "confirm"
|
||||
assert entry.data[CONF_MAC] == "aa:bb:ss:ss:dd:pp"
|
||||
assert entry.unique_id == "0d1cef00-00dc-1000-9c80-4844f7b172de"
|
||||
|
@@ -24,6 +24,7 @@ from homeassistant.components.screenlogic.const import (
|
||||
)
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, CONF_SCAN_INTERVAL
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -47,7 +48,7 @@ async def test_flow_discovery(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "gateway_select"
|
||||
|
||||
@@ -60,7 +61,7 @@ async def test_flow_discovery(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Pentair: 01-01-01"
|
||||
assert result2["data"] == {
|
||||
CONF_IP_ADDRESS: "1.1.1.1",
|
||||
@@ -80,7 +81,7 @@ async def test_flow_discover_none(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "gateway_entry"
|
||||
|
||||
@@ -96,7 +97,7 @@ async def test_flow_discover_error(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "gateway_entry"
|
||||
|
||||
@@ -119,7 +120,7 @@ async def test_flow_discover_error(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "Pentair: 01-01-01"
|
||||
assert result3["data"] == {
|
||||
CONF_IP_ADDRESS: "1.1.1.1",
|
||||
@@ -141,7 +142,7 @@ async def test_dhcp(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "gateway_entry"
|
||||
|
||||
with (
|
||||
@@ -163,7 +164,7 @@ async def test_dhcp(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "Pentair: 01-01-01"
|
||||
assert result3["data"] == {
|
||||
CONF_IP_ADDRESS: "1.1.1.1",
|
||||
@@ -190,7 +191,7 @@ async def test_form_manual_entry(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "gateway_select"
|
||||
|
||||
@@ -198,7 +199,7 @@ async def test_form_manual_entry(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], user_input={GATEWAY_SELECT_KEY: GATEWAY_MANUAL_ENTRY}
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {}
|
||||
assert result2["step_id"] == "gateway_entry"
|
||||
|
||||
@@ -221,7 +222,7 @@ async def test_form_manual_entry(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "Pentair: 01-01-01"
|
||||
assert result3["data"] == {
|
||||
CONF_IP_ADDRESS: "1.1.1.1",
|
||||
@@ -252,7 +253,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {CONF_IP_ADDRESS: "cannot_connect"}
|
||||
|
||||
|
||||
@@ -270,14 +271,14 @@ async def test_option_flow(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "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_SCAN_INTERVAL: 15},
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {CONF_SCAN_INTERVAL: 15}
|
||||
|
||||
|
||||
@@ -295,13 +296,13 @@ async def test_option_flow_defaults(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "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={}
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
CONF_SCAN_INTERVAL: DEFAULT_SCAN_INTERVAL,
|
||||
}
|
||||
@@ -321,13 +322,13 @@ async def test_option_flow_input_floor(hass: HomeAssistant) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "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_SCAN_INTERVAL: 1}
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
CONF_SCAN_INTERVAL: MIN_SCAN_INTERVAL,
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ from homeassistant import config_entries
|
||||
from homeassistant.components.sense.const import DOMAIN
|
||||
from homeassistant.const import CONF_CODE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -51,7 +52,7 @@ async def test_form(hass: HomeAssistant, mock_sense) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch(
|
||||
@@ -64,7 +65,7 @@ async def test_form(hass: HomeAssistant, mock_sense) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "test-email"
|
||||
assert result2["data"] == MOCK_CONFIG
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -85,7 +86,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
{"timeout": "6", "email": "test-email", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -102,7 +103,7 @@ async def test_form_mfa_required(hass: HomeAssistant, mock_sense) -> None:
|
||||
{"timeout": "6", "email": "test-email", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "validation"
|
||||
|
||||
mock_sense.return_value.validate_mfa.side_effect = None
|
||||
@@ -111,7 +112,7 @@ async def test_form_mfa_required(hass: HomeAssistant, mock_sense) -> None:
|
||||
{CONF_CODE: "012345"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "test-email"
|
||||
assert result3["data"] == MOCK_CONFIG
|
||||
|
||||
@@ -129,7 +130,7 @@ async def test_form_mfa_required_wrong(hass: HomeAssistant, mock_sense) -> None:
|
||||
{"timeout": "6", "email": "test-email", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "validation"
|
||||
|
||||
mock_sense.return_value.validate_mfa.side_effect = SenseAuthenticationException
|
||||
@@ -139,7 +140,7 @@ async def test_form_mfa_required_wrong(hass: HomeAssistant, mock_sense) -> None:
|
||||
{CONF_CODE: "000000"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] == {"base": "invalid_auth"}
|
||||
assert result3["step_id"] == "validation"
|
||||
|
||||
@@ -157,7 +158,7 @@ async def test_form_mfa_required_timeout(hass: HomeAssistant, mock_sense) -> Non
|
||||
{"timeout": "6", "email": "test-email", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "validation"
|
||||
|
||||
mock_sense.return_value.validate_mfa.side_effect = SenseAPITimeoutException
|
||||
@@ -166,7 +167,7 @@ async def test_form_mfa_required_timeout(hass: HomeAssistant, mock_sense) -> Non
|
||||
{CONF_CODE: "000000"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -183,7 +184,7 @@ async def test_form_mfa_required_exception(hass: HomeAssistant, mock_sense) -> N
|
||||
{"timeout": "6", "email": "test-email", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "validation"
|
||||
|
||||
mock_sense.return_value.validate_mfa.side_effect = Exception
|
||||
@@ -192,7 +193,7 @@ async def test_form_mfa_required_exception(hass: HomeAssistant, mock_sense) -> N
|
||||
{CONF_CODE: "000000"},
|
||||
)
|
||||
|
||||
assert result3["type"] == "form"
|
||||
assert result3["type"] is FlowResultType.FORM
|
||||
assert result3["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@@ -211,7 +212,7 @@ async def test_form_timeout(hass: HomeAssistant) -> None:
|
||||
{"timeout": "6", "email": "test-email", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -230,7 +231,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
{"timeout": "6", "email": "test-email", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -249,7 +250,7 @@ async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||
{"timeout": "6", "email": "test-email", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@@ -270,7 +271,7 @@ async def test_reauth_no_form(hass: HomeAssistant, mock_sense) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=MOCK_CONFIG
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@@ -290,7 +291,7 @@ async def test_reauth_password(hass: HomeAssistant, mock_sense) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_REAUTH}, data=entry.data
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
mock_sense.return_value.authenticate.side_effect = None
|
||||
with patch(
|
||||
@@ -303,5 +304,5 @@ async def test_reauth_password(hass: HomeAssistant, mock_sense) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
|
@@ -44,7 +44,7 @@ async def test_full_user_flow_implementation(hass: HomeAssistant) -> None:
|
||||
{"dsn": "http://public@sentry.local/1"},
|
||||
)
|
||||
|
||||
assert result2.get("type") == "create_entry"
|
||||
assert result2.get("type") is FlowResultType.CREATE_ENTRY
|
||||
assert result2.get("title") == "Sentry"
|
||||
assert result2.get("data") == {
|
||||
"dsn": "http://public@sentry.local/1",
|
||||
|
@@ -9,6 +9,7 @@ from sharkiq import AylaApi, SharkIqAuthError, SharkIqError
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.sharkiq.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .const import (
|
||||
@@ -41,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"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -56,7 +57,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
CONFIG,
|
||||
)
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == f"{TEST_USERNAME:s}"
|
||||
assert result2["data"] == {
|
||||
"username": TEST_USERNAME,
|
||||
@@ -89,7 +90,7 @@ async def test_form_error(hass: HomeAssistant, exc: Exception, base_error: str)
|
||||
CONFIG,
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"].get("base") == base_error
|
||||
|
||||
|
||||
@@ -105,7 +106,7 @@ async def test_reauth_success(hass: HomeAssistant) -> None:
|
||||
data=CONFIG,
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
|
@@ -205,7 +205,7 @@ async def test_abort_form(hass: HomeAssistant) -> None:
|
||||
get_abort = await hass.config_entries.flow.async_configure(
|
||||
start_another_flow["flow_id"], BASIC_CONFIG
|
||||
)
|
||||
assert get_abort["type"] == "abort"
|
||||
assert get_abort["type"] is FlowResultType.ABORT
|
||||
assert get_abort["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ async def test_validation_errors_user(
|
||||
flow_id = flow_at_user_step["flow_id"]
|
||||
config[field] = value
|
||||
result_err = await hass.config_entries.flow.async_configure(flow_id, config)
|
||||
assert result_err["type"] == "form"
|
||||
assert result_err["type"] is FlowResultType.FORM
|
||||
assert result_err["errors"] == {"base": error}
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ async def test_validation_errors_account(
|
||||
flow_id = flow_at_add_account_step["flow_id"]
|
||||
config[field] = value
|
||||
result_err = await hass.config_entries.flow.async_configure(flow_id, config)
|
||||
assert result_err["type"] == "form"
|
||||
assert result_err["type"] is FlowResultType.FORM
|
||||
assert result_err["errors"] == {"base": error}
|
||||
|
||||
|
||||
|
@@ -81,7 +81,7 @@ async def test_success(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> None
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch("asyncsleepiq.AsyncSleepIQ.login", return_value=True):
|
||||
|
@@ -13,6 +13,7 @@ from homeassistant import config_entries
|
||||
from homeassistant.components.smart_meter_texas.const import DOMAIN
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -25,7 +26,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"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -40,7 +41,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == TEST_LOGIN[CONF_USERNAME]
|
||||
assert result2["data"] == TEST_LOGIN
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -61,7 +62,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
TEST_LOGIN,
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -82,7 +83,7 @@ async def test_form_cannot_connect(hass: HomeAssistant, side_effect) -> None:
|
||||
result["flow_id"], TEST_LOGIN
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -101,7 +102,7 @@ async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||
TEST_LOGIN,
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@@ -123,5 +124,5 @@ async def test_form_duplicate_account(hass: HomeAssistant) -> None:
|
||||
data={"username": "user123", "password": "password123"},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
@@ -18,7 +18,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"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with patch(
|
||||
@@ -30,7 +30,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
{CONF_EMAIL: "test-email", CONF_PASSWORD: "test-password"},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "test-email"
|
||||
assert result["data"] == {
|
||||
CONF_EMAIL: "test-email",
|
||||
@@ -53,7 +53,7 @@ async def test_form_invalid_auth(hass: HomeAssistant, smarttub_api) -> None:
|
||||
{CONF_EMAIL: "test-email", CONF_PASSWORD: "test-password"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
|
@@ -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"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -41,7 +41,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "solarlog_test_1_2_3"
|
||||
assert result2["data"] == {"host": "http://1.1.1.1"}
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
@@ -10,6 +10,7 @@ from homeassistant import config_entries
|
||||
from homeassistant.components.solax.const import DOMAIN
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
|
||||
def __mock_real_time_api_success():
|
||||
@@ -31,7 +32,7 @@ async def test_form_success(hass: HomeAssistant) -> None:
|
||||
flow = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert flow["type"] == "form"
|
||||
assert flow["type"] is FlowResultType.FORM
|
||||
assert flow["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -51,7 +52,7 @@ async def test_form_success(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entry_result["type"] == "create_entry"
|
||||
assert entry_result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert entry_result["title"] == "ABCDEFGHIJ"
|
||||
assert entry_result["data"] == {
|
||||
CONF_IP_ADDRESS: "192.168.1.87",
|
||||
@@ -66,7 +67,7 @@ async def test_form_connect_error(hass: HomeAssistant) -> None:
|
||||
flow = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert flow["type"] == "form"
|
||||
assert flow["type"] is FlowResultType.FORM
|
||||
assert flow["errors"] == {}
|
||||
|
||||
with patch(
|
||||
@@ -78,7 +79,7 @@ async def test_form_connect_error(hass: HomeAssistant) -> None:
|
||||
{CONF_IP_ADDRESS: "192.168.1.87", CONF_PORT: 80, CONF_PASSWORD: "password"},
|
||||
)
|
||||
|
||||
assert entry_result["type"] == "form"
|
||||
assert entry_result["type"] is FlowResultType.FORM
|
||||
assert entry_result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -87,7 +88,7 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
|
||||
flow = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert flow["type"] == "form"
|
||||
assert flow["type"] is FlowResultType.FORM
|
||||
assert flow["errors"] == {}
|
||||
|
||||
with patch(
|
||||
@@ -99,5 +100,5 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
|
||||
{CONF_IP_ADDRESS: "192.168.1.87", CONF_PORT: 80, CONF_PASSWORD: "password"},
|
||||
)
|
||||
|
||||
assert entry_result["type"] == "form"
|
||||
assert entry_result["type"] is FlowResultType.FORM
|
||||
assert entry_result["errors"] == {"base": "unknown"}
|
||||
|
@@ -24,7 +24,7 @@ async def test_form_user(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -47,7 +47,7 @@ async def test_form_user(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "MyLink 1.1.1.1"
|
||||
assert result2["data"] == {
|
||||
CONF_HOST: "1.1.1.1",
|
||||
@@ -68,7 +68,7 @@ async def test_form_user_already_configured(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -91,7 +91,7 @@ async def test_form_user_already_configured(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@@ -272,7 +272,7 @@ async def test_form_user_already_configured_from_dhcp(hass: HomeAssistant) -> No
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ async def test_already_configured_with_ignored(hass: HomeAssistant) -> None:
|
||||
hostname="somfy_eeff",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
|
||||
async def test_dhcp_discovery(hass: HomeAssistant) -> None:
|
||||
@@ -308,7 +308,7 @@ async def test_dhcp_discovery(hass: HomeAssistant) -> None:
|
||||
hostname="somfy_eeff",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -331,7 +331,7 @@ async def test_dhcp_discovery(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "MyLink 1.1.1.1"
|
||||
assert result2["data"] == {
|
||||
CONF_HOST: "1.1.1.1",
|
||||
|
@@ -64,7 +64,7 @@ async def test_flow_ssdp(hass: HomeAssistant) -> None:
|
||||
context={"source": SOURCE_SSDP},
|
||||
data=SSDP_DATA,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
assert result["description_placeholders"] == {
|
||||
CONF_NAME: FRIENDLY_NAME,
|
||||
|
@@ -11,6 +11,7 @@ from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
|
||||
from homeassistant.components.sonos.const import DATA_SONOS_DISCOVERY_MANAGER, DOMAIN
|
||||
from homeassistant.const import CONF_HOSTS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
|
||||
@@ -24,9 +25,9 @@ async def test_user_form(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "no_devices_found"
|
||||
|
||||
# Initiate a discovery to allow config entry creation
|
||||
@@ -40,7 +41,7 @@ async def test_user_form(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
with (
|
||||
patch(
|
||||
@@ -58,7 +59,7 @@ async def test_user_form(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Sonos"
|
||||
assert result2["data"] == {}
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
@@ -78,7 +79,7 @@ async def test_user_form_already_created(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
@@ -93,7 +94,7 @@ async def test_zeroconf_form(
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf_payload,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@@ -112,7 +113,7 @@ async def test_zeroconf_form(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Sonos"
|
||||
assert result2["data"] == {}
|
||||
|
||||
@@ -157,7 +158,7 @@ async def test_ssdp_discovery(hass: HomeAssistant, soco) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "Sonos"
|
||||
assert result["data"] == {}
|
||||
|
||||
@@ -191,7 +192,7 @@ async def test_zeroconf_sonos_v1(hass: HomeAssistant) -> None:
|
||||
},
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@@ -210,7 +211,7 @@ async def test_zeroconf_sonos_v1(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Sonos"
|
||||
assert result2["data"] == {}
|
||||
|
||||
@@ -232,6 +233,6 @@ async def test_zeroconf_form_not_sonos(
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
data=zeroconf_payload,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_sonos_device"
|
||||
assert len(mock_manager.mock_calls) == 0
|
||||
|
@@ -5,6 +5,7 @@ import requests_mock
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.starline import config_flow
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
TEST_APP_ID = "666"
|
||||
TEST_APP_SECRET = "appsecret"
|
||||
@@ -45,7 +46,7 @@ async def test_flow_works(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth_app"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -55,7 +56,7 @@ async def test_flow_works(hass: HomeAssistant) -> None:
|
||||
config_flow.CONF_APP_SECRET: TEST_APP_SECRET,
|
||||
},
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth_user"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -65,7 +66,7 @@ async def test_flow_works(hass: HomeAssistant) -> None:
|
||||
config_flow.CONF_PASSWORD: TEST_APP_PASSWORD,
|
||||
},
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == f"Application {TEST_APP_ID}"
|
||||
|
||||
|
||||
@@ -83,7 +84,7 @@ async def test_step_auth_app_code_falls(hass: HomeAssistant) -> None:
|
||||
config_flow.CONF_APP_SECRET: TEST_APP_SECRET,
|
||||
},
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth_app"
|
||||
assert result["errors"] == {"base": "error_auth_app"}
|
||||
|
||||
@@ -106,7 +107,7 @@ async def test_step_auth_app_token_falls(hass: HomeAssistant) -> None:
|
||||
config_flow.CONF_APP_SECRET: TEST_APP_SECRET,
|
||||
},
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth_app"
|
||||
assert result["errors"] == {"base": "error_auth_app"}
|
||||
|
||||
@@ -123,6 +124,6 @@ async def test_step_auth_user_falls(hass: HomeAssistant) -> None:
|
||||
config_flow.CONF_PASSWORD: TEST_APP_PASSWORD,
|
||||
}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "auth_user"
|
||||
assert result["errors"] == {"base": "error_auth_user"}
|
||||
|
@@ -173,7 +173,7 @@ async def test_discovery(hass: HomeAssistant) -> None:
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "pick_device"
|
||||
assert not result2["errors"]
|
||||
|
||||
|
@@ -12,6 +12,7 @@ from homeassistant.components.subaru import config_flow
|
||||
from homeassistant.components.subaru.const import CONF_UPDATE_ENABLED, DOMAIN
|
||||
from homeassistant.const import CONF_DEVICE_ID, CONF_PIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from .conftest import (
|
||||
@@ -45,7 +46,7 @@ async def test_user_form_init(user_form) -> None:
|
||||
assert user_form["errors"] is None
|
||||
assert user_form["handler"] == DOMAIN
|
||||
assert user_form["step_id"] == "user"
|
||||
assert user_form["type"] == "form"
|
||||
assert user_form["type"] is FlowResultType.FORM
|
||||
|
||||
|
||||
async def test_user_form_repeat_identifier(hass: HomeAssistant, user_form) -> None:
|
||||
@@ -64,7 +65,7 @@ async def test_user_form_repeat_identifier(hass: HomeAssistant, user_form) -> No
|
||||
TEST_CREDS,
|
||||
)
|
||||
assert len(mock_connect.mock_calls) == 0
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -79,7 +80,7 @@ async def test_user_form_cannot_connect(hass: HomeAssistant, user_form) -> None:
|
||||
TEST_CREDS,
|
||||
)
|
||||
assert len(mock_connect.mock_calls) == 1
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@@ -94,7 +95,7 @@ async def test_user_form_invalid_auth(hass: HomeAssistant, user_form) -> None:
|
||||
TEST_CREDS,
|
||||
)
|
||||
assert len(mock_connect.mock_calls) == 1
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -207,7 +208,7 @@ async def test_two_factor_request_fail(
|
||||
user_input={config_flow.CONF_CONTACT_METHOD: "email@addr.com"},
|
||||
)
|
||||
assert len(mock_two_factor_request.mock_calls) == 1
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "two_factor_request_failed"
|
||||
|
||||
|
||||
@@ -302,7 +303,7 @@ async def test_pin_form_bad_pin_format(hass: HomeAssistant, pin_form) -> None:
|
||||
)
|
||||
assert len(mock_test_pin.mock_calls) == 0
|
||||
assert len(mock_update_saved_pin.mock_calls) == 1
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "bad_pin_format"}
|
||||
|
||||
|
||||
@@ -361,7 +362,7 @@ async def test_pin_form_incorrect_pin(hass: HomeAssistant, pin_form) -> None:
|
||||
)
|
||||
assert len(mock_test_pin.mock_calls) == 1
|
||||
assert len(mock_update_saved_pin.mock_calls) == 1
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "incorrect_pin"}
|
||||
|
||||
|
||||
@@ -370,7 +371,7 @@ async def test_option_flow_form(options_form) -> None:
|
||||
assert options_form["description_placeholders"] is None
|
||||
assert options_form["errors"] is None
|
||||
assert options_form["step_id"] == "init"
|
||||
assert options_form["type"] == "form"
|
||||
assert options_form["type"] is FlowResultType.FORM
|
||||
|
||||
|
||||
async def test_option_flow(hass: HomeAssistant, options_form) -> None:
|
||||
@@ -381,7 +382,7 @@ async def test_option_flow(hass: HomeAssistant, options_form) -> None:
|
||||
CONF_UPDATE_ENABLED: False,
|
||||
},
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
CONF_UPDATE_ENABLED: False,
|
||||
}
|
||||
|
@@ -142,7 +142,7 @@ async def test_no_plants_on_account(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], SUNWEG_USER_INPUT
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "no_plants"
|
||||
|
||||
|
||||
@@ -219,5 +219,5 @@ async def test_existing_plant_configured(hass: HomeAssistant, plant_fixture) ->
|
||||
result["flow_id"], SUNWEG_USER_INPUT
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
@@ -165,7 +165,7 @@ async def test_reauthentication(hass: HomeAssistant) -> None:
|
||||
data=old_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@@ -179,7 +179,7 @@ async def test_reauthentication(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ async def test_reauthentication_failure(hass: HomeAssistant) -> None:
|
||||
data=old_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@@ -217,7 +217,7 @@ async def test_reauthentication_failure(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["step_id"] == "reauth_confirm"
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result2["errors"]["base"] == "invalid_auth"
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ async def test_reauthentication_cannot_connect(hass: HomeAssistant) -> None:
|
||||
data=old_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@@ -255,7 +255,7 @@ async def test_reauthentication_cannot_connect(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["step_id"] == "reauth_confirm"
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result2["errors"]["base"] == "cannot_connect"
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ async def test_reauthentication_unknown_failure(hass: HomeAssistant) -> None:
|
||||
data=old_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@@ -293,5 +293,5 @@ async def test_reauthentication_unknown_failure(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["step_id"] == "reauth_confirm"
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result2["errors"]["base"] == "unknown"
|
||||
|
@@ -34,7 +34,7 @@ async def test_flow_user_init_data_success(hass: HomeAssistant) -> None:
|
||||
config_flow.DOMAIN, context={"source": "user"}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["handler"] == "swiss_public_transport"
|
||||
assert result["data_schema"] == config_flow.DATA_SCHEMA
|
||||
@@ -52,7 +52,7 @@ async def test_flow_user_init_data_success(hass: HomeAssistant) -> None:
|
||||
user_input=MOCK_DATA_STEP,
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["result"].title == "test_start test_destination"
|
||||
|
||||
assert result["data"] == MOCK_DATA_STEP
|
||||
@@ -83,7 +83,7 @@ async def test_flow_user_init_data_error_and_recover(
|
||||
user_input=MOCK_DATA_STEP,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"]["base"] == text_error
|
||||
|
||||
# Recover
|
||||
@@ -94,7 +94,7 @@ async def test_flow_user_init_data_error_and_recover(
|
||||
user_input=MOCK_DATA_STEP,
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["result"].title == "test_start test_destination"
|
||||
|
||||
assert result["data"] == MOCK_DATA_STEP
|
||||
|
@@ -29,7 +29,7 @@ async def test_form(hass: HomeAssistant, test_cucode_in_coordinator_data) -> Non
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
|
@@ -176,7 +176,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
{"username": "test-username", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
{"username": "test-username", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ async def test_no_homes(hass: HomeAssistant) -> None:
|
||||
{"username": "test-username", "password": "test-password"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "no_homes"}
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ async def test_form_homekit(hass: HomeAssistant) -> None:
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
flow = next(
|
||||
flow
|
||||
@@ -267,7 +267,7 @@ async def test_form_homekit(hass: HomeAssistant) -> None:
|
||||
type="mock_type",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
|
||||
|
||||
async def test_import_step(hass: HomeAssistant) -> None:
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
from homeassistant.helpers.service_info.mqtt import MqttServiceInfo
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
@@ -18,7 +19,7 @@ async def test_mqtt_abort_if_existing_entry(
|
||||
"tasmota", context={"source": config_entries.SOURCE_MQTT}
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
@@ -46,7 +47,7 @@ async def test_mqtt_abort_invalid_topic(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"tasmota", context={"source": config_entries.SOURCE_MQTT}, data=discovery_info
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "invalid_discovery_info"
|
||||
|
||||
discovery_info = MqttServiceInfo(
|
||||
@@ -60,7 +61,7 @@ async def test_mqtt_abort_invalid_topic(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"tasmota", context={"source": config_entries.SOURCE_MQTT}, data=discovery_info
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "invalid_discovery_info"
|
||||
|
||||
discovery_info = MqttServiceInfo(
|
||||
@@ -83,7 +84,7 @@ async def test_mqtt_abort_invalid_topic(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"tasmota", context={"source": config_entries.SOURCE_MQTT}, data=discovery_info
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
|
||||
async def test_mqtt_setup(hass: HomeAssistant, mqtt_mock: MqttMockHAClient) -> None:
|
||||
@@ -108,11 +109,11 @@ async def test_mqtt_setup(hass: HomeAssistant, mqtt_mock: MqttMockHAClient) -> N
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"tasmota", context={"source": config_entries.SOURCE_MQTT}, data=discovery_info
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["result"].data == {"discovery_prefix": "tasmota/discovery"}
|
||||
|
||||
|
||||
@@ -121,11 +122,11 @@ async def test_user_setup(hass: HomeAssistant, mqtt_mock: MqttMockHAClient) -> N
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"tasmota", context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["result"].data == {
|
||||
"discovery_prefix": "tasmota/discovery",
|
||||
}
|
||||
@@ -139,13 +140,13 @@ async def test_user_setup_advanced(
|
||||
"tasmota",
|
||||
context={"source": config_entries.SOURCE_USER, "show_advanced_options": True},
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"discovery_prefix": "test_tasmota/discovery"}
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["result"].data == {
|
||||
"discovery_prefix": "test_tasmota/discovery",
|
||||
}
|
||||
@@ -159,13 +160,13 @@ async def test_user_setup_advanced_strip_wildcard(
|
||||
"tasmota",
|
||||
context={"source": config_entries.SOURCE_USER, "show_advanced_options": True},
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"discovery_prefix": "test_tasmota/discovery/#"}
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["result"].data == {
|
||||
"discovery_prefix": "test_tasmota/discovery",
|
||||
}
|
||||
@@ -179,13 +180,13 @@ async def test_user_setup_invalid_topic_prefix(
|
||||
"tasmota",
|
||||
context={"source": config_entries.SOURCE_USER, "show_advanced_options": True},
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"discovery_prefix": "tasmota/config/##"}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"]["base"] == "invalid_discovery_topic"
|
||||
|
||||
|
||||
@@ -198,5 +199,5 @@ async def test_user_single_instance(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"tasmota", context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
@@ -98,7 +98,7 @@ async def test_form_already_configured(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
|
||||
# Test config entry got updated with latest IP
|
||||
@@ -120,7 +120,7 @@ async def test_dhcp_can_finish(
|
||||
),
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -154,7 +154,7 @@ async def test_dhcp_already_exists(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -178,5 +178,5 @@ async def test_dhcp_error_from_wall_connector(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
@@ -55,13 +55,13 @@ async def test_discovery(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "pick_device"
|
||||
assert not result2["errors"]
|
||||
|
||||
@@ -69,13 +69,13 @@ async def test_discovery(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "pick_device"
|
||||
assert not result2["errors"]
|
||||
|
||||
@@ -92,7 +92,7 @@ async def test_discovery(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == DEFAULT_ENTRY_TITLE
|
||||
assert result3["data"] == CREATE_ENTRY_DATA_LEGACY
|
||||
mock_setup.assert_called_once()
|
||||
@@ -132,7 +132,7 @@ async def test_discovery_auth(
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "discovery_auth_confirm"
|
||||
assert not result["errors"]
|
||||
|
||||
@@ -184,7 +184,7 @@ async def test_discovery_auth_errors(
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "discovery_auth_confirm"
|
||||
assert not result["errors"]
|
||||
|
||||
@@ -235,7 +235,7 @@ async def test_discovery_new_credentials(
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "discovery_auth_confirm"
|
||||
assert not result["errors"]
|
||||
|
||||
@@ -287,7 +287,7 @@ async def test_discovery_new_credentials_invalid(
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "discovery_auth_confirm"
|
||||
assert not result["errors"]
|
||||
|
||||
|
@@ -7,6 +7,7 @@ import aiotractive
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.tractive.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -22,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"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@@ -38,7 +39,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "test-email@example.com"
|
||||
assert result2["data"] == USER_INPUT
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
@@ -59,7 +60,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
USER_INPUT,
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -78,7 +79,7 @@ async def test_form_unknown_error(hass: HomeAssistant) -> None:
|
||||
USER_INPUT,
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@@ -96,7 +97,7 @@ async def test_flow_entry_already_exists(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -119,7 +120,7 @@ async def test_reauthentication(hass: HomeAssistant) -> None:
|
||||
data=old_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@@ -136,7 +137,7 @@ async def test_reauthentication(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
@@ -160,7 +161,7 @@ async def test_reauthentication_failure(hass: HomeAssistant) -> None:
|
||||
data=old_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@@ -175,7 +176,7 @@ async def test_reauthentication_failure(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["step_id"] == "reauth_confirm"
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result2["errors"]["base"] == "invalid_auth"
|
||||
|
||||
|
||||
@@ -198,7 +199,7 @@ async def test_reauthentication_unknown_failure(hass: HomeAssistant) -> None:
|
||||
data=old_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@@ -213,7 +214,7 @@ async def test_reauthentication_unknown_failure(hass: HomeAssistant) -> None:
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["step_id"] == "reauth_confirm"
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result2["errors"]["base"] == "unknown"
|
||||
|
||||
|
||||
@@ -236,7 +237,7 @@ async def test_reauthentication_failure_no_existing_entry(hass: HomeAssistant) -
|
||||
data=old_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
@@ -247,5 +248,5 @@ async def test_reauthentication_failure_no_existing_entry(hass: HomeAssistant) -
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_failed_existing"
|
||||
|
@@ -28,7 +28,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"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -49,7 +49,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Vallby"
|
||||
assert result2["data"] == {
|
||||
"api_key": "1234567890",
|
||||
|
@@ -7,6 +7,7 @@ from homeassistant.components import dhcp
|
||||
from homeassistant.components.twinkly.const import DOMAIN as TWINKLY_DOMAIN
|
||||
from homeassistant.const import CONF_HOST, CONF_ID, CONF_MODEL, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from . import TEST_MODEL, TEST_NAME, ClientMock
|
||||
|
||||
@@ -23,7 +24,7 @@ async def test_invalid_host(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
TWINKLY_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -31,7 +32,7 @@ async def test_invalid_host(hass: HomeAssistant) -> None:
|
||||
{CONF_HOST: "dummy"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {CONF_HOST: "cannot_connect"}
|
||||
|
||||
@@ -49,7 +50,7 @@ async def test_success_flow(hass: HomeAssistant) -> None:
|
||||
TWINKLY_DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -58,7 +59,7 @@ async def test_success_flow(hass: HomeAssistant) -> None:
|
||||
{CONF_HOST: "dummy"},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_NAME
|
||||
assert result["data"] == {
|
||||
CONF_HOST: "dummy",
|
||||
@@ -85,7 +86,7 @@ async def test_dhcp_can_confirm(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "discovery_confirm"
|
||||
|
||||
|
||||
@@ -109,12 +110,12 @@ async def test_dhcp_success(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "discovery_confirm"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_NAME
|
||||
assert result["data"] == {
|
||||
CONF_HOST: "1.2.3.4",
|
||||
@@ -154,5 +155,5 @@ async def test_dhcp_already_exists(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
@@ -221,7 +221,7 @@ async def test_max_regions(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "max_regions"
|
||||
|
||||
|
||||
|
@@ -581,7 +581,7 @@ async def test_option_flow_integration_not_setup(
|
||||
hass.data[UNIFI_DOMAIN].pop(config_entry.entry_id)
|
||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "integration_not_setup"
|
||||
|
||||
|
||||
@@ -602,7 +602,7 @@ async def test_form_ssdp(hass: HomeAssistant) -> None:
|
||||
},
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -647,7 +647,7 @@ async def test_form_ssdp_aborts_if_host_already_exists(hass: HomeAssistant) -> N
|
||||
},
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -674,7 +674,7 @@ async def test_form_ssdp_aborts_if_serial_already_exists(hass: HomeAssistant) ->
|
||||
},
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -701,7 +701,7 @@ async def test_form_ssdp_gets_form_with_ignored_entry(hass: HomeAssistant) -> No
|
||||
},
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
context = next(
|
||||
|
@@ -5,6 +5,7 @@ from unittest.mock import MagicMock, PropertyMock, patch
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.upb.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
|
||||
def mocked_upb(sync_complete=True, config_ok=True):
|
||||
@@ -63,9 +64,9 @@ async def test_full_upb_flow_with_serial_port(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert flow["type"] == "form"
|
||||
assert flow["type"] is FlowResultType.FORM
|
||||
assert flow["errors"] == {}
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "UPB"
|
||||
assert result["data"] == {
|
||||
"host": "serial:///dev/ttyS0:115200",
|
||||
@@ -77,7 +78,7 @@ async def test_full_upb_flow_with_serial_port(hass: HomeAssistant) -> None:
|
||||
async def test_form_user_with_tcp_upb(hass: HomeAssistant) -> None:
|
||||
"""Test we can setup a serial upb."""
|
||||
result = await valid_tcp_flow(hass)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {"host": "tcp://1.2.3.4", "file_path": "upb.upe"}
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -92,14 +93,14 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
):
|
||||
result = await valid_tcp_flow(hass, sync_complete=False)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_form_missing_upb_file(hass: HomeAssistant) -> None:
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await valid_tcp_flow(hass, config_ok=False)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "invalid_upb_file"}
|
||||
|
||||
|
||||
@@ -107,7 +108,7 @@ async def test_form_user_with_already_configured(hass: HomeAssistant) -> None:
|
||||
"""Test we can setup a TCP upb."""
|
||||
_ = await valid_tcp_flow(hass)
|
||||
result2 = await valid_tcp_flow(hass)
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -128,7 +129,7 @@ async def test_form_import(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "UPB"
|
||||
|
||||
assert result["data"] == {"host": "tcp://42.4.2.42", "file_path": "upb.upe"}
|
||||
@@ -145,7 +146,7 @@ async def test_form_junk_input(hass: HomeAssistant) -> None:
|
||||
data={"foo": "goo", "goo": "foo"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "unknown"}
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
@@ -118,7 +118,7 @@ async def test_async_step_finish_error(hass: HomeAssistant) -> None:
|
||||
data={CONF_CONTROLLER: "http://127.0.0.1:123/"},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
assert result["description_placeholders"] == {
|
||||
"base_url": "http://127.0.0.1:123"
|
||||
|
@@ -16,7 +16,7 @@ async def test_form_user(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
voip.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert not result["errors"]
|
||||
|
||||
with patch(
|
||||
@@ -41,7 +41,7 @@ async def test_single_instance(
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
voip.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
|
@@ -8,6 +8,7 @@ from homeassistant.components import zeroconf
|
||||
from homeassistant.components.volumio.config_flow import CannotConnectError
|
||||
from homeassistant.components.volumio.const import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -43,7 +44,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"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -62,7 +63,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "TestVolumio"
|
||||
assert result2["data"] == {**TEST_SYSTEM_INFO, **TEST_CONNECTION}
|
||||
|
||||
@@ -103,7 +104,7 @@ async def test_form_updates_unique_id(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
|
||||
assert entry.data == {**TEST_SYSTEM_INFO, **TEST_CONNECTION}
|
||||
@@ -114,7 +115,7 @@ async def test_empty_system_info(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -133,7 +134,7 @@ async def test_empty_system_info(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == TEST_CONNECTION["host"]
|
||||
assert result2["data"] == {
|
||||
"host": TEST_CONNECTION["host"],
|
||||
@@ -160,7 +161,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
TEST_CONNECTION,
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -179,7 +180,7 @@ async def test_form_exception(hass: HomeAssistant) -> None:
|
||||
TEST_CONNECTION,
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@@ -206,7 +207,7 @@ async def test_discovery(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == TEST_DISCOVERY_RESULT["name"]
|
||||
assert result2["data"] == TEST_DISCOVERY_RESULT
|
||||
|
||||
@@ -232,7 +233,7 @@ async def test_discovery_cannot_connect(hass: HomeAssistant) -> None:
|
||||
user_input={},
|
||||
)
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@@ -241,13 +242,13 @@ async def test_discovery_duplicate_data(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=TEST_DISCOVERY
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "discovery_confirm"
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_ZEROCONF}, data=TEST_DISCOVERY
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_in_progress"
|
||||
|
||||
|
||||
@@ -278,7 +279,7 @@ async def test_discovery_updates_unique_id(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
assert entry.data == TEST_DISCOVERY_RESULT
|
||||
|
@@ -78,7 +78,7 @@ async def test_form_cannot_authenticate(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ async def test_form_reauth(hass: HomeAssistant, entry: MockConfigEntry) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "reauth_successful"
|
||||
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
@@ -216,7 +216,7 @@ async def test_form_reauth_invalid(hass: HomeAssistant, entry: MockConfigEntry)
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "reauth_invalid"}
|
||||
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
|
@@ -25,7 +25,7 @@ async def test_form(hass: HomeAssistant, region, brand) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == config_entries.SOURCE_USER
|
||||
|
||||
with (
|
||||
@@ -56,7 +56,7 @@ async def test_form(hass: HomeAssistant, region, brand) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "test-username"
|
||||
assert result2["data"] == {
|
||||
"username": "test-username",
|
||||
@@ -84,7 +84,7 @@ async def test_form_invalid_auth(hass: HomeAssistant, region, brand) -> None:
|
||||
result["flow_id"],
|
||||
CONFIG_INPUT | {"region": region[0], "brand": brand[0]},
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ async def test_form_cannot_connect(hass: HomeAssistant, region, brand) -> None:
|
||||
"brand": brand[0],
|
||||
},
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ async def test_form_auth_timeout(hass: HomeAssistant, region, brand) -> None:
|
||||
"brand": brand[0],
|
||||
},
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ async def test_form_generic_auth_exception(hass: HomeAssistant, region, brand) -
|
||||
"brand": brand[0],
|
||||
},
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ async def test_form_already_configured(hass: HomeAssistant, region, brand) -> No
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == config_entries.SOURCE_USER
|
||||
|
||||
with (
|
||||
@@ -192,7 +192,7 @@ async def test_form_already_configured(hass: HomeAssistant, region, brand) -> No
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
|
@@ -151,7 +151,7 @@ async def test_config_reauth_profile(
|
||||
},
|
||||
data=polling_config_entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
@@ -213,7 +213,7 @@ async def test_config_reauth_wrong_account(
|
||||
},
|
||||
data=polling_config_entry.data,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
@@ -49,7 +49,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"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
# Patch functions
|
||||
with (
|
||||
@@ -68,7 +68,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "WiZ Dimmable White ABCABC"
|
||||
assert result2["data"] == {
|
||||
CONF_HOST: "1.1.1.1",
|
||||
@@ -82,7 +82,7 @@ async def test_user_flow_enters_dns_name(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
@@ -110,7 +110,7 @@ async def test_user_flow_enters_dns_name(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "WiZ Dimmable White ABCABC"
|
||||
assert result3["data"] == {
|
||||
CONF_HOST: "1.1.1.1",
|
||||
@@ -145,7 +145,7 @@ async def test_user_form_exceptions(
|
||||
TEST_CONNECTION,
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": error_base}
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ async def test_form_updates_unique_id(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
assert entry.data[CONF_HOST] == FAKE_IP
|
||||
|
||||
@@ -291,7 +291,7 @@ async def test_discovered_by_dhcp_or_integration_discovery(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == name
|
||||
assert result2["data"] == {
|
||||
CONF_HOST: "1.1.1.1",
|
||||
@@ -364,7 +364,7 @@ async def test_setup_via_discovery(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
@@ -372,7 +372,7 @@ async def test_setup_via_discovery(hass: HomeAssistant) -> None:
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "pick_device"
|
||||
assert not result2["errors"]
|
||||
|
||||
@@ -380,7 +380,7 @@ async def test_setup_via_discovery(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
@@ -388,7 +388,7 @@ async def test_setup_via_discovery(hass: HomeAssistant) -> None:
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "pick_device"
|
||||
assert not result2["errors"]
|
||||
|
||||
@@ -407,7 +407,7 @@ async def test_setup_via_discovery(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == "WiZ Dimmable White ABCABC"
|
||||
assert result3["data"] == {
|
||||
CONF_HOST: "1.1.1.1",
|
||||
@@ -419,7 +419,7 @@ async def test_setup_via_discovery(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
@@ -427,7 +427,7 @@ async def test_setup_via_discovery(hass: HomeAssistant) -> None:
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
@@ -437,7 +437,7 @@ async def test_setup_via_discovery_cannot_connect(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
@@ -445,7 +445,7 @@ async def test_setup_via_discovery_cannot_connect(hass: HomeAssistant) -> None:
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "pick_device"
|
||||
assert not result2["errors"]
|
||||
|
||||
@@ -462,7 +462,7 @@ async def test_setup_via_discovery_cannot_connect(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == "abort"
|
||||
assert result3["type"] is FlowResultType.ABORT
|
||||
assert result3["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@@ -472,7 +472,7 @@ async def test_setup_via_discovery_exception_finds_nothing(hass: HomeAssistant)
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
@@ -528,7 +528,7 @@ async def test_discovery_with_firmware_update(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "WiZ RGBWW Tunable ABCABC"
|
||||
assert result2["data"] == {
|
||||
CONF_HOST: "1.1.1.1",
|
||||
@@ -564,7 +564,7 @@ async def test_discovered_during_onboarding(hass: HomeAssistant, source, data) -
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == "WiZ Dimmable White ABCABC"
|
||||
assert result["data"] == {
|
||||
CONF_HOST: "1.1.1.1",
|
||||
|
@@ -92,7 +92,7 @@ async def test_form_invalid_auth(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=INPUT_CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "invalid_auth"}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=INPUT_CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ async def test_form_unknown_exception(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=INPUT_CONFIG
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
|
@@ -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"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {}
|
||||
|
||||
with (
|
||||
@@ -52,7 +52,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||
ws66i_instance.open.assert_called_once()
|
||||
ws66i_instance.close.assert_called_once()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "WS66i Amp"
|
||||
assert result2["data"] == {CONF_IP_ADDRESS: CONFIG[CONF_IP_ADDRESS]}
|
||||
|
||||
@@ -72,7 +72,7 @@ async def test_form_cannot_connect(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], CONFIG
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ async def test_form_wrong_ip(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], CONFIG
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ async def test_generic_exception(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], CONFIG
|
||||
)
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
|
@@ -11,6 +11,7 @@ from homeassistant.components import zeroconf
|
||||
from homeassistant.components.xiaomi_aqara import config_flow, const
|
||||
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME, CONF_PORT, CONF_PROTOCOL
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
ZEROCONF_NAME = "name"
|
||||
ZEROCONF_PROP = "properties"
|
||||
@@ -89,7 +90,7 @@ async def test_config_flow_user_success(hass: HomeAssistant) -> None:
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -98,7 +99,7 @@ async def test_config_flow_user_success(hass: HomeAssistant) -> None:
|
||||
{const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "settings"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -107,7 +108,7 @@ async def test_config_flow_user_success(hass: HomeAssistant) -> None:
|
||||
{const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_NAME
|
||||
assert result["data"] == {
|
||||
CONF_HOST: TEST_HOST,
|
||||
@@ -126,7 +127,7 @@ async def test_config_flow_user_multiple_success(hass: HomeAssistant) -> None:
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -141,7 +142,7 @@ async def test_config_flow_user_multiple_success(hass: HomeAssistant) -> None:
|
||||
{const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "select"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -150,7 +151,7 @@ async def test_config_flow_user_multiple_success(hass: HomeAssistant) -> None:
|
||||
{"select_ip": TEST_HOST_2},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "settings"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -159,7 +160,7 @@ async def test_config_flow_user_multiple_success(hass: HomeAssistant) -> None:
|
||||
{const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_NAME
|
||||
assert result["data"] == {
|
||||
CONF_HOST: TEST_HOST_2,
|
||||
@@ -178,7 +179,7 @@ async def test_config_flow_user_no_key_success(hass: HomeAssistant) -> None:
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -187,7 +188,7 @@ async def test_config_flow_user_no_key_success(hass: HomeAssistant) -> None:
|
||||
{const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "settings"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -196,7 +197,7 @@ async def test_config_flow_user_no_key_success(hass: HomeAssistant) -> None:
|
||||
{CONF_NAME: TEST_NAME},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_NAME
|
||||
assert result["data"] == {
|
||||
CONF_HOST: TEST_HOST,
|
||||
@@ -215,7 +216,7 @@ async def test_config_flow_user_host_mac_success(hass: HomeAssistant) -> None:
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -234,7 +235,7 @@ async def test_config_flow_user_host_mac_success(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "settings"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -243,7 +244,7 @@ async def test_config_flow_user_host_mac_success(hass: HomeAssistant) -> None:
|
||||
{CONF_NAME: TEST_NAME},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_NAME
|
||||
assert result["data"] == {
|
||||
CONF_HOST: TEST_HOST,
|
||||
@@ -262,7 +263,7 @@ async def test_config_flow_user_discovery_error(hass: HomeAssistant) -> None:
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -277,7 +278,7 @@ async def test_config_flow_user_discovery_error(hass: HomeAssistant) -> None:
|
||||
{const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"base": "discovery_error"}
|
||||
|
||||
@@ -288,7 +289,7 @@ async def test_config_flow_user_invalid_interface(hass: HomeAssistant) -> None:
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -303,7 +304,7 @@ async def test_config_flow_user_invalid_interface(hass: HomeAssistant) -> None:
|
||||
{const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {const.CONF_INTERFACE: "invalid_interface"}
|
||||
|
||||
@@ -314,7 +315,7 @@ async def test_config_flow_user_invalid_host(hass: HomeAssistant) -> None:
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -333,7 +334,7 @@ async def test_config_flow_user_invalid_host(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"host": "invalid_host"}
|
||||
|
||||
@@ -344,7 +345,7 @@ async def test_config_flow_user_invalid_mac(hass: HomeAssistant) -> None:
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -363,7 +364,7 @@ async def test_config_flow_user_invalid_mac(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {"mac": "invalid_mac"}
|
||||
|
||||
@@ -374,7 +375,7 @@ async def test_config_flow_user_invalid_key(hass: HomeAssistant) -> None:
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -389,7 +390,7 @@ async def test_config_flow_user_invalid_key(hass: HomeAssistant) -> None:
|
||||
{const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "settings"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -398,7 +399,7 @@ async def test_config_flow_user_invalid_key(hass: HomeAssistant) -> None:
|
||||
{const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "settings"
|
||||
assert result["errors"] == {const.CONF_KEY: "invalid_key"}
|
||||
|
||||
@@ -419,7 +420,7 @@ async def test_zeroconf_success(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -428,7 +429,7 @@ async def test_zeroconf_success(hass: HomeAssistant) -> None:
|
||||
{const.CONF_INTERFACE: config_flow.DEFAULT_INTERFACE},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "settings"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -437,7 +438,7 @@ async def test_zeroconf_success(hass: HomeAssistant) -> None:
|
||||
{const.CONF_KEY: TEST_KEY, CONF_NAME: TEST_NAME},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_NAME
|
||||
assert result["data"] == {
|
||||
CONF_HOST: TEST_HOST,
|
||||
@@ -466,7 +467,7 @@ async def test_zeroconf_missing_data(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_xiaomi_aqara"
|
||||
|
||||
|
||||
@@ -486,5 +487,5 @@ async def test_zeroconf_unknown_device(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_xiaomi_aqara"
|
||||
|
@@ -119,7 +119,7 @@ async def test_config_flow_step_gateway_connect_error(hass: HomeAssistant) -> No
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -128,7 +128,7 @@ async def test_config_flow_step_gateway_connect_error(hass: HomeAssistant) -> No
|
||||
{const.CONF_MANUAL: True},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -141,7 +141,7 @@ async def test_config_flow_step_gateway_connect_error(hass: HomeAssistant) -> No
|
||||
{CONF_HOST: TEST_HOST, CONF_TOKEN: TEST_TOKEN},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "connect"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@@ -152,7 +152,7 @@ async def test_config_flow_gateway_success(hass: HomeAssistant) -> None:
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -161,7 +161,7 @@ async def test_config_flow_gateway_success(hass: HomeAssistant) -> None:
|
||||
{const.CONF_MANUAL: True},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -170,7 +170,7 @@ async def test_config_flow_gateway_success(hass: HomeAssistant) -> None:
|
||||
{CONF_HOST: TEST_HOST, CONF_TOKEN: TEST_TOKEN},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_MODEL
|
||||
assert result["data"] == {
|
||||
const.CONF_FLOW_TYPE: const.CONF_GATEWAY,
|
||||
@@ -190,7 +190,7 @@ async def test_config_flow_gateway_cloud_success(hass: HomeAssistant) -> None:
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -203,7 +203,7 @@ async def test_config_flow_gateway_cloud_success(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_NAME
|
||||
assert result["data"] == {
|
||||
const.CONF_FLOW_TYPE: const.CONF_GATEWAY,
|
||||
@@ -223,7 +223,7 @@ async def test_config_flow_gateway_cloud_multiple_success(hass: HomeAssistant) -
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -240,7 +240,7 @@ async def test_config_flow_gateway_cloud_multiple_success(hass: HomeAssistant) -
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "select"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -249,7 +249,7 @@ async def test_config_flow_gateway_cloud_multiple_success(hass: HomeAssistant) -
|
||||
{"select_device": f"{TEST_NAME2} - {TEST_MODEL}"},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_NAME2
|
||||
assert result["data"] == {
|
||||
const.CONF_FLOW_TYPE: const.CONF_GATEWAY,
|
||||
@@ -269,7 +269,7 @@ async def test_config_flow_gateway_cloud_incomplete(hass: HomeAssistant) -> None
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -281,7 +281,7 @@ async def test_config_flow_gateway_cloud_incomplete(hass: HomeAssistant) -> None
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {"base": "cloud_credentials_incomplete"}
|
||||
|
||||
@@ -292,7 +292,7 @@ async def test_config_flow_gateway_cloud_login_error(hass: HomeAssistant) -> Non
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -309,7 +309,7 @@ async def test_config_flow_gateway_cloud_login_error(hass: HomeAssistant) -> Non
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {"base": "cloud_login_error"}
|
||||
|
||||
@@ -326,7 +326,7 @@ async def test_config_flow_gateway_cloud_login_error(hass: HomeAssistant) -> Non
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {"base": "cloud_login_error"}
|
||||
|
||||
@@ -343,7 +343,7 @@ async def test_config_flow_gateway_cloud_login_error(hass: HomeAssistant) -> Non
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
@@ -353,7 +353,7 @@ async def test_config_flow_gateway_cloud_no_devices(hass: HomeAssistant) -> None
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -370,7 +370,7 @@ async def test_config_flow_gateway_cloud_no_devices(hass: HomeAssistant) -> None
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {"base": "cloud_no_devices"}
|
||||
|
||||
@@ -387,7 +387,7 @@ async def test_config_flow_gateway_cloud_no_devices(hass: HomeAssistant) -> None
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
@@ -397,7 +397,7 @@ async def test_config_flow_gateway_cloud_missing_token(hass: HomeAssistant) -> N
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -425,7 +425,7 @@ async def test_config_flow_gateway_cloud_missing_token(hass: HomeAssistant) -> N
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "incomplete_info"
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ async def test_zeroconf_gateway_success(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -458,7 +458,7 @@ async def test_zeroconf_gateway_success(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TEST_NAME
|
||||
assert result["data"] == {
|
||||
const.CONF_FLOW_TYPE: const.CONF_GATEWAY,
|
||||
@@ -488,7 +488,7 @@ async def test_zeroconf_unknown_device(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_xiaomi_miio"
|
||||
|
||||
|
||||
@@ -508,7 +508,7 @@ async def test_zeroconf_no_data(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_xiaomi_miio"
|
||||
|
||||
|
||||
@@ -528,7 +528,7 @@ async def test_zeroconf_missing_data(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_xiaomi_miio"
|
||||
|
||||
|
||||
@@ -538,7 +538,7 @@ async def test_config_flow_step_device_connect_error(hass: HomeAssistant) -> Non
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -547,7 +547,7 @@ async def test_config_flow_step_device_connect_error(hass: HomeAssistant) -> Non
|
||||
{const.CONF_MANUAL: True},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -560,7 +560,7 @@ async def test_config_flow_step_device_connect_error(hass: HomeAssistant) -> Non
|
||||
{CONF_HOST: TEST_HOST, CONF_TOKEN: TEST_TOKEN},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "connect"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@@ -571,7 +571,7 @@ async def test_config_flow_step_unknown_device(hass: HomeAssistant) -> None:
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -580,7 +580,7 @@ async def test_config_flow_step_unknown_device(hass: HomeAssistant) -> None:
|
||||
{const.CONF_MANUAL: True},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -595,7 +595,7 @@ async def test_config_flow_step_unknown_device(hass: HomeAssistant) -> None:
|
||||
{CONF_HOST: TEST_HOST, CONF_TOKEN: TEST_TOKEN},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "connect"
|
||||
assert result["errors"] == {"base": "unknown_device"}
|
||||
|
||||
@@ -606,7 +606,7 @@ async def test_config_flow_step_device_manual_model_error(hass: HomeAssistant) -
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -615,7 +615,7 @@ async def test_config_flow_step_device_manual_model_error(hass: HomeAssistant) -
|
||||
{const.CONF_MANUAL: True},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -628,7 +628,7 @@ async def test_config_flow_step_device_manual_model_error(hass: HomeAssistant) -
|
||||
{CONF_HOST: TEST_HOST, CONF_TOKEN: TEST_TOKEN},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "connect"
|
||||
assert result["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@@ -641,7 +641,7 @@ async def test_config_flow_step_device_manual_model_error(hass: HomeAssistant) -
|
||||
{CONF_MODEL: TEST_MODEL},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "unknown"
|
||||
|
||||
|
||||
@@ -651,7 +651,7 @@ async def test_config_flow_step_device_manual_model_succes(hass: HomeAssistant)
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -660,7 +660,7 @@ async def test_config_flow_step_device_manual_model_succes(hass: HomeAssistant)
|
||||
{const.CONF_MANUAL: True},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -675,7 +675,7 @@ async def test_config_flow_step_device_manual_model_succes(hass: HomeAssistant)
|
||||
{CONF_HOST: TEST_HOST, CONF_TOKEN: TEST_TOKEN},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "connect"
|
||||
assert result["errors"] == {"base": "wrong_token"}
|
||||
|
||||
@@ -690,7 +690,7 @@ async def test_config_flow_step_device_manual_model_succes(hass: HomeAssistant)
|
||||
{CONF_MODEL: overwrite_model},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == overwrite_model
|
||||
assert result["data"] == {
|
||||
const.CONF_FLOW_TYPE: CONF_DEVICE,
|
||||
@@ -710,7 +710,7 @@ async def config_flow_device_success(hass, model_to_test):
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -719,7 +719,7 @@ async def config_flow_device_success(hass, model_to_test):
|
||||
{const.CONF_MANUAL: True},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -734,7 +734,7 @@ async def config_flow_device_success(hass, model_to_test):
|
||||
{CONF_HOST: TEST_HOST, CONF_TOKEN: TEST_TOKEN},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == model_to_test
|
||||
assert result["data"] == {
|
||||
const.CONF_FLOW_TYPE: CONF_DEVICE,
|
||||
@@ -756,7 +756,7 @@ async def config_flow_generic_roborock(hass):
|
||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -765,7 +765,7 @@ async def config_flow_generic_roborock(hass):
|
||||
{const.CONF_MANUAL: True},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -780,7 +780,7 @@ async def config_flow_generic_roborock(hass):
|
||||
{CONF_HOST: TEST_HOST, CONF_TOKEN: TEST_TOKEN},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == dummy_model
|
||||
assert result["data"] == {
|
||||
const.CONF_FLOW_TYPE: CONF_DEVICE,
|
||||
@@ -810,7 +810,7 @@ async def zeroconf_device_success(hass, zeroconf_name_to_test, model_to_test):
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -819,7 +819,7 @@ async def zeroconf_device_success(hass, zeroconf_name_to_test, model_to_test):
|
||||
{const.CONF_MANUAL: True},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -834,7 +834,7 @@ async def zeroconf_device_success(hass, zeroconf_name_to_test, model_to_test):
|
||||
{CONF_TOKEN: TEST_TOKEN},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == model_to_test
|
||||
assert result["data"] == {
|
||||
const.CONF_FLOW_TYPE: CONF_DEVICE,
|
||||
@@ -980,7 +980,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||
data=config_entry.data,
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "reauth_confirm"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -988,7 +988,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||
{},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "cloud"
|
||||
assert result["errors"] == {}
|
||||
|
||||
@@ -1001,7 +1001,7 @@ async def test_reauth(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "reauth_successful"
|
||||
|
||||
config_data = config_entry.data.copy()
|
||||
|
@@ -67,12 +67,12 @@ async def test_discovery(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "pick_device"
|
||||
assert not result2["errors"]
|
||||
|
||||
@@ -80,12 +80,12 @@ async def test_discovery(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "pick_device"
|
||||
assert not result2["errors"]
|
||||
|
||||
@@ -98,7 +98,7 @@ async def test_discovery(hass: HomeAssistant) -> None:
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {CONF_DEVICE: ID}
|
||||
)
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == UNIQUE_FRIENDLY_NAME
|
||||
assert result3["data"] == {CONF_ID: ID, CONF_HOST: IP_ADDRESS, CONF_MODEL: MODEL}
|
||||
await hass.async_block_till_done()
|
||||
@@ -109,13 +109,13 @@ async def test_discovery(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
with _patch_discovery(), _patch_discovery_interval():
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
@@ -151,7 +151,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "pick_device"
|
||||
assert not result2["errors"]
|
||||
|
||||
@@ -160,13 +160,13 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
with _patch_discovery(), _patch_discovery_interval():
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "pick_device"
|
||||
assert not result2["errors"]
|
||||
|
||||
@@ -178,7 +178,7 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {CONF_DEVICE: ID}
|
||||
)
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == UNIQUE_FRIENDLY_NAME
|
||||
assert result3["data"] == {
|
||||
CONF_ID: ID,
|
||||
@@ -192,13 +192,13 @@ async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> No
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
with _patch_discovery(), _patch_discovery_interval():
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ async def test_discovery_no_device(hass: HomeAssistant) -> None:
|
||||
):
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "no_devices_found"
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ async def test_import(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=config
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
# Success
|
||||
@@ -255,7 +255,7 @@ async def test_import(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=config
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == DEFAULT_NAME
|
||||
assert result["data"] == {
|
||||
CONF_NAME: DEFAULT_NAME,
|
||||
@@ -278,7 +278,7 @@ async def test_import(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data=config
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -287,7 +287,7 @@ async def test_manual(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
@@ -302,7 +302,7 @@ async def test_manual(hass: HomeAssistant) -> None:
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {CONF_HOST: IP_ADDRESS}
|
||||
)
|
||||
assert result2["type"] == "form"
|
||||
assert result2["type"] is FlowResultType.FORM
|
||||
assert result2["step_id"] == "user"
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
@@ -331,7 +331,7 @@ async def test_manual(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], {CONF_HOST: IP_ADDRESS}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result4["type"] == "create_entry"
|
||||
assert result4["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result4["title"] == "Color 0x15243f"
|
||||
assert result4["data"] == {
|
||||
CONF_HOST: IP_ADDRESS,
|
||||
@@ -353,7 +353,7 @@ async def test_manual(hass: HomeAssistant) -> None:
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {CONF_HOST: IP_ADDRESS}
|
||||
)
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -382,7 +382,7 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||
assert hass.states.get(f"light.{NAME}_nightlight") is None
|
||||
|
||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
config[CONF_NIGHTLIGHT_SWITCH] = True
|
||||
@@ -394,7 +394,7 @@ async def test_options(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], user_input
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == config
|
||||
assert result2["data"] == config_entry.options
|
||||
assert hass.states.get(f"light.{NAME}_nightlight") is not None
|
||||
@@ -425,7 +425,7 @@ async def test_options_unknown_model(hass: HomeAssistant) -> None:
|
||||
assert hass.states.get(f"light.{NAME}_nightlight") is None
|
||||
|
||||
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "init"
|
||||
|
||||
config[CONF_NIGHTLIGHT_SWITCH] = True
|
||||
@@ -436,7 +436,7 @@ async def test_options_unknown_model(hass: HomeAssistant) -> None:
|
||||
result["flow_id"], user_input
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == config
|
||||
assert result2["data"] == config_entry.options
|
||||
assert hass.states.get(f"light.{NAME}_nightlight") is not None
|
||||
@@ -447,7 +447,7 @@ async def test_manual_no_capabilities(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
assert not result["errors"]
|
||||
|
||||
@@ -469,7 +469,7 @@ async def test_manual_no_capabilities(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {CONF_HOST: IP_ADDRESS}
|
||||
)
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
CONF_HOST: IP_ADDRESS,
|
||||
CONF_ID: None,
|
||||
@@ -604,7 +604,7 @@ async def test_discovered_by_dhcp_or_homekit(hass: HomeAssistant, source, data)
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == {
|
||||
CONF_HOST: IP_ADDRESS,
|
||||
CONF_ID: "0x000000000015243f",
|
||||
@@ -697,7 +697,7 @@ async def test_discovered_ssdp(hass: HomeAssistant) -> None:
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == {
|
||||
CONF_HOST: IP_ADDRESS,
|
||||
CONF_ID: "0x000000000015243f",
|
||||
@@ -751,7 +751,7 @@ async def test_discovered_zeroconf(hass: HomeAssistant) -> None:
|
||||
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["data"] == {
|
||||
CONF_HOST: IP_ADDRESS,
|
||||
CONF_ID: "0x000000000015243f",
|
||||
@@ -916,7 +916,7 @@ async def test_discovered_during_onboarding(hass: HomeAssistant, source, data) -
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
CONF_HOST: IP_ADDRESS,
|
||||
CONF_ID: "0x000000000015243f",
|
||||
|
@@ -75,7 +75,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"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TITLE
|
||||
assert "result" in result
|
||||
assert result["result"].unique_id == "UC_x5XG1OV2P6uZZ5FSM9Ttw"
|
||||
@@ -300,7 +300,7 @@ async def test_reauth(
|
||||
|
||||
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == abort_reason
|
||||
assert result["description_placeholders"] == placeholders
|
||||
assert len(mock_setup.mock_calls) == calls
|
||||
|
@@ -7,6 +7,7 @@ import pyzerproc
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.zerproc.config_flow import DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
|
||||
async def test_flow_success(hass: HomeAssistant) -> None:
|
||||
@@ -15,7 +16,7 @@ async def test_flow_success(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@@ -34,7 +35,7 @@ async def test_flow_success(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Zerproc"
|
||||
assert result2["data"] == {}
|
||||
|
||||
@@ -47,7 +48,7 @@ async def test_flow_no_devices_found(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@@ -65,7 +66,7 @@ async def test_flow_no_devices_found(hass: HomeAssistant) -> None:
|
||||
{},
|
||||
)
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "no_devices_found"
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
@@ -77,7 +78,7 @@ async def test_flow_exceptions_caught(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] is None
|
||||
|
||||
with (
|
||||
@@ -95,7 +96,7 @@ async def test_flow_exceptions_caught(hass: HomeAssistant) -> None:
|
||||
{},
|
||||
)
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "no_devices_found"
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup_entry.mock_calls) == 0
|
||||
|
@@ -580,7 +580,7 @@ async def test_discovery_via_usb_deconz_already_discovered(hass: HomeAssistant)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_zha_device"
|
||||
|
||||
|
||||
@@ -602,7 +602,7 @@ async def test_discovery_via_usb_deconz_already_setup(hass: HomeAssistant) -> No
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_zha_device"
|
||||
|
||||
|
||||
@@ -684,7 +684,7 @@ async def test_discovery_already_setup(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "single_instance_allowed"
|
||||
|
||||
|
||||
@@ -812,7 +812,7 @@ async def test_user_flow_existing_config_entry(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={CONF_SOURCE: SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
|
||||
|
||||
@patch(f"bellows.{PROBE_FUNCTION_PATH}", return_value=False)
|
||||
|
@@ -19,6 +19,7 @@ from homeassistant.components.zeroconf import ZeroconfServiceInfo
|
||||
from homeassistant.components.zwave_js.config_flow import SERVER_VERSION_TIMEOUT, TITLE
|
||||
from homeassistant.components.zwave_js.const import ADDON_SLUG, DOMAIN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
@@ -193,7 +194,7 @@ async def test_manual(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
with (
|
||||
patch(
|
||||
@@ -212,7 +213,7 @@ async def test_manual(hass: HomeAssistant) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Z-Wave JS"
|
||||
assert result2["data"] == {
|
||||
"url": "ws://localhost:3000",
|
||||
@@ -277,7 +278,7 @@ async def test_manual_errors(
|
||||
entry = integration
|
||||
result = await getattr(hass.config_entries, flow).async_init(**flow_params(entry))
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
|
||||
result = await getattr(hass.config_entries, flow).async_configure(
|
||||
@@ -287,7 +288,7 @@ async def test_manual_errors(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
assert result["errors"] == {"base": error}
|
||||
|
||||
@@ -310,7 +311,7 @@ async def test_manual_already_configured(hass: HomeAssistant) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -320,7 +321,7 @@ async def test_manual_already_configured(hass: HomeAssistant) -> None:
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data["url"] == "ws://1.1.1.1:3001"
|
||||
assert entry.data["use_addon"] is False
|
||||
@@ -366,7 +367,7 @@ async def test_supervisor_discovery(
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TITLE
|
||||
assert result["data"] == {
|
||||
"url": "ws://host1:3001",
|
||||
@@ -402,7 +403,7 @@ async def test_supervisor_discovery_cannot_connect(
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
@@ -433,20 +434,20 @@ async def test_clean_discovery_on_user_create(
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"use_addon": False}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
|
||||
with (
|
||||
@@ -467,7 +468,7 @@ async def test_clean_discovery_on_user_create(
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(hass.config_entries.flow.async_progress()) == 0
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TITLE
|
||||
assert result["data"] == {
|
||||
"url": "ws://localhost:3000",
|
||||
@@ -507,7 +508,7 @@ async def test_abort_discovery_with_existing_entry(
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
# Assert that the entry data is updated with discovery info.
|
||||
assert entry.data["url"] == "ws://host1:3001"
|
||||
@@ -522,7 +523,7 @@ async def test_abort_hassio_discovery_with_existing_flow(
|
||||
context={"source": config_entries.SOURCE_USB},
|
||||
data=USB_DISCOVERY_INFO,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "usb_confirm"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_init(
|
||||
@@ -536,7 +537,7 @@ async def test_abort_hassio_discovery_with_existing_flow(
|
||||
),
|
||||
)
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_in_progress"
|
||||
|
||||
|
||||
@@ -559,7 +560,7 @@ async def test_abort_hassio_discovery_for_other_addon(
|
||||
),
|
||||
)
|
||||
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "not_zwave_js_addon"
|
||||
|
||||
|
||||
@@ -580,12 +581,12 @@ async def test_usb_discovery(
|
||||
context={"source": config_entries.SOURCE_USB},
|
||||
data=USB_DISCOVERY_INFO,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "usb_confirm"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "install_addon"
|
||||
|
||||
# Make sure the flow continues when the progress task is done.
|
||||
@@ -595,7 +596,7 @@ async def test_usb_discovery(
|
||||
|
||||
assert install_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -622,7 +623,7 @@ async def test_usb_discovery(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
with (
|
||||
@@ -640,7 +641,7 @@ async def test_usb_discovery(
|
||||
|
||||
assert start_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TITLE
|
||||
assert result["data"] == {
|
||||
"url": "ws://host1:3001",
|
||||
@@ -674,12 +675,12 @@ async def test_usb_discovery_addon_not_running(
|
||||
context={"source": config_entries.SOURCE_USB},
|
||||
data=USB_DISCOVERY_INFO,
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "usb_confirm"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
# Make sure the discovered usb device is preferred.
|
||||
@@ -715,7 +716,7 @@ async def test_usb_discovery_addon_not_running(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
with (
|
||||
@@ -733,7 +734,7 @@ async def test_usb_discovery_addon_not_running(
|
||||
|
||||
assert start_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TITLE
|
||||
assert result["data"] == {
|
||||
"url": "ws://host1:3001",
|
||||
@@ -772,11 +773,11 @@ async def test_discovery_addon_not_running(
|
||||
)
|
||||
|
||||
assert result["step_id"] == "hassio_confirm"
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -804,7 +805,7 @@ async def test_discovery_addon_not_running(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
with (
|
||||
@@ -822,7 +823,7 @@ async def test_discovery_addon_not_running(
|
||||
|
||||
assert start_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TITLE
|
||||
assert result["data"] == {
|
||||
"url": "ws://host1:3001",
|
||||
@@ -860,12 +861,12 @@ async def test_discovery_addon_not_installed(
|
||||
)
|
||||
|
||||
assert result["step_id"] == "hassio_confirm"
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
|
||||
assert result["step_id"] == "install_addon"
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@@ -873,7 +874,7 @@ async def test_discovery_addon_not_installed(
|
||||
|
||||
assert install_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -901,7 +902,7 @@ async def test_discovery_addon_not_installed(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
with (
|
||||
@@ -919,7 +920,7 @@ async def test_discovery_addon_not_installed(
|
||||
|
||||
assert start_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TITLE
|
||||
assert result["data"] == {
|
||||
"url": "ws://host1:3001",
|
||||
@@ -950,7 +951,7 @@ async def test_abort_usb_discovery_with_existing_flow(
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "hassio_confirm"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_init(
|
||||
@@ -958,7 +959,7 @@ async def test_abort_usb_discovery_with_existing_flow(
|
||||
context={"source": config_entries.SOURCE_USB},
|
||||
data=USB_DISCOVERY_INFO,
|
||||
)
|
||||
assert result2["type"] == "abort"
|
||||
assert result2["type"] is FlowResultType.ABORT
|
||||
assert result2["reason"] == "already_in_progress"
|
||||
|
||||
|
||||
@@ -979,7 +980,7 @@ async def test_abort_usb_discovery_already_configured(
|
||||
context={"source": config_entries.SOURCE_USB},
|
||||
data=USB_DISCOVERY_INFO,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -990,7 +991,7 @@ async def test_usb_discovery_requires_supervisor(hass: HomeAssistant) -> None:
|
||||
context={"source": config_entries.SOURCE_USB},
|
||||
data=USB_DISCOVERY_INFO,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "discovery_requires_supervisor"
|
||||
|
||||
|
||||
@@ -1003,7 +1004,7 @@ async def test_usb_discovery_already_running(
|
||||
context={"source": config_entries.SOURCE_USB},
|
||||
data=USB_DISCOVERY_INFO,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
@@ -1020,7 +1021,7 @@ async def test_abort_usb_discovery_aborts_specific_devices(
|
||||
context={"source": config_entries.SOURCE_USB},
|
||||
data=discovery_info,
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "not_zwave_device"
|
||||
|
||||
|
||||
@@ -1031,14 +1032,14 @@ async def test_not_addon(hass: HomeAssistant, supervisor) -> None:
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"use_addon": False}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
|
||||
with (
|
||||
@@ -1058,7 +1059,7 @@ async def test_not_addon(hass: HomeAssistant, supervisor) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TITLE
|
||||
assert result["data"] == {
|
||||
"url": "ws://localhost:3000",
|
||||
@@ -1093,7 +1094,7 @@ async def test_addon_running(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
with (
|
||||
@@ -1110,7 +1111,7 @@ async def test_addon_running(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TITLE
|
||||
assert result["data"] == {
|
||||
"url": "ws://host1:3001",
|
||||
@@ -1181,14 +1182,14 @@ async def test_addon_running_failures(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == abort_reason
|
||||
|
||||
|
||||
@@ -1227,14 +1228,14 @@ async def test_addon_running_already_configured(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data["url"] == "ws://host1:3001"
|
||||
assert entry.data["usb_path"] == "/test_new"
|
||||
@@ -1260,14 +1261,14 @@ async def test_addon_installed(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1295,7 +1296,7 @@ async def test_addon_installed(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
with (
|
||||
@@ -1313,7 +1314,7 @@ async def test_addon_installed(
|
||||
|
||||
assert start_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TITLE
|
||||
assert result["data"] == {
|
||||
"url": "ws://host1:3001",
|
||||
@@ -1348,14 +1349,14 @@ async def test_addon_installed_start_failure(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1383,7 +1384,7 @@ async def test_addon_installed_start_failure(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
await hass.async_block_till_done()
|
||||
@@ -1391,7 +1392,7 @@ async def test_addon_installed_start_failure(
|
||||
|
||||
assert start_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "addon_start_failed"
|
||||
|
||||
|
||||
@@ -1423,14 +1424,14 @@ async def test_addon_installed_failures(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1458,7 +1459,7 @@ async def test_addon_installed_failures(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
await hass.async_block_till_done()
|
||||
@@ -1466,7 +1467,7 @@ async def test_addon_installed_failures(
|
||||
|
||||
assert start_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "addon_start_failed"
|
||||
|
||||
|
||||
@@ -1489,14 +1490,14 @@ async def test_addon_installed_set_options_failure(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1524,7 +1525,7 @@ async def test_addon_installed_set_options_failure(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "addon_set_config_failed"
|
||||
|
||||
assert start_addon.call_count == 0
|
||||
@@ -1561,14 +1562,14 @@ async def test_addon_installed_already_configured(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1596,7 +1597,7 @@ async def test_addon_installed_already_configured(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
await hass.async_block_till_done()
|
||||
@@ -1604,7 +1605,7 @@ async def test_addon_installed_already_configured(
|
||||
|
||||
assert start_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
assert entry.data["url"] == "ws://host1:3001"
|
||||
assert entry.data["usb_path"] == "/new"
|
||||
@@ -1630,14 +1631,14 @@ async def test_addon_not_installed(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "install_addon"
|
||||
|
||||
# Make sure the flow continues when the progress task is done.
|
||||
@@ -1647,7 +1648,7 @@ async def test_addon_not_installed(
|
||||
|
||||
assert install_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
@@ -1675,7 +1676,7 @@ async def test_addon_not_installed(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
with (
|
||||
@@ -1693,7 +1694,7 @@ async def test_addon_not_installed(
|
||||
|
||||
assert start_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TITLE
|
||||
assert result["data"] == {
|
||||
"url": "ws://host1:3001",
|
||||
@@ -1719,14 +1720,14 @@ async def test_install_addon_failure(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
|
||||
# Make sure the flow continues when the progress task is done.
|
||||
await hass.async_block_till_done()
|
||||
@@ -1735,7 +1736,7 @@ async def test_install_addon_failure(
|
||||
|
||||
assert install_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "addon_install_failed"
|
||||
|
||||
|
||||
@@ -1749,7 +1750,7 @@ async def test_options_manual(hass: HomeAssistant, client, integration) -> None:
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -1757,7 +1758,7 @@ async def test_options_manual(hass: HomeAssistant, client, integration) -> None:
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert entry.data["url"] == "ws://1.1.1.1:3001"
|
||||
assert entry.data["use_addon"] is False
|
||||
assert entry.data["integration_created_addon"] is False
|
||||
@@ -1774,7 +1775,7 @@ async def test_options_manual_different_device(
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -1782,7 +1783,7 @@ async def test_options_manual_different_device(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "different_device"
|
||||
|
||||
|
||||
@@ -1798,14 +1799,14 @@ async def test_options_not_addon(
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"], {"use_addon": False}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "manual"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -1816,7 +1817,7 @@ async def test_options_not_addon(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert entry.data["url"] == "ws://localhost:3000"
|
||||
assert entry.data["use_addon"] is False
|
||||
assert entry.data["integration_created_addon"] is False
|
||||
@@ -1908,14 +1909,14 @@ async def test_options_addon_running(
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -1931,7 +1932,7 @@ async def test_options_addon_running(
|
||||
)
|
||||
assert client.disconnect.call_count == disconnect_calls
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
await hass.async_block_till_done()
|
||||
@@ -1940,7 +1941,7 @@ async def test_options_addon_running(
|
||||
|
||||
assert restart_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert entry.data["url"] == "ws://host1:3001"
|
||||
assert entry.data["usb_path"] == new_addon_options["device"]
|
||||
assert entry.data["s0_legacy_key"] == new_addon_options["s0_legacy_key"]
|
||||
@@ -2017,14 +2018,14 @@ async def test_options_addon_running_no_changes(
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -2037,7 +2038,7 @@ async def test_options_addon_running_no_changes(
|
||||
assert set_addon_options.call_count == 0
|
||||
assert restart_addon.call_count == 0
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert entry.data["url"] == "ws://host1:3001"
|
||||
assert entry.data["usb_path"] == new_addon_options["device"]
|
||||
assert entry.data["s0_legacy_key"] == new_addon_options["s0_legacy_key"]
|
||||
@@ -2160,14 +2161,14 @@ async def test_options_different_device(
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -2183,7 +2184,7 @@ async def test_options_different_device(
|
||||
{"options": new_addon_options},
|
||||
)
|
||||
assert client.disconnect.call_count == disconnect_calls
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
await hass.async_block_till_done()
|
||||
@@ -2205,7 +2206,7 @@ async def test_options_different_device(
|
||||
"core_zwave_js",
|
||||
{"options": addon_options},
|
||||
)
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
await hass.async_block_till_done()
|
||||
@@ -2216,7 +2217,7 @@ async def test_options_different_device(
|
||||
result = await hass.config_entries.options.async_configure(result["flow_id"])
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "different_device"
|
||||
assert entry.data == data
|
||||
assert client.connect.call_count == 2
|
||||
@@ -2318,14 +2319,14 @@ async def test_options_addon_restart_failed(
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -2341,7 +2342,7 @@ async def test_options_addon_restart_failed(
|
||||
{"options": new_addon_options},
|
||||
)
|
||||
assert client.disconnect.call_count == disconnect_calls
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
await hass.async_block_till_done()
|
||||
@@ -2360,7 +2361,7 @@ async def test_options_addon_restart_failed(
|
||||
"core_zwave_js",
|
||||
{"options": old_addon_options},
|
||||
)
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
await hass.async_block_till_done()
|
||||
@@ -2371,7 +2372,7 @@ async def test_options_addon_restart_failed(
|
||||
result = await hass.config_entries.options.async_configure(result["flow_id"])
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "addon_start_failed"
|
||||
assert entry.data == data
|
||||
assert client.connect.call_count == 2
|
||||
@@ -2445,14 +2446,14 @@ async def test_options_addon_running_server_info_failure(
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -2461,7 +2462,7 @@ async def test_options_addon_running_server_info_failure(
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "abort"
|
||||
assert result["type"] is FlowResultType.ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
assert entry.data == data
|
||||
assert client.connect.call_count == 2
|
||||
@@ -2553,14 +2554,14 @@ async def test_options_addon_not_installed(
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "install_addon"
|
||||
|
||||
# Make sure the flow continues when the progress task is done.
|
||||
@@ -2570,7 +2571,7 @@ async def test_options_addon_not_installed(
|
||||
|
||||
assert install_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
result = await hass.config_entries.options.async_configure(
|
||||
@@ -2586,7 +2587,7 @@ async def test_options_addon_not_installed(
|
||||
)
|
||||
assert client.disconnect.call_count == disconnect_calls
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
await hass.async_block_till_done()
|
||||
@@ -2598,7 +2599,7 @@ async def test_options_addon_not_installed(
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert entry.data["url"] == "ws://host1:3001"
|
||||
assert entry.data["usb_path"] == new_addon_options["device"]
|
||||
assert entry.data["s0_legacy_key"] == new_addon_options["s0_legacy_key"]
|
||||
@@ -2627,14 +2628,14 @@ async def test_import_addon_installed(
|
||||
data={"usb_path": "/test/imported", "network_key": "imported123"},
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "on_supervisor"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], {"use_addon": True}
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "configure_addon"
|
||||
|
||||
# the default input should be the imported data
|
||||
@@ -2666,7 +2667,7 @@ async def test_import_addon_installed(
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "progress"
|
||||
assert result["type"] is FlowResultType.SHOW_PROGRESS
|
||||
assert result["step_id"] == "start_addon"
|
||||
|
||||
with (
|
||||
@@ -2684,7 +2685,7 @@ async def test_import_addon_installed(
|
||||
|
||||
assert start_addon.call_args == call(hass, "core_zwave_js")
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TITLE
|
||||
assert result["data"] == {
|
||||
"url": "ws://host1:3001",
|
||||
@@ -2717,7 +2718,7 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "zeroconf_confirm"
|
||||
|
||||
with (
|
||||
@@ -2732,7 +2733,7 @@ async def test_zeroconf(hass: HomeAssistant) -> None:
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == TITLE
|
||||
assert result["data"] == {
|
||||
"url": "ws://127.0.0.1:3000",
|
||||
|
Reference in New Issue
Block a user