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
4 changes: 1 addition & 3 deletions airos/airos8.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async def login(self) -> bool:
logger.exception("Error during login")
raise DeviceConnectionError from err

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

if return_json:
return response_json
return airos_data
except json.JSONDecodeError:
logger.exception(
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.1.2"
version = "0.1.3"
license = "MIT"
description = "Ubiquity airOS module(s) for Python 3."
readme = "README.md"
Expand Down
35 changes: 0 additions & 35 deletions tests/test_stations.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,6 @@ async def _read_fixture(fixture: str = "ap-ptp"):
pytest.fail(f"Invalid JSON in fixture file {path}: {e}")


@pytest.mark.parametrize("mode", ["ap-ptp", "sta-ptp"])
@pytest.mark.asyncio
async def test_ap_json(airos_device, base_url, mode):
"""Test device operation."""
cookie = SimpleCookie()
cookie["session_id"] = "test-cookie"
cookie["AIROS_TOKEN"] = "abc123"

# --- 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 = AsyncMock(return_value="{}")
mock_login_response.status = 200
mock_login_response.cookies = cookie
mock_login_response.headers = {"X-CSRF-ID": "test-csrf-token"}
# --- Prepare fake GET /api/status response ---
fixture_data = await _read_fixture(mode)
mock_status_payload = fixture_data
mock_status_response = MagicMock()
mock_status_response.__aenter__.return_value = mock_status_response
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)

with (
patch.object(airos_device.session, "post", return_value=mock_login_response),
patch.object(airos_device.session, "get", return_value=mock_status_response),
):
assert await airos_device.login()
status = await airos_device.status(return_json=True)

# Verify the fixture returns the correct mode
assert status.get("wireless", {}).get("mode") == mode


@pytest.mark.parametrize("mode", ["ap-ptp", "sta-ptp"])
@pytest.mark.asyncio
async def test_ap_object(airos_device, base_url, mode):
Expand Down