Skip to content

Commit aa10da7

Browse files
committed
MyPy
1 parent 8fa8a25 commit aa10da7

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

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.5.0a1"
7+
version = "0.5.0a2"
88
license = "MIT"
99
description = "Ubiquiti airOS module(s) for Python 3."
1010
readme = "README.md"

tests/test_airos6.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
from mashumaro.exceptions import MissingField
99
import pytest
1010

11-
from airos.airos6 import AirOS
11+
from airos.airos6 import AirOS6
1212
import airos.exceptions
1313

1414

1515
@pytest.mark.skip(reason="broken, needs investigation")
1616
@pytest.mark.asyncio
17-
async def test_login_no_csrf_token(airos6_device: AirOS) -> None:
17+
async def test_login_no_csrf_token(airos6_device: AirOS6) -> None:
1818
"""Test login response without a CSRF token header."""
1919
cookie = SimpleCookie()
2020
cookie["AIROS_TOKEN"] = "abc"
@@ -34,7 +34,7 @@ async def test_login_no_csrf_token(airos6_device: AirOS) -> None:
3434

3535

3636
@pytest.mark.asyncio
37-
async def test_login_connection_error(airos6_device: AirOS) -> None:
37+
async def test_login_connection_error(airos6_device: AirOS6) -> None:
3838
"""Test aiohttp ClientError during login attempt."""
3939
with (
4040
patch.object(airos6_device.session, "request", side_effect=aiohttp.ClientError),
@@ -45,7 +45,7 @@ async def test_login_connection_error(airos6_device: AirOS) -> None:
4545

4646
# --- Tests for status() and derived_data() logic ---
4747
@pytest.mark.asyncio
48-
async def test_status_when_not_connected(airos6_device: AirOS) -> None:
48+
async def test_status_when_not_connected(airos6_device: AirOS6) -> None:
4949
"""Test calling status() before a successful login."""
5050
airos6_device.connected = False # Ensure connected state is false
5151
with pytest.raises(airos.exceptions.AirOSDeviceConnectionError):
@@ -55,7 +55,7 @@ async def test_status_when_not_connected(airos6_device: AirOS) -> None:
5555
# pylint: disable=pointless-string-statement
5656
'''
5757
@pytest.mark.asyncio
58-
async def test_status_non_200_response(airos6_device: AirOS) -> None:
58+
async def test_status_non_200_response(airos6_device: AirOS6) -> None:
5959
"""Test status() with a non-successful HTTP response."""
6060
airos6_device.connected = True
6161
mock_status_response = MagicMock()
@@ -72,7 +72,7 @@ async def test_status_non_200_response(airos6_device: AirOS) -> None:
7272

7373

7474
@pytest.mark.asyncio
75-
async def test_status_invalid_json_response(airos6_device: AirOS) -> None:
75+
async def test_status_invalid_json_response(airos6_device: AirOS6) -> None:
7676
"""Test status() with a response that is not valid JSON."""
7777
airos6_device.connected = True
7878
mock_status_response = MagicMock()
@@ -90,7 +90,7 @@ async def test_status_invalid_json_response(airos6_device: AirOS) -> None:
9090

9191

9292
@pytest.mark.asyncio
93-
async def test_status_missing_interface_key_data(airos6_device: AirOS) -> None:
93+
async def test_status_missing_interface_key_data(airos6_device: AirOS6) -> None:
9494
"""Test status() with a response missing critical data fields."""
9595
airos6_device.connected = True
9696
# The derived_data() function is called with a mocked response
@@ -111,15 +111,15 @@ async def test_status_missing_interface_key_data(airos6_device: AirOS) -> None:
111111

112112

113113
@pytest.mark.asyncio
114-
async def test_derived_data_no_interfaces_key(airos6_device: AirOS) -> None:
114+
async def test_derived_data_no_interfaces_key(airos6_device: AirOS6) -> None:
115115
"""Test derived_data() with a response that has no 'interfaces' key."""
116116
# This will directly test the 'if not interfaces:' branch (line 206)
117117
with pytest.raises(airos.exceptions.AirOSKeyDataMissingError):
118118
airos6_device.derived_data({})
119119

120120

121121
@pytest.mark.asyncio
122-
async def test_derived_data_no_br0_eth0_ath0(airos6_device: AirOS) -> None:
122+
async def test_derived_data_no_br0_eth0_ath0(airos6_device: AirOS6) -> None:
123123
"""Test derived_data() with an unexpected interface list, to test the fallback logic."""
124124
fixture_data = {
125125
"interfaces": [
@@ -134,7 +134,7 @@ async def test_derived_data_no_br0_eth0_ath0(airos6_device: AirOS) -> None:
134134

135135
@pytest.mark.skip(reason="broken, needs investigation")
136136
@pytest.mark.asyncio
137-
async def test_status_missing_required_key_in_json(airos6_device: AirOS) -> None:
137+
async def test_status_missing_required_key_in_json(airos6_device: AirOS6) -> None:
138138
"""Test status() with a response missing a key required by the dataclass."""
139139
airos6_device.connected = True
140140
# Fixture is valid JSON, but is missing the entire 'wireless' block,

tests/test_stations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from http.cookies import SimpleCookie
44
import json
55
import os
6-
from typing import Any
6+
from typing import Any, cast
77
from unittest.mock import AsyncMock, MagicMock, patch
88

99
import aiofiles
@@ -175,7 +175,7 @@ async def test_ap_object(
175175
):
176176
# We don't need to patch the session directly anymore
177177
await airos8_device.login()
178-
status: AirOSData = await airos8_device.status()
178+
status = cast(AirOSData, await airos8_device.status())
179179

180180
# Assertions remain the same as they check the final result
181181
assert status.wireless.mode

0 commit comments

Comments
 (0)