diff --git a/airos/base.py b/airos/base.py index de2eee3..f206886 100644 --- a/airos/base.py +++ b/airos/base.py @@ -50,6 +50,7 @@ def __init__( username: str, password: str, session: aiohttp.ClientSession, + *, use_ssl: bool = True, ): """Initialize AirOS class.""" @@ -262,6 +263,7 @@ async def _request_json( self, method: str, url: str, + *, headers: dict[str, Any] | None = None, json_data: dict[str, Any] | None = None, form_data: dict[str, Any] | None = None, diff --git a/airos/discovery.py b/airos/discovery.py index dd0a6ad..cd06352 100644 --- a/airos/discovery.py +++ b/airos/discovery.py @@ -82,7 +82,7 @@ def connection_lost(self, exc: Exception | None) -> None: """Handle connection is lost or closed.""" _LOGGER.debug("AirOSDiscoveryProtocol connection lost.") if exc: - _LOGGER.exception("AirOSDiscoveryProtocol connection lost due to") + _LOGGER.error("AirOSDiscoveryProtocol connection lost due to %s", exc) raise AirOSDiscoveryError from None def parse_airos_packet(self, data: bytes, host_ip: str) -> dict[str, Any] | None: diff --git a/tests/test_discovery.py b/tests/test_discovery.py index bbc25ed..65316e8 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -196,13 +196,11 @@ async def test_connection_lost_with_exception() -> None: protocol = AirOSDiscoveryProtocol(AsyncMock()) test_exception = Exception("Test connection lost error") with ( - patch("airos.discovery._LOGGER.exception") as mock_log_exception, - pytest.raises( - AirOSDiscoveryError - ), # connection_lost now re-raises AirOSDiscoveryError + patch("airos.discovery._LOGGER.error") as mock_log_error, + pytest.raises(AirOSDiscoveryError), ): protocol.connection_lost(test_exception) - mock_log_exception.assert_called_once() + mock_log_error.assert_called_once() @pytest.mark.asyncio