netsleuth/tests
Andrew Pimenov 245533f904 add Prometheus/CSV export, auto-diff vs previous run, and --trend
New metrics.py: collect_metrics() does the per-section extraction a flat
dict walk can't (latency needs label/host/method, TLS label/host, path hops
target/ttl/ip/asn), producing a flat Metric list that render_prometheus()
and render_csv() each format in about 15 lines. Simpler than treating them
as two separate renderers. FORMAT_EXTENSIONS gained "prom"/"csv" as the
single wiring point both parse_formats() and Output._normalize_formats()
already key off of.

New history.py finds a previous JSON report for the same ASN by reusing
the exact filename convention exporter.report_filename() already writes,
so the lookup key can't drift from what's on disk. Wired into diagnose()
before write_report() - a compact vs-previous-run summary
(compare.py::render_diff_brief(), new) prints automatically whenever this
run writes JSON and an earlier one exists for the same network; silent on
every other case (first run, prior run wrote no JSON prints one note
instead of guessing). New --no-auto-diff escapes it per run,
history.auto_diff in config disables it entirely.

New trend.py aggregates N saved JSON reports into per-label sparkline
series via --trend N - read-only, and it doesn't touch the network to find
"this network's" history either: history.latest_key() just reads it off
the newest report filename already on disk.

Growing FORMAT_EXTENSIONS to 5 entries broke three pre-existing tests that
hardcoded the old 3-format set; fixed in this commit.

Live-tested: prom/csv artifacts render correctly, auto-diff fired on a
second run, --trend 3 produced readable output, --compare unaffected.

Part of plans/zesty-zooming-wilkinson.md (gitignored).
2026-08-12 22:10:21 +03:00
..
fixtures add system DNS vs DoH comparison and transparent proxy detection 2026-08-09 17:45:33 +03:00
conftest.py project scaffold: uv packaging, config.yaml, package skeleton 2026-08-08 21:12:41 +03:00
test_bgp.py extract NDT7 consent check into a helper function 2026-08-09 16:07:44 +03:00
test_bgp_path.py fix international-loop detection: drop dead ip_country parameter 2026-08-10 21:18:28 +03:00
test_captive_portal.py detect captive portals up front, flag off-country speedtest servers 2026-08-12 21:36:54 +03:00
test_cgnat_nat64.py detect CGNAT, NAT64, and first-hop-vs-path issues separately 2026-08-12 21:06:01 +03:00
test_cli_formats.py add Prometheus/CSV export, auto-diff vs previous run, and --trend 2026-08-12 22:10:21 +03:00
test_compare.py add Prometheus/CSV export, auto-diff vs previous run, and --trend 2026-08-12 22:10:21 +03:00
test_config.py add Prometheus/CSV export, auto-diff vs previous run, and --trend 2026-08-12 22:10:21 +03:00
test_dns_advanced.py add system DNS vs DoH comparison and transparent proxy detection 2026-08-09 17:45:33 +03:00
test_dns_leak.py rename package netcheck to netsleuth (name taken on pypi) 2026-08-09 11:43:00 +03:00
test_dnsbl_decode.py add tests for decode_dnsbl fallback and mixed responses 2026-08-09 16:18:57 +03:00
test_dpi_check.py add single-host DPI/TCP-RST self-diagnostic probe 2026-08-09 17:45:27 +03:00
test_exporter.py add Prometheus/CSV export, auto-diff vs previous run, and --trend 2026-08-12 22:10:21 +03:00
test_exporter_l7.py render TLS, DNS advanced, path diversity, prefix bench, DPI sections in reports 2026-08-09 17:56:07 +03:00
test_history.py add Prometheus/CSV export, auto-diff vs previous run, and --trend 2026-08-12 22:10:21 +03:00
test_hop_asn.py enrich traceroute hops with ASN, AS name, country and PTR fallback 2026-08-12 21:17:00 +03:00
test_icmp_win_parse.py rename package netcheck to netsleuth (name taken on pypi) 2026-08-09 11:43:00 +03:00
test_icmp_win_trace.py add --interface flag to force outbound probing through a specific adapter 2026-08-09 13:36:06 +03:00
test_iface.py add --interface flag to force outbound probing through a specific adapter 2026-08-09 13:36:06 +03:00
test_interpret.py detect captive portals up front, flag off-country speedtest servers 2026-08-12 21:36:54 +03:00
test_interpret_l7.py verify TLS certificates and fingerprint them for MITM detection 2026-08-12 21:48:36 +03:00
test_ip_geo_normalize.py expand classify_ip_type test coverage 2026-08-09 16:17:49 +03:00
test_metrics.py add Prometheus/CSV export, auto-diff vs previous run, and --trend 2026-08-12 22:10:21 +03:00
test_models.py add L4-L7 diagnostic models (TLS, DPI, DNS, anycast, prefix bench) 2026-08-09 17:35:37 +03:00
test_netinfo.py fix default gateway detection picking wrong route with multiple adapters 2026-08-09 13:00:24 +03:00
test_orchestration.py rename package netcheck to netsleuth (name taken on pypi) 2026-08-09 11:43:00 +03:00
test_prefix_benchmark.py add AS prefix latency benchmark probe 2026-08-09 17:43:10 +03:00
test_prober_stats.py add jitter matrix (p95/p99/cv) to ping stats 2026-08-09 17:34:06 +03:00
test_reputation.py add test coverage for fetch_internetdb 2026-08-09 16:19:59 +03:00
test_speed_cloudflare.py add tests for tier_cloudflare 2026-08-09 16:14:55 +03:00
test_speed_fastcom.py detect captive portals up front, flag off-country speedtest servers 2026-08-12 21:36:54 +03:00
test_speed_math.py add test coverage for throughput_from_samples 2026-08-09 16:20:50 +03:00
test_stats.py add jitter matrix (p95/p99/cv) to ping stats 2026-08-09 17:34:06 +03:00
test_tls_rtt.py verify TLS certificates and fingerprint them for MITM detection 2026-08-12 21:48:36 +03:00
test_traceparse.py add specific unit tests for parse_traceroute 2026-08-09 16:21:23 +03:00
test_traceroute_cascade.py add --interface flag to force outbound probing through a specific adapter 2026-08-09 13:36:06 +03:00
test_trend.py add Prometheus/CSV export, auto-diff vs previous run, and --trend 2026-08-12 22:10:21 +03:00
test_watch.py rename package netcheck to netsleuth (name taken on pypi) 2026-08-09 11:43:00 +03:00