Skip to content

Commit 396e0b6

Browse files
authored
Merge pull request #24 from CoMPaTech/testing
Drop JSON output
2 parents f571942 + e401a03 commit 396e0b6

File tree

3 files changed

+2
-39
lines changed

3 files changed

+2
-39
lines changed

airos/airos8.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ async def login(self) -> bool:
187187
logger.exception("Error during login")
188188
raise DeviceConnectionError from err
189189

190-
async def status(self, return_json: bool = False) -> dict | AirOSData:
190+
async def status(self) -> AirOSData:
191191
"""Retrieve status from the device."""
192192
if not self.connected:
193193
logger.error("Not connected, login first")
@@ -220,8 +220,6 @@ async def status(self, return_json: bool = False) -> dict | AirOSData:
220220
log = f"AirOS data warning for field '{field_name}': {msg}"
221221
logger.warning(log)
222222

223-
if return_json:
224-
return response_json
225223
return airos_data
226224
except json.JSONDecodeError:
227225
logger.exception(

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.1.2"
7+
version = "0.1.3"
88
license = "MIT"
99
description = "Ubiquity airOS module(s) for Python 3."
1010
readme = "README.md"

tests/test_stations.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,6 @@ async def _read_fixture(fixture: str = "ap-ptp"):
2626
pytest.fail(f"Invalid JSON in fixture file {path}: {e}")
2727

2828

29-
@pytest.mark.parametrize("mode", ["ap-ptp", "sta-ptp"])
30-
@pytest.mark.asyncio
31-
async def test_ap_json(airos_device, base_url, mode):
32-
"""Test device operation."""
33-
cookie = SimpleCookie()
34-
cookie["session_id"] = "test-cookie"
35-
cookie["AIROS_TOKEN"] = "abc123"
36-
37-
# --- Prepare fake POST /api/auth response with cookies ---
38-
mock_login_response = MagicMock()
39-
mock_login_response.__aenter__.return_value = mock_login_response
40-
mock_login_response.text = AsyncMock(return_value="{}")
41-
mock_login_response.status = 200
42-
mock_login_response.cookies = cookie
43-
mock_login_response.headers = {"X-CSRF-ID": "test-csrf-token"}
44-
# --- Prepare fake GET /api/status response ---
45-
fixture_data = await _read_fixture(mode)
46-
mock_status_payload = fixture_data
47-
mock_status_response = MagicMock()
48-
mock_status_response.__aenter__.return_value = mock_status_response
49-
mock_status_response.text = AsyncMock(return_value=json.dumps(fixture_data))
50-
mock_status_response.status = 200
51-
mock_status_response.json = AsyncMock(return_value=mock_status_payload)
52-
53-
with (
54-
patch.object(airos_device.session, "post", return_value=mock_login_response),
55-
patch.object(airos_device.session, "get", return_value=mock_status_response),
56-
):
57-
assert await airos_device.login()
58-
status = await airos_device.status(return_json=True)
59-
60-
# Verify the fixture returns the correct mode
61-
assert status.get("wireless", {}).get("mode") == mode
62-
63-
6429
@pytest.mark.parametrize("mode", ["ap-ptp", "sta-ptp"])
6530
@pytest.mark.asyncio
6631
async def test_ap_object(airos_device, base_url, mode):

0 commit comments

Comments
 (0)