From d0b4451c4073e535f35b52d55ebd8b7c616d6235 Mon Sep 17 00:00:00 2001 From: Horizontal42 <75383519+Horizontal42@users.noreply.github.com> Date: Wed, 19 Aug 2026 17:13:07 +0300 Subject: [PATCH] Add test coverage for _as_int handling TypeError and ValueError (#8) Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- tests/test_speed_math.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_speed_math.py b/tests/test_speed_math.py index 4d04053..91e023e 100644 --- a/tests/test_speed_math.py +++ b/tests/test_speed_math.py @@ -7,6 +7,7 @@ from unittest.mock import AsyncMock, patch import pytest from netsleuth.speed import ( + _as_int, bufferbloat_delta, mbps, ookla_interface_args, @@ -397,3 +398,16 @@ async def test_measure_with_bufferbloat_without_an_idle_baseline_grades_unknown( ) assert result.bufferbloat_down_ms is None assert result.bufferbloat_grade == "?" + + +def test_as_int_returns_none_for_none(): + assert _as_int(None) is None + + +def test_as_int_returns_none_for_invalid_string(): + assert _as_int("abc") is None + + +def test_as_int_returns_parsed_integer_for_valid_string(): + assert _as_int("123") == 123 + assert _as_int("-456") == -456