2020-02-29 03:14:17 +00:00
|
|
|
"""Define tests for the AirVisual config flow."""
|
2021-01-01 21:31:56 +00:00
|
|
|
from unittest.mock import patch
|
|
|
|
|
2021-02-01 21:38:03 +00:00
|
|
|
from pyairvisual.errors import (
|
|
|
|
AirVisualError,
|
|
|
|
InvalidKeyError,
|
|
|
|
NodeProError,
|
|
|
|
NotFoundError,
|
|
|
|
)
|
2020-02-29 03:14:17 +00:00
|
|
|
|
|
|
|
from homeassistant import data_entry_flow
|
2021-02-01 21:38:03 +00:00
|
|
|
from homeassistant.components.airvisual.const import (
|
|
|
|
CONF_CITY,
|
|
|
|
CONF_COUNTRY,
|
2020-04-22 23:41:14 +00:00
|
|
|
CONF_GEOGRAPHIES,
|
2020-04-24 17:11:17 +00:00
|
|
|
CONF_INTEGRATION_TYPE,
|
2020-04-22 23:41:14 +00:00
|
|
|
DOMAIN,
|
2021-02-01 21:38:03 +00:00
|
|
|
INTEGRATION_TYPE_GEOGRAPHY_COORDS,
|
|
|
|
INTEGRATION_TYPE_GEOGRAPHY_NAME,
|
2020-04-22 23:41:14 +00:00
|
|
|
INTEGRATION_TYPE_NODE_PRO,
|
|
|
|
)
|
2020-11-09 12:41:04 +00:00
|
|
|
from homeassistant.config_entries import SOURCE_USER
|
2020-03-10 20:16:25 +00:00
|
|
|
from homeassistant.const import (
|
|
|
|
CONF_API_KEY,
|
2020-04-22 23:41:14 +00:00
|
|
|
CONF_IP_ADDRESS,
|
2020-03-10 20:16:25 +00:00
|
|
|
CONF_LATITUDE,
|
|
|
|
CONF_LONGITUDE,
|
2020-04-22 23:41:14 +00:00
|
|
|
CONF_PASSWORD,
|
2020-03-10 20:16:25 +00:00
|
|
|
CONF_SHOW_ON_MAP,
|
2021-02-01 21:38:03 +00:00
|
|
|
CONF_STATE,
|
2020-03-10 20:16:25 +00:00
|
|
|
)
|
2020-03-24 18:39:38 +00:00
|
|
|
from homeassistant.setup import async_setup_component
|
2020-02-29 03:14:17 +00:00
|
|
|
|
2020-03-10 03:39:42 +00:00
|
|
|
from tests.common import MockConfigEntry
|
2020-02-29 03:14:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_duplicate_error(hass):
|
2020-04-22 23:41:14 +00:00
|
|
|
"""Test that errors are shown when duplicate entries are added."""
|
|
|
|
geography_conf = {
|
2020-03-24 18:39:38 +00:00
|
|
|
CONF_API_KEY: "abcde12345",
|
|
|
|
CONF_LATITUDE: 51.528308,
|
|
|
|
CONF_LONGITUDE: -0.3817765,
|
|
|
|
}
|
2020-02-29 03:14:17 +00:00
|
|
|
|
2020-03-24 18:39:38 +00:00
|
|
|
MockConfigEntry(
|
2020-04-22 23:41:14 +00:00
|
|
|
domain=DOMAIN, unique_id="51.528308, -0.3817765", data=geography_conf
|
2020-03-24 18:39:38 +00:00
|
|
|
).add_to_hass(hass)
|
2020-02-29 03:14:17 +00:00
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2021-02-01 21:38:03 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
|
|
|
data={"type": INTEGRATION_TYPE_GEOGRAPHY_COORDS},
|
2020-11-09 12:41:04 +00:00
|
|
|
)
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input=geography_conf
|
2020-02-29 03:14:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "already_configured"
|
|
|
|
|
2020-09-09 22:41:07 +00:00
|
|
|
node_pro_conf = {CONF_IP_ADDRESS: "192.168.1.100", CONF_PASSWORD: "12345"}
|
|
|
|
|
2020-04-22 23:41:14 +00:00
|
|
|
MockConfigEntry(
|
|
|
|
domain=DOMAIN, unique_id="192.168.1.100", data=node_pro_conf
|
|
|
|
).add_to_hass(hass)
|
2020-02-29 03:14:17 +00:00
|
|
|
|
2020-04-22 23:41:14 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_USER}, data={"type": "AirVisual Node/Pro"}
|
|
|
|
)
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input=node_pro_conf
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "already_configured"
|
|
|
|
|
|
|
|
|
2021-02-01 21:38:03 +00:00
|
|
|
async def test_invalid_identifier_geography_api_key(hass):
|
|
|
|
"""Test that an invalid API key throws an error."""
|
2020-02-29 03:14:17 +00:00
|
|
|
with patch(
|
2020-10-25 12:16:23 +00:00
|
|
|
"pyairvisual.air_quality.AirQuality.nearest_city",
|
2020-08-27 11:56:20 +00:00
|
|
|
side_effect=InvalidKeyError,
|
2020-02-29 03:14:17 +00:00
|
|
|
):
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-11-09 12:41:04 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
2021-02-01 21:38:03 +00:00
|
|
|
data={"type": INTEGRATION_TYPE_GEOGRAPHY_COORDS},
|
2020-11-09 12:41:04 +00:00
|
|
|
)
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
2021-02-01 21:38:03 +00:00
|
|
|
result["flow_id"],
|
|
|
|
user_input={
|
|
|
|
CONF_API_KEY: "abcde12345",
|
|
|
|
CONF_LATITUDE: 51.528308,
|
|
|
|
CONF_LONGITUDE: -0.3817765,
|
|
|
|
},
|
2020-02-29 03:14:17 +00:00
|
|
|
)
|
2020-11-09 12:41:04 +00:00
|
|
|
|
2020-04-22 23:41:14 +00:00
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
2020-02-29 03:14:17 +00:00
|
|
|
assert result["errors"] == {CONF_API_KEY: "invalid_api_key"}
|
|
|
|
|
|
|
|
|
2021-02-01 21:38:03 +00:00
|
|
|
async def test_invalid_identifier_geography_name(hass):
|
|
|
|
"""Test that an invalid location name throws an error."""
|
|
|
|
with patch(
|
|
|
|
"pyairvisual.air_quality.AirQuality.city",
|
|
|
|
side_effect=NotFoundError,
|
|
|
|
):
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
|
|
|
data={"type": INTEGRATION_TYPE_GEOGRAPHY_NAME},
|
|
|
|
)
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"],
|
|
|
|
user_input={
|
|
|
|
CONF_API_KEY: "abcde12345",
|
|
|
|
CONF_CITY: "Beijing",
|
|
|
|
CONF_STATE: "Beijing",
|
|
|
|
CONF_COUNTRY: "China",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["errors"] == {CONF_CITY: "location_not_found"}
|
|
|
|
|
|
|
|
|
|
|
|
async def test_invalid_identifier_geography_unknown(hass):
|
|
|
|
"""Test that an unknown identifier issue throws an error."""
|
|
|
|
with patch(
|
|
|
|
"pyairvisual.air_quality.AirQuality.city",
|
|
|
|
side_effect=AirVisualError,
|
|
|
|
):
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
|
|
|
data={"type": INTEGRATION_TYPE_GEOGRAPHY_NAME},
|
|
|
|
)
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"],
|
|
|
|
user_input={
|
|
|
|
CONF_API_KEY: "abcde12345",
|
|
|
|
CONF_CITY: "Beijing",
|
|
|
|
CONF_STATE: "Beijing",
|
|
|
|
CONF_COUNTRY: "China",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["errors"] == {"base": "unknown"}
|
|
|
|
|
|
|
|
|
|
|
|
async def test_invalid_identifier_node_pro(hass):
|
|
|
|
"""Test that an invalid Node/Pro identifier shows an error."""
|
|
|
|
node_pro_conf = {CONF_IP_ADDRESS: "192.168.1.100", CONF_PASSWORD: "my_password"}
|
|
|
|
|
|
|
|
with patch(
|
|
|
|
"pyairvisual.node.NodeSamba.async_connect",
|
|
|
|
side_effect=NodeProError,
|
|
|
|
):
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_USER}, data={"type": "AirVisual Node/Pro"}
|
|
|
|
)
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input=node_pro_conf
|
|
|
|
)
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["errors"] == {CONF_IP_ADDRESS: "cannot_connect"}
|
|
|
|
|
|
|
|
|
2020-04-24 17:11:17 +00:00
|
|
|
async def test_migration(hass):
|
|
|
|
"""Test migrating from version 1 to the current version."""
|
2020-03-24 18:39:38 +00:00
|
|
|
conf = {
|
|
|
|
CONF_API_KEY: "abcde12345",
|
|
|
|
CONF_GEOGRAPHIES: [
|
|
|
|
{CONF_LATITUDE: 51.528308, CONF_LONGITUDE: -0.3817765},
|
2021-02-01 21:38:03 +00:00
|
|
|
{CONF_CITY: "Beijing", CONF_STATE: "Beijing", CONF_COUNTRY: "China"},
|
2020-03-24 18:39:38 +00:00
|
|
|
],
|
|
|
|
}
|
|
|
|
|
|
|
|
config_entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN, version=1, unique_id="abcde12345", data=conf
|
|
|
|
)
|
|
|
|
config_entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
|
|
|
|
|
2021-02-01 21:38:03 +00:00
|
|
|
with patch("pyairvisual.air_quality.AirQuality.city"), patch(
|
|
|
|
"pyairvisual.air_quality.AirQuality.nearest_city"
|
|
|
|
), patch.object(hass.config_entries, "async_forward_entry_setup"):
|
2020-03-24 18:39:38 +00:00
|
|
|
assert await async_setup_component(hass, DOMAIN, {DOMAIN: conf})
|
2020-06-01 05:18:30 +00:00
|
|
|
await hass.async_block_till_done()
|
2020-03-24 18:39:38 +00:00
|
|
|
|
|
|
|
config_entries = hass.config_entries.async_entries(DOMAIN)
|
|
|
|
|
|
|
|
assert len(config_entries) == 2
|
|
|
|
|
|
|
|
assert config_entries[0].unique_id == "51.528308, -0.3817765"
|
|
|
|
assert config_entries[0].title == "Cloud API (51.528308, -0.3817765)"
|
|
|
|
assert config_entries[0].data == {
|
|
|
|
CONF_API_KEY: "abcde12345",
|
|
|
|
CONF_LATITUDE: 51.528308,
|
|
|
|
CONF_LONGITUDE: -0.3817765,
|
2021-02-01 21:38:03 +00:00
|
|
|
CONF_INTEGRATION_TYPE: INTEGRATION_TYPE_GEOGRAPHY_COORDS,
|
2020-03-24 18:39:38 +00:00
|
|
|
}
|
|
|
|
|
2021-02-01 21:38:03 +00:00
|
|
|
assert config_entries[1].unique_id == "Beijing, Beijing, China"
|
|
|
|
assert config_entries[1].title == "Cloud API (Beijing, Beijing, China)"
|
2020-03-24 18:39:38 +00:00
|
|
|
assert config_entries[1].data == {
|
|
|
|
CONF_API_KEY: "abcde12345",
|
2021-02-01 21:38:03 +00:00
|
|
|
CONF_CITY: "Beijing",
|
|
|
|
CONF_STATE: "Beijing",
|
|
|
|
CONF_COUNTRY: "China",
|
|
|
|
CONF_INTEGRATION_TYPE: INTEGRATION_TYPE_GEOGRAPHY_NAME,
|
2020-03-24 18:39:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-10 20:16:25 +00:00
|
|
|
async def test_options_flow(hass):
|
|
|
|
"""Test config flow options."""
|
2020-04-22 23:41:14 +00:00
|
|
|
geography_conf = {
|
|
|
|
CONF_API_KEY: "abcde12345",
|
|
|
|
CONF_LATITUDE: 51.528308,
|
|
|
|
CONF_LONGITUDE: -0.3817765,
|
|
|
|
}
|
2020-03-10 20:16:25 +00:00
|
|
|
|
|
|
|
config_entry = MockConfigEntry(
|
|
|
|
domain=DOMAIN,
|
2020-04-22 23:41:14 +00:00
|
|
|
unique_id="51.528308, -0.3817765",
|
|
|
|
data=geography_conf,
|
2020-03-10 20:16:25 +00:00
|
|
|
options={CONF_SHOW_ON_MAP: True},
|
|
|
|
)
|
|
|
|
config_entry.add_to_hass(hass)
|
|
|
|
|
|
|
|
with patch(
|
|
|
|
"homeassistant.components.airvisual.async_setup_entry", return_value=True
|
|
|
|
):
|
2020-11-09 12:41:04 +00:00
|
|
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
2020-03-10 20:16:25 +00:00
|
|
|
result = await hass.config_entries.options.async_init(config_entry.entry_id)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "init"
|
|
|
|
|
|
|
|
result = await hass.config_entries.options.async_configure(
|
|
|
|
result["flow_id"], user_input={CONF_SHOW_ON_MAP: False}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
assert config_entry.options == {CONF_SHOW_ON_MAP: False}
|
|
|
|
|
|
|
|
|
2021-02-01 21:38:03 +00:00
|
|
|
async def test_step_geography_by_coords(hass):
|
|
|
|
"""Test setting up a geopgraphy entry by latitude/longitude."""
|
2020-03-10 20:16:25 +00:00
|
|
|
conf = {
|
|
|
|
CONF_API_KEY: "abcde12345",
|
2020-03-24 18:39:38 +00:00
|
|
|
CONF_LATITUDE: 51.528308,
|
|
|
|
CONF_LONGITUDE: -0.3817765,
|
2020-03-10 20:16:25 +00:00
|
|
|
}
|
2020-02-29 03:14:17 +00:00
|
|
|
|
2020-03-10 03:39:42 +00:00
|
|
|
with patch(
|
2020-03-10 20:16:25 +00:00
|
|
|
"homeassistant.components.airvisual.async_setup_entry", return_value=True
|
2020-09-24 21:31:47 +00:00
|
|
|
), patch("pyairvisual.air_quality.AirQuality.nearest_city"):
|
2020-03-10 03:39:42 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-11-09 12:41:04 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
2021-02-01 21:38:03 +00:00
|
|
|
data={"type": INTEGRATION_TYPE_GEOGRAPHY_COORDS},
|
2020-03-10 03:39:42 +00:00
|
|
|
)
|
2020-11-09 12:41:04 +00:00
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input=conf
|
2020-09-09 22:41:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
assert result["title"] == "Cloud API (51.528308, -0.3817765)"
|
|
|
|
assert result["data"] == {
|
|
|
|
CONF_API_KEY: "abcde12345",
|
|
|
|
CONF_LATITUDE: 51.528308,
|
|
|
|
CONF_LONGITUDE: -0.3817765,
|
2021-02-01 21:38:03 +00:00
|
|
|
CONF_INTEGRATION_TYPE: INTEGRATION_TYPE_GEOGRAPHY_COORDS,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async def test_step_geography_by_name(hass):
|
|
|
|
"""Test setting up a geopgraphy entry by city/state/country."""
|
|
|
|
conf = {
|
|
|
|
CONF_API_KEY: "abcde12345",
|
|
|
|
CONF_CITY: "Beijing",
|
|
|
|
CONF_STATE: "Beijing",
|
|
|
|
CONF_COUNTRY: "China",
|
|
|
|
}
|
|
|
|
|
|
|
|
with patch(
|
|
|
|
"homeassistant.components.airvisual.async_setup_entry", return_value=True
|
|
|
|
), patch("pyairvisual.air_quality.AirQuality.city"):
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
|
|
|
data={"type": INTEGRATION_TYPE_GEOGRAPHY_NAME},
|
|
|
|
)
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input=conf
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
assert result["title"] == "Cloud API (Beijing, Beijing, China)"
|
|
|
|
assert result["data"] == {
|
|
|
|
CONF_API_KEY: "abcde12345",
|
|
|
|
CONF_CITY: "Beijing",
|
|
|
|
CONF_STATE: "Beijing",
|
|
|
|
CONF_COUNTRY: "China",
|
|
|
|
CONF_INTEGRATION_TYPE: INTEGRATION_TYPE_GEOGRAPHY_NAME,
|
2020-09-09 22:41:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-22 23:41:14 +00:00
|
|
|
async def test_step_node_pro(hass):
|
|
|
|
"""Test the Node/Pro step."""
|
|
|
|
conf = {CONF_IP_ADDRESS: "192.168.1.100", CONF_PASSWORD: "my_password"}
|
|
|
|
|
|
|
|
with patch(
|
|
|
|
"homeassistant.components.airvisual.async_setup_entry", return_value=True
|
2020-09-24 21:31:47 +00:00
|
|
|
), patch("pyairvisual.node.NodeSamba.async_connect"), patch(
|
|
|
|
"pyairvisual.node.NodeSamba.async_get_latest_measurements"
|
|
|
|
), patch(
|
|
|
|
"pyairvisual.node.NodeSamba.async_disconnect"
|
|
|
|
):
|
2020-04-22 23:41:14 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_USER}, data={"type": "AirVisual Node/Pro"}
|
|
|
|
)
|
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input=conf
|
|
|
|
)
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
|
|
assert result["title"] == "Node/Pro (192.168.1.100)"
|
|
|
|
assert result["data"] == {
|
|
|
|
CONF_IP_ADDRESS: "192.168.1.100",
|
|
|
|
CONF_PASSWORD: "my_password",
|
2020-04-24 17:11:17 +00:00
|
|
|
CONF_INTEGRATION_TYPE: INTEGRATION_TYPE_NODE_PRO,
|
2020-04-22 23:41:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-09 22:41:07 +00:00
|
|
|
async def test_step_reauth(hass):
|
|
|
|
"""Test that the reauth step works."""
|
2021-02-01 21:38:03 +00:00
|
|
|
entry_data = {
|
2020-02-29 03:14:17 +00:00
|
|
|
CONF_API_KEY: "abcde12345",
|
2020-04-22 23:41:14 +00:00
|
|
|
CONF_LATITUDE: 51.528308,
|
|
|
|
CONF_LONGITUDE: -0.3817765,
|
2021-02-01 21:38:03 +00:00
|
|
|
CONF_INTEGRATION_TYPE: INTEGRATION_TYPE_GEOGRAPHY_COORDS,
|
2020-02-29 03:14:17 +00:00
|
|
|
}
|
|
|
|
|
2020-09-09 22:41:07 +00:00
|
|
|
MockConfigEntry(
|
2021-02-01 21:38:03 +00:00
|
|
|
domain=DOMAIN, unique_id="51.528308, -0.3817765", data=entry_data
|
2020-09-09 22:41:07 +00:00
|
|
|
).add_to_hass(hass)
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2021-02-01 21:38:03 +00:00
|
|
|
DOMAIN, context={"source": "reauth"}, data=entry_data
|
2020-09-09 22:41:07 +00:00
|
|
|
)
|
|
|
|
assert result["step_id"] == "reauth_confirm"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "reauth_confirm"
|
|
|
|
|
2020-02-29 03:14:17 +00:00
|
|
|
with patch(
|
2020-09-24 21:31:47 +00:00
|
|
|
"homeassistant.components.airvisual.async_setup_entry", return_value=True
|
2020-10-15 07:30:39 +00:00
|
|
|
), patch("pyairvisual.air_quality.AirQuality.nearest_city", return_value=True):
|
2020-09-09 22:41:07 +00:00
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input={CONF_API_KEY: "defgh67890"}
|
2020-02-29 03:14:17 +00:00
|
|
|
)
|
2020-09-09 22:41:07 +00:00
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "reauth_successful"
|
2020-04-22 23:41:14 +00:00
|
|
|
|
2020-09-09 22:41:07 +00:00
|
|
|
assert len(hass.config_entries.async_entries()) == 1
|
2020-04-22 23:41:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_step_user(hass):
|
|
|
|
"""Test the user ("pick the integration type") step."""
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN, context={"source": SOURCE_USER}
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "user"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
2021-02-01 21:38:03 +00:00
|
|
|
data={"type": INTEGRATION_TYPE_GEOGRAPHY_COORDS},
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "geography_by_coords"
|
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
|
|
|
data={"type": INTEGRATION_TYPE_GEOGRAPHY_NAME},
|
2020-04-22 23:41:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
2021-02-01 21:38:03 +00:00
|
|
|
assert result["step_id"] == "geography_by_name"
|
2020-04-22 23:41:14 +00:00
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
|
|
|
data={"type": INTEGRATION_TYPE_NODE_PRO},
|
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
|
|
|
assert result["step_id"] == "node_pro"
|