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
9 changes: 6 additions & 3 deletions airos/airos8.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ async def login(self) -> bool:
if not airos_cookie_found and not ok_cookie_found:
raise DataMissingError from None

response_text = await response.text()

if response.status == 200:
try:
json.loads(response.text)
json.loads(response_text)
self.connected = True
return True
except json.JSONDecodeError as err:
Expand Down Expand Up @@ -191,14 +193,15 @@ async def status(self) -> dict:
) as response:
if response.status == 200:
try:
return json.loads(response.text)
response_text = await response.text()
return json.loads(response_text)
except json.JSONDecodeError:
logger.exception(
"JSON Decode Error in authenticated status response"
)
raise DataMissingError from None
else:
log = f"Authenticated status.cgi failed: {response.status}. Response: {response.text}"
log = f"Authenticated status.cgi failed: {response.status}. Response: {response_text}"
logger.error(log)
except aiohttp.ClientError as err:
logger.exception("Error during authenticated status.cgi call")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "airos"
version = "0.0.6"
version = "0.0.7"
license = "MIT"
description = "Ubiquity airOS module(s) for Python 3."
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_stations.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def test_ap(airos_device, base_url, mode):
# --- Prepare fake POST /api/auth response with cookies ---
mock_login_response = MagicMock()
mock_login_response.__aenter__.return_value = mock_login_response
mock_login_response.text = "{}"
mock_login_response.text = AsyncMock(return_value="{}")
mock_login_response.status = 200
mock_login_response.cookies = cookie
mock_login_response.headers = {"X-CSRF-ID": "test-csrf-token"}
Expand All @@ -43,7 +43,7 @@ async def test_ap(airos_device, base_url, mode):
mock_status_payload = fixture_data
mock_status_response = MagicMock()
mock_status_response.__aenter__.return_value = mock_status_response
mock_status_response.text = json.dumps(fixture_data)
mock_status_response.text = AsyncMock(return_value=json.dumps(fixture_data))
mock_status_response.status = 200
mock_status_response.json = AsyncMock(return_value=mock_status_payload)

Expand Down