From 615ae780ca1925d6f89cd6f130ce6cb8c6fbdea1 Mon Sep 17 00:00:00 2001 From: starkillerOG Date: Wed, 15 May 2024 12:04:12 +0200 Subject: [PATCH] Reolink fix not unregistering webhook during ReAuth (#117490) --- homeassistant/components/reolink/__init__.py | 1 + tests/components/reolink/test_init.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/reolink/__init__.py b/homeassistant/components/reolink/__init__.py index 3196dbf3ad793c..22b616f9f4379e 100644 --- a/homeassistant/components/reolink/__init__.py +++ b/homeassistant/components/reolink/__init__.py @@ -85,6 +85,7 @@ async def async_device_config_update() -> None: try: await host.update_states() except CredentialsInvalidError as err: + await host.stop() raise ConfigEntryAuthFailed(err) from err except ReolinkError as err: raise UpdateFailed(str(err)) from err diff --git a/tests/components/reolink/test_init.py b/tests/components/reolink/test_init.py index 4ec02244c91103..261f572bf2ef43 100644 --- a/tests/components/reolink/test_init.py +++ b/tests/components/reolink/test_init.py @@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, MagicMock, Mock, patch import pytest -from reolink_aio.exceptions import ReolinkError +from reolink_aio.exceptions import CredentialsInvalidError, ReolinkError from homeassistant.components.reolink import FIRMWARE_UPDATE_INTERVAL, const from homeassistant.config import async_process_ha_core_config @@ -50,6 +50,11 @@ AsyncMock(side_effect=ReolinkError("Test error")), ConfigEntryState.SETUP_RETRY, ), + ( + "get_states", + AsyncMock(side_effect=CredentialsInvalidError("Test error")), + ConfigEntryState.SETUP_ERROR, + ), ( "supported", Mock(return_value=False),