Fix linking issue when deCONZ gateway is not unlocked (#71082)

This commit is contained in:
Robert Svensson 2022-04-30 00:34:33 +02:00 committed by GitHub
parent 865c75b631
commit 7f094a928b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 4 deletions

View file

@ -4,6 +4,7 @@ import asyncio
from unittest.mock import patch
import pydeconz
import pytest
from homeassistant.components import ssdp
from homeassistant.components.deconz.config_flow import (
@ -341,7 +342,16 @@ async def test_manual_configuration_timeout_get_bridge(hass, aioclient_mock):
assert result["reason"] == "no_bridges"
async def test_link_get_api_key_ResponseError(hass, aioclient_mock):
@pytest.mark.parametrize(
"raised_error, error_string",
[
(pydeconz.errors.LinkButtonNotPressed, "linking_not_possible"),
(asyncio.TimeoutError, "no_key"),
(pydeconz.errors.ResponseError, "no_key"),
(pydeconz.errors.RequestError, "no_key"),
],
)
async def test_link_step_fails(hass, aioclient_mock, raised_error, error_string):
"""Test config flow should abort if no API key was possible to retrieve."""
aioclient_mock.get(
pydeconz.utils.URL_DISCOVER,
@ -360,7 +370,7 @@ async def test_link_get_api_key_ResponseError(hass, aioclient_mock):
assert result["type"] == RESULT_TYPE_FORM
assert result["step_id"] == "link"
aioclient_mock.post("http://1.2.3.4:80/api", exc=pydeconz.errors.ResponseError)
aioclient_mock.post("http://1.2.3.4:80/api", exc=raised_error)
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
@ -368,7 +378,7 @@ async def test_link_get_api_key_ResponseError(hass, aioclient_mock):
assert result["type"] == RESULT_TYPE_FORM
assert result["step_id"] == "link"
assert result["errors"] == {"base": "no_key"}
assert result["errors"] == {"base": error_string}
async def test_reauth_flow_update_configuration(hass, aioclient_mock):