From a54e5237311b34294d254bfce431dbd37cbe1ef2 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Wed, 22 Feb 2023 00:41:46 +0100 Subject: [PATCH] Bump `nettigo-air-monitor` to version 2.1.0 (#88569) Co-authored-by: J. Nick Koston --- homeassistant/components/nam/__init__.py | 8 ++++---- homeassistant/components/nam/config_flow.py | 17 +++++++++++------ homeassistant/components/nam/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/nam/test_config_flow.py | 12 ++++++------ tests/components/nam/test_init.py | 4 ++-- 7 files changed, 26 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/nam/__init__.py b/homeassistant/components/nam/__init__.py index c035184c37b..c011bdfa427 100644 --- a/homeassistant/components/nam/__init__.py +++ b/homeassistant/components/nam/__init__.py @@ -9,9 +9,9 @@ from aiohttp.client_exceptions import ClientConnectorError, ClientError import async_timeout from nettigo_air_monitor import ( ApiError, - AuthFailed, + AuthFailedError, ConnectionOptions, - InvalidSensorData, + InvalidSensorDataError, NAMSensors, NettigoAirMonitor, ) @@ -58,7 +58,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: await nam.async_check_credentials() except ApiError as err: raise ConfigEntryNotReady from err - except AuthFailed as err: + except AuthFailedError as err: raise ConfigEntryAuthFailed from err coordinator = NAMDataUpdateCoordinator(hass, nam, entry.unique_id) @@ -116,7 +116,7 @@ class NAMDataUpdateCoordinator(DataUpdateCoordinator[NAMSensors]): data = await self.nam.async_update() # We do not need to catch AuthFailed exception here because sensor data is # always available without authorization. - except (ApiError, ClientConnectorError, InvalidSensorData) as error: + except (ApiError, ClientConnectorError, InvalidSensorDataError) as error: raise UpdateFailed(error) from error return data diff --git a/homeassistant/components/nam/config_flow.py b/homeassistant/components/nam/config_flow.py index 6cf9dd55451..eef4c33e5f0 100644 --- a/homeassistant/components/nam/config_flow.py +++ b/homeassistant/components/nam/config_flow.py @@ -11,8 +11,8 @@ from aiohttp.client_exceptions import ClientConnectorError import async_timeout from nettigo_air_monitor import ( ApiError, - AuthFailed, - CannotGetMac, + AuthFailedError, + CannotGetMacError, ConnectionOptions, NettigoAirMonitor, ) @@ -95,7 +95,7 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): config = await async_get_config(self.hass, self.host) except (ApiError, ClientConnectorError, asyncio.TimeoutError): errors["base"] = "cannot_connect" - except CannotGetMac: + except CannotGetMacError: return self.async_abort(reason="device_unsupported") except Exception: # pylint: disable=broad-except _LOGGER.exception("Unexpected exception") @@ -127,7 +127,7 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): if user_input is not None: try: await async_check_credentials(self.hass, self.host, user_input) - except AuthFailed: + except AuthFailedError: errors["base"] = "invalid_auth" except (ApiError, ClientConnectorError, asyncio.TimeoutError): errors["base"] = "cannot_connect" @@ -158,7 +158,7 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): self._config = await async_get_config(self.hass, self.host) except (ApiError, ClientConnectorError, asyncio.TimeoutError): return self.async_abort(reason="cannot_connect") - except CannotGetMac: + except CannotGetMacError: return self.async_abort(reason="device_unsupported") await self.async_set_unique_id(format_mac(self._config.mac_address)) @@ -206,7 +206,12 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): if user_input is not None: try: await async_check_credentials(self.hass, self.host, user_input) - except (ApiError, AuthFailed, ClientConnectorError, asyncio.TimeoutError): + except ( + ApiError, + AuthFailedError, + ClientConnectorError, + asyncio.TimeoutError, + ): return self.async_abort(reason="reauth_unsuccessful") self.hass.config_entries.async_update_entry( diff --git a/homeassistant/components/nam/manifest.json b/homeassistant/components/nam/manifest.json index fe53f137eed..32f7329a0a2 100644 --- a/homeassistant/components/nam/manifest.json +++ b/homeassistant/components/nam/manifest.json @@ -8,7 +8,7 @@ "iot_class": "local_polling", "loggers": ["nettigo_air_monitor"], "quality_scale": "platinum", - "requirements": ["nettigo-air-monitor==2.0.0"], + "requirements": ["nettigo-air-monitor==2.1.0"], "zeroconf": [ { "type": "_http._tcp.local.", diff --git a/requirements_all.txt b/requirements_all.txt index 64efb65e1c9..19ad3fcd42b 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1183,7 +1183,7 @@ netdisco==3.0.0 netmap==0.7.0.2 # homeassistant.components.nam -nettigo-air-monitor==2.0.0 +nettigo-air-monitor==2.1.0 # homeassistant.components.neurio_energy neurio==0.3.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 9f55743de21..a3274053736 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -879,7 +879,7 @@ netdisco==3.0.0 netmap==0.7.0.2 # homeassistant.components.nam -nettigo-air-monitor==2.0.0 +nettigo-air-monitor==2.1.0 # homeassistant.components.nexia nexia==2.0.6 diff --git a/tests/components/nam/test_config_flow.py b/tests/components/nam/test_config_flow.py index 3fd2c614f6d..9aafcae2482 100644 --- a/tests/components/nam/test_config_flow.py +++ b/tests/components/nam/test_config_flow.py @@ -2,7 +2,7 @@ import asyncio from unittest.mock import patch -from nettigo_air_monitor import ApiError, AuthFailed, CannotGetMac +from nettigo_air_monitor import ApiError, AuthFailedError, CannotGetMacError import pytest from homeassistant import data_entry_flow @@ -169,7 +169,7 @@ async def test_reauth_unsuccessful(hass: HomeAssistant) -> None: "error", [ (ApiError("API Error"), "cannot_connect"), - (AuthFailed("Auth Error"), "invalid_auth"), + (AuthFailedError("Auth Error"), "invalid_auth"), (asyncio.TimeoutError, "cannot_connect"), (ValueError, "unknown"), ], @@ -179,7 +179,7 @@ async def test_form_with_auth_errors(hass: HomeAssistant, error) -> None: exc, base_error = error with patch( "homeassistant.components.nam.NettigoAirMonitor.async_check_credentials", - side_effect=AuthFailed("Auth Error"), + side_effect=AuthFailedError("Auth Error"), ), patch( "homeassistant.components.nam.NettigoAirMonitor.async_get_mac_address", return_value="aa:bb:cc:dd:ee:ff", @@ -236,7 +236,7 @@ async def test_form_abort(hass: HomeAssistant) -> None: return_value=DEVICE_CONFIG, ), patch( "homeassistant.components.nam.NettigoAirMonitor.async_get_mac_address", - side_effect=CannotGetMac("Cannot get MAC address from device"), + side_effect=CannotGetMacError("Cannot get MAC address from device"), ): result = await hass.config_entries.flow.async_init( DOMAIN, @@ -323,7 +323,7 @@ async def test_zeroconf_with_auth(hass: HomeAssistant) -> None: """Test that the zeroconf step with auth works.""" with patch( "homeassistant.components.nam.NettigoAirMonitor.async_check_credentials", - side_effect=AuthFailed("Auth Error"), + side_effect=AuthFailedError("Auth Error"), ), patch( "homeassistant.components.nam.NettigoAirMonitor.async_get_mac_address", return_value="aa:bb:cc:dd:ee:ff", @@ -388,7 +388,7 @@ async def test_zeroconf_host_already_configured(hass: HomeAssistant) -> None: "error", [ (ApiError("API Error"), "cannot_connect"), - (CannotGetMac("Cannot get MAC address from device"), "device_unsupported"), + (CannotGetMacError("Cannot get MAC address from device"), "device_unsupported"), ], ) async def test_zeroconf_errors(hass: HomeAssistant, error) -> None: diff --git a/tests/components/nam/test_init.py b/tests/components/nam/test_init.py index 23e8275df22..24aaee1acb3 100644 --- a/tests/components/nam/test_init.py +++ b/tests/components/nam/test_init.py @@ -1,7 +1,7 @@ """Test init of Nettigo Air Monitor integration.""" from unittest.mock import patch -from nettigo_air_monitor import ApiError, AuthFailed +from nettigo_air_monitor import ApiError, AuthFailedError from homeassistant.components.air_quality import DOMAIN as AIR_QUALITY_PLATFORM from homeassistant.components.nam.const import DOMAIN @@ -73,7 +73,7 @@ async def test_config_auth_failed(hass: HomeAssistant) -> None: with patch( "homeassistant.components.nam.NettigoAirMonitor.async_check_credentials", - side_effect=AuthFailed("Authorization has failed"), + side_effect=AuthFailedError("Authorization has failed"), ): await hass.config_entries.async_setup(entry.entry_id) assert entry.state is ConfigEntryState.SETUP_ERROR