2020-03-30 23:13:47 +00:00
|
|
|
"""Tests for the IPP config flow."""
|
2021-11-23 21:59:36 +00:00
|
|
|
import dataclasses
|
2021-01-01 21:31:56 +00:00
|
|
|
from unittest.mock import patch
|
|
|
|
|
2021-11-19 16:16:34 +00:00
|
|
|
from homeassistant.components import zeroconf
|
2020-03-31 23:40:07 +00:00
|
|
|
from homeassistant.components.ipp.const import CONF_BASE_PATH, CONF_UUID, DOMAIN
|
2020-03-30 23:13:47 +00:00
|
|
|
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
|
|
|
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_SSL
|
|
|
|
from homeassistant.core import HomeAssistant
|
2020-03-31 23:40:07 +00:00
|
|
|
from homeassistant.data_entry_flow import (
|
|
|
|
RESULT_TYPE_ABORT,
|
|
|
|
RESULT_TYPE_CREATE_ENTRY,
|
|
|
|
RESULT_TYPE_FORM,
|
|
|
|
)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
from . import (
|
|
|
|
MOCK_USER_INPUT,
|
|
|
|
MOCK_ZEROCONF_IPP_SERVICE_INFO,
|
|
|
|
MOCK_ZEROCONF_IPPS_SERVICE_INFO,
|
|
|
|
init_integration,
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection,
|
2020-03-30 23:13:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
from tests.test_util.aiohttp import AiohttpClientMocker
|
|
|
|
|
|
|
|
|
|
|
|
async def test_show_user_form(hass: HomeAssistant) -> None:
|
|
|
|
"""Test that the user set up form is served."""
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
2020-03-30 23:13:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["step_id"] == "user"
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_FORM
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_show_zeroconf_form(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test that the zeroconf confirmation form is served."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2021-11-23 21:59:36 +00:00
|
|
|
discovery_info = dataclasses.replace(MOCK_ZEROCONF_IPP_SERVICE_INFO)
|
2020-03-31 23:40:07 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_ZEROCONF},
|
|
|
|
data=discovery_info,
|
2020-03-31 23:40:07 +00:00
|
|
|
)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
assert result["step_id"] == "zeroconf_confirm"
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_FORM
|
2020-04-16 21:12:26 +00:00
|
|
|
assert result["description_placeholders"] == {CONF_NAME: "EPSON XP-6000 Series"}
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_connection_error(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we show user form on IPP connection error."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock, conn_error=True)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
user_input = MOCK_USER_INPUT.copy()
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
|
|
|
data=user_input,
|
2020-03-30 23:13:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["step_id"] == "user"
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_FORM
|
2020-10-07 20:42:01 +00:00
|
|
|
assert result["errors"] == {"base": "cannot_connect"}
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_zeroconf_connection_error(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we abort zeroconf flow on IPP connection error."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock, conn_error=True)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2021-11-23 21:59:36 +00:00
|
|
|
discovery_info = dataclasses.replace(MOCK_ZEROCONF_IPP_SERVICE_INFO)
|
2020-03-30 23:13:47 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_ZEROCONF},
|
|
|
|
data=discovery_info,
|
2020-03-30 23:13:47 +00:00
|
|
|
)
|
|
|
|
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_ABORT
|
2020-10-07 20:42:01 +00:00
|
|
|
assert result["reason"] == "cannot_connect"
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_zeroconf_confirm_connection_error(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we abort zeroconf flow on IPP connection error."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock, conn_error=True)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2021-11-23 21:59:36 +00:00
|
|
|
discovery_info = dataclasses.replace(MOCK_ZEROCONF_IPP_SERVICE_INFO)
|
2020-03-30 23:13:47 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-04-04 05:36:46 +00:00
|
|
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
2020-03-30 23:13:47 +00:00
|
|
|
)
|
|
|
|
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_ABORT
|
2020-10-07 20:42:01 +00:00
|
|
|
assert result["reason"] == "cannot_connect"
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def test_user_connection_upgrade_required(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we show the user form if connection upgrade required by server."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock, conn_upgrade_error=True)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
user_input = MOCK_USER_INPUT.copy()
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
|
|
|
data=user_input,
|
2020-03-30 23:13:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["step_id"] == "user"
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_FORM
|
2020-03-30 23:13:47 +00:00
|
|
|
assert result["errors"] == {"base": "connection_upgrade"}
|
|
|
|
|
|
|
|
|
|
|
|
async def test_zeroconf_connection_upgrade_required(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we abort zeroconf flow on IPP connection error."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock, conn_upgrade_error=True)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2021-11-23 21:59:36 +00:00
|
|
|
discovery_info = dataclasses.replace(MOCK_ZEROCONF_IPP_SERVICE_INFO)
|
2020-03-30 23:13:47 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_ZEROCONF},
|
|
|
|
data=discovery_info,
|
2020-03-30 23:13:47 +00:00
|
|
|
)
|
|
|
|
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_ABORT
|
2020-03-30 23:13:47 +00:00
|
|
|
assert result["reason"] == "connection_upgrade"
|
|
|
|
|
|
|
|
|
2020-04-07 16:32:43 +00:00
|
|
|
async def test_user_parse_error(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we abort user flow on IPP parse error."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock, parse_error=True)
|
2020-04-07 16:32:43 +00:00
|
|
|
|
|
|
|
user_input = MOCK_USER_INPUT.copy()
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
|
|
|
data=user_input,
|
2020-04-07 16:32:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "parse_error"
|
|
|
|
|
|
|
|
|
|
|
|
async def test_zeroconf_parse_error(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we abort zeroconf flow on IPP parse error."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock, parse_error=True)
|
2020-04-07 16:32:43 +00:00
|
|
|
|
2021-11-23 21:59:36 +00:00
|
|
|
discovery_info = dataclasses.replace(MOCK_ZEROCONF_IPP_SERVICE_INFO)
|
2020-04-07 16:32:43 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_ZEROCONF},
|
|
|
|
data=discovery_info,
|
2020-04-07 16:32:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "parse_error"
|
|
|
|
|
|
|
|
|
2020-04-14 18:30:41 +00:00
|
|
|
async def test_user_ipp_error(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we abort the user flow on IPP error."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock, ipp_error=True)
|
2020-04-14 18:30:41 +00:00
|
|
|
|
|
|
|
user_input = MOCK_USER_INPUT.copy()
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
|
|
|
data=user_input,
|
2020-04-14 18:30:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "ipp_error"
|
|
|
|
|
|
|
|
|
|
|
|
async def test_zeroconf_ipp_error(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we abort zeroconf flow on IPP error."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock, ipp_error=True)
|
2020-04-14 18:30:41 +00:00
|
|
|
|
2021-11-23 21:59:36 +00:00
|
|
|
discovery_info = dataclasses.replace(MOCK_ZEROCONF_IPP_SERVICE_INFO)
|
2020-04-14 18:30:41 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_ZEROCONF},
|
|
|
|
data=discovery_info,
|
2020-04-14 18:30:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "ipp_error"
|
|
|
|
|
|
|
|
|
|
|
|
async def test_user_ipp_version_error(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we abort user flow on IPP version not supported error."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock, version_not_supported=True)
|
2020-04-14 18:30:41 +00:00
|
|
|
|
|
|
|
user_input = {**MOCK_USER_INPUT}
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
|
|
|
data=user_input,
|
2020-04-14 18:30:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "ipp_version_error"
|
|
|
|
|
|
|
|
|
|
|
|
async def test_zeroconf_ipp_version_error(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we abort zeroconf flow on IPP version not supported error."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock, version_not_supported=True)
|
2020-04-14 18:30:41 +00:00
|
|
|
|
2021-11-23 21:59:36 +00:00
|
|
|
discovery_info = dataclasses.replace(MOCK_ZEROCONF_IPP_SERVICE_INFO)
|
2020-04-14 18:30:41 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_ZEROCONF},
|
|
|
|
data=discovery_info,
|
2020-04-14 18:30:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["type"] == RESULT_TYPE_ABORT
|
|
|
|
assert result["reason"] == "ipp_version_error"
|
|
|
|
|
|
|
|
|
2020-03-30 23:13:47 +00:00
|
|
|
async def test_user_device_exists_abort(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we abort user flow if printer already configured."""
|
2020-08-02 23:02:47 +00:00
|
|
|
await init_integration(hass, aioclient_mock, skip_setup=True)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
user_input = MOCK_USER_INPUT.copy()
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
|
|
|
data=user_input,
|
2020-03-30 23:13:47 +00:00
|
|
|
)
|
|
|
|
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_ABORT
|
2020-03-30 23:13:47 +00:00
|
|
|
assert result["reason"] == "already_configured"
|
|
|
|
|
|
|
|
|
|
|
|
async def test_zeroconf_device_exists_abort(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we abort zeroconf flow if printer already configured."""
|
2020-08-02 23:02:47 +00:00
|
|
|
await init_integration(hass, aioclient_mock, skip_setup=True)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2021-11-23 21:59:36 +00:00
|
|
|
discovery_info = dataclasses.replace(MOCK_ZEROCONF_IPP_SERVICE_INFO)
|
2020-03-30 23:13:47 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_ZEROCONF},
|
|
|
|
data=discovery_info,
|
2020-03-30 23:13:47 +00:00
|
|
|
)
|
|
|
|
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_ABORT
|
2020-03-30 23:13:47 +00:00
|
|
|
assert result["reason"] == "already_configured"
|
|
|
|
|
|
|
|
|
|
|
|
async def test_zeroconf_with_uuid_device_exists_abort(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test we abort zeroconf flow if printer already configured."""
|
2020-08-02 23:02:47 +00:00
|
|
|
await init_integration(hass, aioclient_mock, skip_setup=True)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2021-11-23 21:59:36 +00:00
|
|
|
discovery_info = dataclasses.replace(MOCK_ZEROCONF_IPP_SERVICE_INFO)
|
|
|
|
discovery_info.properties = {
|
|
|
|
**MOCK_ZEROCONF_IPP_SERVICE_INFO[zeroconf.ATTR_PROPERTIES],
|
|
|
|
"UUID": "cfe92100-67c4-11d4-a45f-f8d027761251",
|
2020-04-16 21:12:26 +00:00
|
|
|
}
|
2021-11-23 21:59:36 +00:00
|
|
|
|
2020-03-30 23:13:47 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_ZEROCONF},
|
|
|
|
data=discovery_info,
|
2020-03-30 23:13:47 +00:00
|
|
|
)
|
|
|
|
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_ABORT
|
2020-03-30 23:13:47 +00:00
|
|
|
assert result["reason"] == "already_configured"
|
|
|
|
|
|
|
|
|
2020-06-15 11:38:38 +00:00
|
|
|
async def test_zeroconf_empty_unique_id(
|
2020-05-23 18:02:49 +00:00
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
2020-06-15 11:38:38 +00:00
|
|
|
"""Test zeroconf flow if printer lacks (empty) unique identification."""
|
2020-05-23 18:02:49 +00:00
|
|
|
mock_connection(aioclient_mock, no_unique_id=True)
|
|
|
|
|
2021-11-23 21:59:36 +00:00
|
|
|
discovery_info = dataclasses.replace(MOCK_ZEROCONF_IPP_SERVICE_INFO)
|
|
|
|
discovery_info.properties = {
|
|
|
|
**MOCK_ZEROCONF_IPP_SERVICE_INFO[zeroconf.ATTR_PROPERTIES],
|
|
|
|
"UUID": "",
|
2020-05-23 18:02:49 +00:00
|
|
|
}
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_ZEROCONF},
|
|
|
|
data=discovery_info,
|
2020-05-23 18:02:49 +00:00
|
|
|
)
|
|
|
|
|
2020-06-15 11:38:38 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_FORM
|
2020-05-23 18:02:49 +00:00
|
|
|
|
|
|
|
|
2020-06-15 11:38:38 +00:00
|
|
|
async def test_zeroconf_no_unique_id(
|
2020-05-16 08:48:36 +00:00
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
2020-06-15 11:38:38 +00:00
|
|
|
"""Test zeroconf flow if printer lacks unique identification."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock, no_unique_id=True)
|
|
|
|
|
2021-11-23 21:59:36 +00:00
|
|
|
discovery_info = dataclasses.replace(MOCK_ZEROCONF_IPP_SERVICE_INFO)
|
2020-05-16 08:48:36 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_ZEROCONF},
|
|
|
|
data=discovery_info,
|
2020-05-16 08:48:36 +00:00
|
|
|
)
|
|
|
|
|
2020-06-15 11:38:38 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_FORM
|
2020-05-16 08:48:36 +00:00
|
|
|
|
|
|
|
|
2020-03-30 23:13:47 +00:00
|
|
|
async def test_full_user_flow_implementation(
|
|
|
|
hass: HomeAssistant, aioclient_mock
|
|
|
|
) -> None:
|
|
|
|
"""Test the full manual user flow from start to finish."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_USER},
|
2020-03-30 23:13:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert result["step_id"] == "user"
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_FORM
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2021-04-16 16:23:27 +00:00
|
|
|
with patch("homeassistant.components.ipp.async_setup_entry", return_value=True):
|
2020-07-03 18:43:13 +00:00
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"],
|
|
|
|
user_input={CONF_HOST: "192.168.1.31", CONF_BASE_PATH: "/ipp/print"},
|
|
|
|
)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
|
2020-04-04 05:36:46 +00:00
|
|
|
assert result["title"] == "192.168.1.31"
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
assert result["data"]
|
2020-04-04 05:36:46 +00:00
|
|
|
assert result["data"][CONF_HOST] == "192.168.1.31"
|
2020-03-30 23:13:47 +00:00
|
|
|
assert result["data"][CONF_UUID] == "cfe92100-67c4-11d4-a45f-f8d027761251"
|
|
|
|
|
2020-04-16 21:12:26 +00:00
|
|
|
assert result["result"]
|
|
|
|
assert result["result"].unique_id == "cfe92100-67c4-11d4-a45f-f8d027761251"
|
|
|
|
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
async def test_full_zeroconf_flow_implementation(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test the full manual user flow from start to finish."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2021-11-23 21:59:36 +00:00
|
|
|
discovery_info = dataclasses.replace(MOCK_ZEROCONF_IPP_SERVICE_INFO)
|
2020-03-31 23:40:07 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_ZEROCONF},
|
|
|
|
data=discovery_info,
|
2020-03-31 23:40:07 +00:00
|
|
|
)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
assert result["step_id"] == "zeroconf_confirm"
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_FORM
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2021-04-16 16:23:27 +00:00
|
|
|
with patch("homeassistant.components.ipp.async_setup_entry", return_value=True):
|
2020-07-03 18:43:13 +00:00
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input={}
|
|
|
|
)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
|
2020-04-16 21:12:26 +00:00
|
|
|
assert result["title"] == "EPSON XP-6000 Series"
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
assert result["data"]
|
2020-04-04 05:36:46 +00:00
|
|
|
assert result["data"][CONF_HOST] == "192.168.1.31"
|
2020-04-16 21:12:26 +00:00
|
|
|
assert result["data"][CONF_NAME] == "EPSON XP-6000 Series"
|
2020-03-30 23:13:47 +00:00
|
|
|
assert result["data"][CONF_UUID] == "cfe92100-67c4-11d4-a45f-f8d027761251"
|
|
|
|
assert not result["data"][CONF_SSL]
|
|
|
|
|
2020-04-16 21:12:26 +00:00
|
|
|
assert result["result"]
|
|
|
|
assert result["result"].unique_id == "cfe92100-67c4-11d4-a45f-f8d027761251"
|
|
|
|
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
async def test_full_zeroconf_tls_flow_implementation(
|
|
|
|
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
|
|
|
) -> None:
|
|
|
|
"""Test the full manual user flow from start to finish."""
|
2020-05-16 08:48:36 +00:00
|
|
|
mock_connection(aioclient_mock, ssl=True)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2021-11-23 21:59:36 +00:00
|
|
|
discovery_info = dataclasses.replace(MOCK_ZEROCONF_IPPS_SERVICE_INFO)
|
2020-03-31 23:40:07 +00:00
|
|
|
result = await hass.config_entries.flow.async_init(
|
2020-08-27 11:56:20 +00:00
|
|
|
DOMAIN,
|
|
|
|
context={"source": SOURCE_ZEROCONF},
|
|
|
|
data=discovery_info,
|
2020-03-31 23:40:07 +00:00
|
|
|
)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
assert result["step_id"] == "zeroconf_confirm"
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_FORM
|
2020-04-16 21:12:26 +00:00
|
|
|
assert result["description_placeholders"] == {CONF_NAME: "EPSON XP-6000 Series"}
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2021-04-16 16:23:27 +00:00
|
|
|
with patch("homeassistant.components.ipp.async_setup_entry", return_value=True):
|
2020-07-03 18:43:13 +00:00
|
|
|
result = await hass.config_entries.flow.async_configure(
|
|
|
|
result["flow_id"], user_input={}
|
|
|
|
)
|
2020-03-30 23:13:47 +00:00
|
|
|
|
2020-03-31 23:40:07 +00:00
|
|
|
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
|
2020-04-16 21:12:26 +00:00
|
|
|
assert result["title"] == "EPSON XP-6000 Series"
|
2020-03-30 23:13:47 +00:00
|
|
|
|
|
|
|
assert result["data"]
|
2020-04-04 05:36:46 +00:00
|
|
|
assert result["data"][CONF_HOST] == "192.168.1.31"
|
2020-04-16 21:12:26 +00:00
|
|
|
assert result["data"][CONF_NAME] == "EPSON XP-6000 Series"
|
2020-03-30 23:13:47 +00:00
|
|
|
assert result["data"][CONF_UUID] == "cfe92100-67c4-11d4-a45f-f8d027761251"
|
|
|
|
assert result["data"][CONF_SSL]
|
2020-04-16 21:12:26 +00:00
|
|
|
|
|
|
|
assert result["result"]
|
|
|
|
assert result["result"].unique_id == "cfe92100-67c4-11d4-a45f-f8d027761251"
|