Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions airos/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(
username: str,
password: str,
session: aiohttp.ClientSession,
*,
use_ssl: bool = True,
):
"""Initialize AirOS class."""
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion airos/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 3 additions & 5 deletions tests/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down