@@ -260,18 +260,24 @@ async def test_status_missing_required_key_in_json(airos_device: AirOS) -> None:
260260 # Assert that the cause of our exception is the correct type from mashumaro
261261 assert isinstance (excinfo .value .__cause__ , MissingField )
262262
263+
263264# --- Tests for warnings() and update_check() ---
264265@pytest .mark .asyncio
265266async def test_warnings_correctly_parses_json () -> None :
266267 """Test that the warnings() method correctly parses a valid JSON response."""
267268 mock_session = MagicMock ()
268- airos_device = AirOS (host = "http://192.168.1.3" , username = "test" , password = "test" , session = mock_session )
269+ airos_device = AirOS (
270+ host = "http://192.168.1.3" ,
271+ username = "test" ,
272+ password = "test" ,
273+ session = mock_session ,
274+ )
269275 airos_device .connected = True
270276
271277 mock_response = MagicMock ()
272278 mock_response .__aenter__ .return_value = mock_response
273279 mock_response .status = 200
274- with open ("fixtures/warnings.json" ) as f :
280+ with open ("fixtures/warnings.json" , encoding = "utf-8" ) as f :
275281 mock_response_data = json .load (f )
276282 mock_response .text = AsyncMock (return_value = json .dumps (mock_response_data ))
277283
@@ -285,31 +291,43 @@ async def test_warnings_correctly_parses_json() -> None:
285291async def test_warnings_raises_exception_on_invalid_json () -> None :
286292 """Test that warnings() raises an exception on invalid JSON response."""
287293 mock_session = MagicMock ()
288- airos_device = AirOS (host = "http://192.168.1.3" , username = "test" , password = "test" , session = mock_session )
294+ airos_device = AirOS (
295+ host = "http://192.168.1.3" ,
296+ username = "test" ,
297+ password = "test" ,
298+ session = mock_session ,
299+ )
289300 airos_device .connected = True
290301
291302 mock_response = MagicMock ()
292303 mock_response .__aenter__ .return_value = mock_response
293304 mock_response .status = 200
294305 mock_response .text = AsyncMock (return_value = "This is not JSON" )
295306
296- with (patch .object (airos_device .session , "get" , return_value = mock_response ),
297- pytest .raises (airos .exceptions .AirOSDataMissingError )):
298- await airos_device .warnings ()
307+ with (
308+ patch .object (airos_device .session , "get" , return_value = mock_response ),
309+ pytest .raises (airos .exceptions .AirOSDataMissingError ),
310+ ):
311+ await airos_device .warnings ()
299312
300313
301314@pytest .mark .asyncio
302315async def test_update_check_correctly_parses_json () -> None :
303316 """Test that update_check() method correctly parses a valid JSON response."""
304317 mock_session = MagicMock ()
305- airos_device = AirOS (host = "http://192.168.1.3" , username = "test" , password = "test" , session = mock_session )
318+ airos_device = AirOS (
319+ host = "http://192.168.1.3" ,
320+ username = "test" ,
321+ password = "test" ,
322+ session = mock_session ,
323+ )
306324 airos_device .connected = True
307325 airos_device .current_csrf_token = "mock-csrf-token"
308326
309327 mock_response = MagicMock ()
310328 mock_response .__aenter__ .return_value = mock_response
311329 mock_response .status = 200
312- with open ("fixtures/update_check_available.json" ) as f :
330+ with open ("fixtures/update_check_available.json" , encoding = "utf-8" ) as f :
313331 mock_response_data = json .load (f )
314332 mock_response .text = AsyncMock (return_value = json .dumps (mock_response_data ))
315333
@@ -323,7 +341,12 @@ async def test_update_check_correctly_parses_json() -> None:
323341async def test_update_check_raises_exception_on_invalid_json () -> None :
324342 """Test that update_check() raises an exception on invalid JSON response."""
325343 mock_session = MagicMock ()
326- airos_device = AirOS (host = "http://192.168.1.3" , username = "test" , password = "test" , session = mock_session )
344+ airos_device = AirOS (
345+ host = "http://192.168.1.3" ,
346+ username = "test" ,
347+ password = "test" ,
348+ session = mock_session ,
349+ )
327350 airos_device .connected = True
328351 airos_device .current_csrf_token = "mock-csrf-token"
329352
@@ -332,16 +355,23 @@ async def test_update_check_raises_exception_on_invalid_json() -> None:
332355 mock_response .status = 200
333356 mock_response .text = AsyncMock (return_value = "This is not JSON" )
334357
335- with (patch .object (airos_device .session , "post" , return_value = mock_response ),
336- pytest .raises (airos .exceptions .AirOSDataMissingError )):
337- await airos_device .update_check ()
358+ with (
359+ patch .object (airos_device .session , "post" , return_value = mock_response ),
360+ pytest .raises (airos .exceptions .AirOSDataMissingError ),
361+ ):
362+ await airos_device .update_check ()
338363
339364
340365@pytest .mark .asyncio
341366async def test_warnings_when_not_connected () -> None :
342367 """Test calling warnings() before a successful login."""
343368 mock_session = MagicMock ()
344- airos_device = AirOS (host = "http://192.168.1.3" , username = "test" , password = "test" , session = mock_session )
369+ airos_device = AirOS (
370+ host = "http://192.168.1.3" ,
371+ username = "test" ,
372+ password = "test" ,
373+ session = mock_session ,
374+ )
345375 airos_device .connected = False # Explicitly set connected state to false
346376
347377 with pytest .raises (airos .exceptions .AirOSDeviceConnectionError ):
@@ -352,8 +382,13 @@ async def test_warnings_when_not_connected() -> None:
352382async def test_update_check_when_not_connected () -> None :
353383 """Test calling update_check() before a successful login."""
354384 mock_session = MagicMock ()
355- airos_device = AirOS (host = "http://192.168.1.3" , username = "test" , password = "test" , session = mock_session )
356- airos_device .connected = False # Explicitly set connected state to false
385+ airos_device = AirOS (
386+ host = "http://192.168.1.3" ,
387+ username = "test" ,
388+ password = "test" ,
389+ session = mock_session ,
390+ )
391+ airos_device .connected = False # Explicitly set connected state to false
357392
358393 with pytest .raises (airos .exceptions .AirOSDeviceConnectionError ):
359394 await airos_device .update_check ()
0 commit comments