Bump aiounifi to v58 (#99103)

pull/99117/head
Robert Svensson 2023-08-27 01:27:45 +02:00 committed by GitHub
parent a81e6d5811
commit 45efe29262
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 23 deletions

View File

@ -10,6 +10,7 @@ from typing import Any
from aiohttp import CookieJar
import aiounifi
from aiounifi.interfaces.api_handlers import ItemEvent
from aiounifi.models.configuration import Configuration
from aiounifi.websocket import WebsocketState
from homeassistant.config_entries import ConfigEntry
@ -409,18 +410,19 @@ async def get_unifi_controller(
)
controller = aiounifi.Controller(
host=config[CONF_HOST],
username=config[CONF_USERNAME],
password=config[CONF_PASSWORD],
port=config[CONF_PORT],
site=config[CONF_SITE_ID],
websession=session,
ssl_context=ssl_context,
Configuration(
session,
host=config[CONF_HOST],
username=config[CONF_USERNAME],
password=config[CONF_PASSWORD],
port=config[CONF_PORT],
site=config[CONF_SITE_ID],
ssl_context=ssl_context,
)
)
try:
async with asyncio.timeout(10):
await controller.check_unifi_os()
await controller.login()
return controller

View File

@ -8,7 +8,7 @@
"iot_class": "local_push",
"loggers": ["aiounifi"],
"quality_scale": "platinum",
"requirements": ["aiounifi==55"],
"requirements": ["aiounifi==58"],
"ssdp": [
{
"manufacturer": "Ubiquiti Networks",

View File

@ -360,7 +360,7 @@ aiosyncthing==0.5.1
aiotractive==0.5.5
# homeassistant.components.unifi
aiounifi==55
aiounifi==58
# homeassistant.components.vlc_telnet
aiovlc==0.1.0

View File

@ -335,7 +335,7 @@ aiosyncthing==0.5.1
aiotractive==0.5.5
# homeassistant.components.unifi
aiounifi==55
aiounifi==58
# homeassistant.components.vlc_telnet
aiovlc==0.1.0

View File

@ -395,9 +395,7 @@ async def test_reconnect_mechanism(
await setup_unifi_integration(hass, aioclient_mock)
aioclient_mock.clear_requests()
aioclient_mock.post(
f"https://{DEFAULT_HOST}:1234/api/login", status=HTTPStatus.BAD_GATEWAY
)
aioclient_mock.get(f"https://{DEFAULT_HOST}:1234/", status=HTTPStatus.BAD_GATEWAY)
mock_unifi_websocket(state=WebsocketState.DISCONNECTED)
await hass.async_block_till_done()
@ -448,9 +446,7 @@ async def test_reconnect_mechanism_exceptions(
async def test_get_unifi_controller(hass: HomeAssistant) -> None:
"""Successful call."""
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", return_value=True
):
with patch("aiounifi.Controller.login", return_value=True):
assert await get_unifi_controller(hass, ENTRY_CONFIG)
@ -458,9 +454,7 @@ async def test_get_unifi_controller_verify_ssl_false(hass: HomeAssistant) -> Non
"""Successful call with verify ssl set to false."""
controller_data = dict(ENTRY_CONFIG)
controller_data[CONF_VERIFY_SSL] = False
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", return_value=True
):
with patch("aiounifi.Controller.login", return_value=True):
assert await get_unifi_controller(hass, controller_data)
@ -481,7 +475,7 @@ async def test_get_unifi_controller_fails_to_connect(
hass: HomeAssistant, side_effect, raised_exception
) -> None:
"""Check that get_unifi_controller can handle controller being unavailable."""
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", side_effect=side_effect
), pytest.raises(raised_exception):
with patch("aiounifi.Controller.login", side_effect=side_effect), pytest.raises(
raised_exception
):
await get_unifi_controller(hass, ENTRY_CONFIG)