mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 07:51:46 -05:00
Split the Amber Electric user flow init from its data (#180766)
This commit is contained in:
@@ -161,9 +161,15 @@ async def test_single_pending_site(
|
||||
|
||||
# Test filling in API key
|
||||
enter_api_key_result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
data={CONF_API_TOKEN: API_KEY},
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
|
||||
assert enter_api_key_result["type"] is FlowResultType.FORM
|
||||
assert enter_api_key_result["step_id"] == "user"
|
||||
|
||||
enter_api_key_result = await hass.config_entries.flow.async_configure(
|
||||
enter_api_key_result["flow_id"],
|
||||
user_input={CONF_API_TOKEN: API_KEY},
|
||||
)
|
||||
assert enter_api_key_result.get("type") is FlowResultType.FORM
|
||||
assert enter_api_key_result.get("step_id") == "site"
|
||||
@@ -192,9 +198,15 @@ async def test_single_site(hass: HomeAssistant, single_site_api: Mock) -> None:
|
||||
|
||||
# Test filling in API key
|
||||
enter_api_key_result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
data={CONF_API_TOKEN: API_KEY},
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
|
||||
assert enter_api_key_result["type"] is FlowResultType.FORM
|
||||
assert enter_api_key_result["step_id"] == "user"
|
||||
|
||||
enter_api_key_result = await hass.config_entries.flow.async_configure(
|
||||
enter_api_key_result["flow_id"],
|
||||
user_input={CONF_API_TOKEN: API_KEY},
|
||||
)
|
||||
assert enter_api_key_result.get("type") is FlowResultType.FORM
|
||||
assert enter_api_key_result.get("step_id") == "site"
|
||||
@@ -218,9 +230,15 @@ async def test_single_closed_site_no_closed_date(
|
||||
) -> None:
|
||||
"""Test single closed site with no closed date is filtered out."""
|
||||
enter_api_key_result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
data={CONF_API_TOKEN: API_KEY},
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
|
||||
assert enter_api_key_result["type"] is FlowResultType.FORM
|
||||
assert enter_api_key_result["step_id"] == "user"
|
||||
|
||||
enter_api_key_result = await hass.config_entries.flow.async_configure(
|
||||
enter_api_key_result["flow_id"],
|
||||
user_input={CONF_API_TOKEN: API_KEY},
|
||||
)
|
||||
assert enter_api_key_result.get("type") is FlowResultType.FORM
|
||||
assert enter_api_key_result.get("step_id") == "user"
|
||||
@@ -239,9 +257,15 @@ async def test_single_site_rejoin(
|
||||
|
||||
# Test filling in API key
|
||||
enter_api_key_result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
data={CONF_API_TOKEN: API_KEY},
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
|
||||
assert enter_api_key_result["type"] is FlowResultType.FORM
|
||||
assert enter_api_key_result["step_id"] == "user"
|
||||
|
||||
enter_api_key_result = await hass.config_entries.flow.async_configure(
|
||||
enter_api_key_result["flow_id"],
|
||||
user_input={CONF_API_TOKEN: API_KEY},
|
||||
)
|
||||
assert enter_api_key_result.get("type") is FlowResultType.FORM
|
||||
assert enter_api_key_result.get("step_id") == "site"
|
||||
@@ -263,9 +287,15 @@ async def test_single_site_rejoin(
|
||||
async def test_no_site(hass: HomeAssistant, no_site_api: Mock) -> None:
|
||||
"""Test no site."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
data={CONF_API_TOKEN: "psk_123456789"},
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={CONF_API_TOKEN: "psk_123456789"},
|
||||
)
|
||||
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
@@ -284,9 +314,15 @@ async def test_invalid_key(hass: HomeAssistant, invalid_key_api: Mock) -> None:
|
||||
|
||||
# Test filling in API key
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
data={CONF_API_TOKEN: "psk_123456789"},
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={CONF_API_TOKEN: "psk_123456789"},
|
||||
)
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
# Goes back to the user step
|
||||
@@ -304,9 +340,15 @@ async def test_unknown_error(hass: HomeAssistant, api_error: Mock) -> None:
|
||||
|
||||
# Test filling in API key
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
data={CONF_API_TOKEN: "psk_123456789"},
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={CONF_API_TOKEN: "psk_123456789"},
|
||||
)
|
||||
assert result.get("type") is FlowResultType.FORM
|
||||
# Goes back to the user step
|
||||
|
||||
Reference in New Issue
Block a user