mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-10 23:52:04 +03:00
Add test coverage for _as_int handling TypeError and ValueError
Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
parent
007fdb2509
commit
e15a6cc649
1 changed files with 14 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ from unittest.mock import AsyncMock, patch
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from netsleuth.speed import (
|
from netsleuth.speed import (
|
||||||
|
_as_int,
|
||||||
bufferbloat_delta,
|
bufferbloat_delta,
|
||||||
mbps,
|
mbps,
|
||||||
ookla_interface_args,
|
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_down_ms is None
|
||||||
assert result.bufferbloat_grade == "?"
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue