Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def test_discovery_response_empty() -> None:
"""Test an empty discovery returns an empty list."""
session = Mock()
with patch("pydeconz.utils.async_request", new=CoroutineMock(return_value={})):
response = await utils.async_discovery(session)
assert not response
If no bridge is found allow user to manually input configuration.
"""
if user_input is not None:
for bridge in self.bridges:
if bridge[CONF_HOST] == user_input[CONF_HOST]:
self.deconz_config = bridge
return await self.async_step_link()
self.deconz_config = user_input
return await self.async_step_link()
session = aiohttp_client.async_get_clientsession(self.hass)
try:
with async_timeout.timeout(10):
self.bridges = await async_discovery(session)
except (asyncio.TimeoutError, ResponseError):
self.bridges = []
if len(self.bridges) == 1:
self.deconz_config = self.bridges[0]
return await self.async_step_link()
if len(self.bridges) > 1:
hosts = []
for bridge in self.bridges:
hosts.append(bridge[CONF_HOST])
return self.async_show_form(
step_id="init",