mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Merge onvif host/auth step, allow skipping scan (#49660)
This commit is contained in:
@@ -203,7 +203,7 @@ async def test_flow_discovered_devices(hass):
|
||||
setup_mock_device(mock_device)
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={}
|
||||
result["flow_id"], user_input={"auto": True}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
@@ -215,7 +215,7 @@ async def test_flow_discovered_devices(hass):
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "auth"
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.onvif.async_setup", return_value=True
|
||||
@@ -268,7 +268,7 @@ async def test_flow_discovered_devices_ignore_configured_manual_input(hass):
|
||||
setup_mock_device(mock_device)
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={}
|
||||
result["flow_id"], user_input={"auto": True}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
@@ -281,7 +281,37 @@ async def test_flow_discovered_devices_ignore_configured_manual_input(hass):
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "manual_input"
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
|
||||
async def test_flow_discovered_no_device(hass):
|
||||
"""Test that config flow discovery no device."""
|
||||
await setup_onvif_integration(hass)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.onvif.config_flow.get_device"
|
||||
) as mock_onvif_camera, patch(
|
||||
"homeassistant.components.onvif.config_flow.wsdiscovery"
|
||||
) as mock_discovery, patch(
|
||||
"homeassistant.components.onvif.ONVIFDevice"
|
||||
) as mock_device:
|
||||
setup_mock_onvif_camera(mock_onvif_camera)
|
||||
mock_discovery.return_value = []
|
||||
setup_mock_device(mock_device)
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={"auto": True}
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
|
||||
async def test_flow_discovery_ignore_existing_and_abort(hass):
|
||||
@@ -319,12 +349,12 @@ async def test_flow_discovery_ignore_existing_and_abort(hass):
|
||||
setup_mock_device(mock_device)
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"], user_input={}
|
||||
result["flow_id"], user_input={"auto": True}
|
||||
)
|
||||
|
||||
# It should skip to manual entry if the only devices are already configured
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "manual_input"
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@@ -332,15 +362,6 @@ async def test_flow_discovery_ignore_existing_and_abort(hass):
|
||||
config_flow.CONF_NAME: NAME,
|
||||
config_flow.CONF_HOST: HOST,
|
||||
config_flow.CONF_PORT: PORT,
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "auth"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
config_flow.CONF_USERNAME: USERNAME,
|
||||
config_flow.CONF_PASSWORD: PASSWORD,
|
||||
},
|
||||
@@ -373,23 +394,11 @@ async def test_flow_manual_entry(hass):
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={},
|
||||
user_input={"auto": False},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "manual_input"
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
config_flow.CONF_NAME: NAME,
|
||||
config_flow.CONF_HOST: HOST,
|
||||
config_flow.CONF_PORT: PORT,
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "auth"
|
||||
assert result["step_id"] == "configure"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.onvif.async_setup", return_value=True
|
||||
@@ -399,6 +408,9 @@ async def test_flow_manual_entry(hass):
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
config_flow.CONF_NAME: NAME,
|
||||
config_flow.CONF_HOST: HOST,
|
||||
config_flow.CONF_PORT: PORT,
|
||||
config_flow.CONF_USERNAME: USERNAME,
|
||||
config_flow.CONF_PASSWORD: PASSWORD,
|
||||
},
|
||||
@@ -598,7 +610,7 @@ async def test_flow_import_onvif_auth_error(hass):
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "auth"
|
||||
assert result["step_id"] == "configure"
|
||||
assert result["errors"]["base"] == "cannot_connect"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user