Catch IPPParseError during config flow (#33769)

* Update config_flow.py

* Update strings.json

* Update config_flow.py

* squash.
This commit is contained in:
Chris Talkington authored and Paulus Schoutsen committed 2020-04-07 10:22:04 -07:00
1 parent a33e5728de
commit abdee3fcb7
6 files changed
+59 -8

No files matched your search

+38
View File
@@ -134,6 +134,44 @@ async def test_zeroconf_connection_upgrade_required(
assert result["reason"] == "connection_upgrade"
async def test_user_parse_error(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we abort user flow on IPP parse error."""
aioclient_mock.post(
"http://192.168.1.31:631/ipp/print",
content="BAD",
headers={"Content-Type": "application/ipp"},
)
user_input = MOCK_USER_INPUT.copy()
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=user_input,
)
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."""
aioclient_mock.post(
"http://192.168.1.31:631/ipp/print",
content="BAD",
headers={"Content-Type": "application/ipp"},
)
discovery_info = MOCK_ZEROCONF_IPP_SERVICE_INFO.copy()
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info,
)
assert result["type"] == RESULT_TYPE_ABORT
assert result["reason"] == "parse_error"
async def test_user_device_exists_abort(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None: