Skip to content

Commit 78a0154

Browse files
committed
Revert back to text as a function
1 parent f5f57cb commit 78a0154

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

airos/airos8.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,11 @@ async def login(self) -> bool:
156156
if not airos_cookie_found and not ok_cookie_found:
157157
raise DataMissingError from None
158158

159+
response_text = await response.text()
160+
159161
if response.status == 200:
160162
try:
161-
json.loads(response.text)
163+
json.loads(response_text)
162164
self.connected = True
163165
return True
164166
except json.JSONDecodeError as err:
@@ -191,14 +193,15 @@ async def status(self) -> dict:
191193
) as response:
192194
if response.status == 200:
193195
try:
194-
return json.loads(response.text)
196+
response_text = await response.text()
197+
return json.loads(response_text)
195198
except json.JSONDecodeError:
196199
logger.exception(
197200
"JSON Decode Error in authenticated status response"
198201
)
199202
raise DataMissingError from None
200203
else:
201-
log = f"Authenticated status.cgi failed: {response.status}. Response: {response.text}"
204+
log = f"Authenticated status.cgi failed: {response.status}. Response: {response_text}"
202205
logger.error(log)
203206
except aiohttp.ClientError as err:
204207
logger.exception("Error during authenticated status.cgi call")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "airos"
7-
version = "0.0.6"
7+
version = "0.0.7"
88
license = "MIT"
99
description = "Ubiquity airOS module(s) for Python 3."
1010
readme = "README.md"

tests/test_stations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async def test_ap(airos_device, base_url, mode):
3434
# --- Prepare fake POST /api/auth response with cookies ---
3535
mock_login_response = MagicMock()
3636
mock_login_response.__aenter__.return_value = mock_login_response
37-
mock_login_response.text = "{}"
37+
mock_login_response.text = AsyncMock(return_value="{}")
3838
mock_login_response.status = 200
3939
mock_login_response.cookies = cookie
4040
mock_login_response.headers = {"X-CSRF-ID": "test-csrf-token"}
@@ -43,7 +43,7 @@ async def test_ap(airos_device, base_url, mode):
4343
mock_status_payload = fixture_data
4444
mock_status_response = MagicMock()
4545
mock_status_response.__aenter__.return_value = mock_status_response
46-
mock_status_response.text = json.dumps(fixture_data)
46+
mock_status_response.text = AsyncMock(return_value=json.dumps(fixture_data))
4747
mock_status_response.status = 200
4848
mock_status_response.json = AsyncMock(return_value=mock_status_payload)
4949

0 commit comments

Comments
 (0)