add specific unit tests for parse_traceroute

This commit is contained in:
Andrew Pimenov 2026-08-09 16:21:23 +03:00
parent 9a01b2abe2
commit 387e58949f

View file

@ -186,10 +186,36 @@ def test_darwin_parser_tolerates_empty_input():
assert parse_darwin("") == [] assert parse_darwin("") == []
from unittest.mock import patch
from netsleuth.models import TraceConfig from netsleuth.models import TraceConfig
from netsleuth.traceparse import build_trace_result, parse_traceroute from netsleuth.traceparse import build_trace_result, parse_traceroute
def test_parse_traceroute_routes_to_windows():
with patch("netsleuth.traceparse.parse_windows") as mock_windows:
parse_traceroute("test text", "Windows")
mock_windows.assert_called_once_with("test text")
def test_parse_traceroute_routes_to_darwin():
with patch("netsleuth.traceparse.parse_darwin") as mock_darwin:
parse_traceroute("test text", "Darwin")
mock_darwin.assert_called_once_with("test text")
def test_parse_traceroute_routes_to_linux_for_linux():
with patch("netsleuth.traceparse.parse_linux") as mock_linux:
parse_traceroute("test text", "Linux")
mock_linux.assert_called_once_with("test text")
def test_parse_traceroute_routes_to_linux_for_unknown_os():
with patch("netsleuth.traceparse.parse_linux") as mock_linux:
parse_traceroute("test text", "SunOS")
mock_linux.assert_called_once_with("test text")
def test_dispatcher_routes_by_os_name(trace_fixture): def test_dispatcher_routes_by_os_name(trace_fixture):
win = parse_traceroute(trace_fixture("windows", "tracert_en.txt"), "Windows") win = parse_traceroute(trace_fixture("windows", "tracert_en.txt"), "Windows")
lin = parse_traceroute(trace_fixture("linux", "gnu_basic.txt"), "Linux") lin = parse_traceroute(trace_fixture("linux", "gnu_basic.txt"), "Linux")