mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-10 19:12:03 +03:00
Merge 73b843404d into 8c99ac78b7
This commit is contained in:
commit
57c0b2eaf5
1 changed files with 30 additions and 0 deletions
|
|
@ -4,6 +4,8 @@ import json
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
import pytest
|
import pytest
|
||||||
from netsleuth.speed import (
|
from netsleuth.speed import (
|
||||||
|
_as_int,
|
||||||
|
_us_to_ms,
|
||||||
bufferbloat_delta,
|
bufferbloat_delta,
|
||||||
mbps,
|
mbps,
|
||||||
ookla_interface_args,
|
ookla_interface_args,
|
||||||
|
|
@ -23,6 +25,34 @@ from netsleuth.speed import tier_fastcom
|
||||||
from netsleuth.speed import tier_ndt7
|
from netsleuth.speed import tier_ndt7
|
||||||
|
|
||||||
|
|
||||||
|
def test_as_int_happy_path():
|
||||||
|
assert _as_int("123") == 123
|
||||||
|
assert _as_int("-45") == -45
|
||||||
|
assert _as_int("0") == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_as_int_error_path():
|
||||||
|
assert _as_int("not-a-number") is None
|
||||||
|
assert _as_int("12.34") is None
|
||||||
|
assert _as_int("") is None
|
||||||
|
assert _as_int(None) is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_us_to_ms_happy_path():
|
||||||
|
assert _us_to_ms("1000") == 1.0
|
||||||
|
assert _us_to_ms("1500") == 1.5
|
||||||
|
assert _us_to_ms("123456") == 123.456
|
||||||
|
assert _us_to_ms("-1000") == -1.0
|
||||||
|
assert _us_to_ms("0") == 0.0
|
||||||
|
|
||||||
|
|
||||||
|
def test_us_to_ms_error_path():
|
||||||
|
assert _us_to_ms("not-a-number") is None
|
||||||
|
assert _us_to_ms("12.34") is None
|
||||||
|
assert _us_to_ms("") is None
|
||||||
|
assert _us_to_ms(None) is None
|
||||||
|
|
||||||
|
|
||||||
def test_mbps_converts_bytes_and_seconds():
|
def test_mbps_converts_bytes_and_seconds():
|
||||||
assert mbps(1000000, 1.0) == pytest.approx(8.0)
|
assert mbps(1000000, 1.0) == pytest.approx(8.0)
|
||||||
assert mbps(12500000, 1.0) == pytest.approx(100.0)
|
assert mbps(12500000, 1.0) == pytest.approx(100.0)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue