diff --git a/src/netsleuth/cli.py b/src/netsleuth/cli.py index e84faa5..272ca2f 100644 --- a/src/netsleuth/cli.py +++ b/src/netsleuth/cli.py @@ -493,6 +493,23 @@ async def diagnose(settings: Settings, options: Options) -> tuple[dict, list[Pat return report, paths +def _check_ndt7_consent(settings: Settings) -> bool: + consent_marker = Path(settings.output.cache_dir) / "ndt7_consent" + if consent_marker.exists(): + return True + + console.print(f"[yellow]{NDT7_CONSENT_NOTICE}[/yellow]") + if not sys.stdin.isatty(): + return True + + if typer.confirm("Continue with NDT7?", default=False): + consent_marker.parent.mkdir(parents=True, exist_ok=True) + consent_marker.write_text("consented\n", encoding="utf-8") + return True + + return False + + @app.command() def run( full: bool = typer.Option(False, "--full", help="Full run: speedtest and full MTR cycles."), @@ -569,15 +586,7 @@ def run( finally: probe.close() if ndt7: - consent_marker = Path(settings.output.cache_dir) / "ndt7_consent" - if not consent_marker.exists(): - console.print(f"[yellow]{NDT7_CONSENT_NOTICE}[/yellow]") - if sys.stdin.isatty(): - if typer.confirm("Continue with NDT7?", default=False): - consent_marker.parent.mkdir(parents=True, exist_ok=True) - consent_marker.write_text("consented\n", encoding="utf-8") - else: - options.ndt7 = False + options.ndt7 = _check_ndt7_consent(settings) if tcp_trace: console.print( "[yellow]--tcp-trace needs Npcap (Windows) or root (Unix) and the `tcptrace` extra; " diff --git a/tests/test_bgp.py b/tests/test_bgp.py index 2c13272..202fddc 100644 --- a/tests/test_bgp.py +++ b/tests/test_bgp.py @@ -1,7 +1,6 @@ from __future__ import annotations import httpx -import pytest from netsleuth.bgp import ( classify_stability, diff --git a/tests/test_speed_math.py b/tests/test_speed_math.py index 785e1db..8b68061 100644 --- a/tests/test_speed_math.py +++ b/tests/test_speed_math.py @@ -98,7 +98,7 @@ def test_bufferbloat_delta_needs_both_a_baseline_and_samples(): assert bufferbloat_delta(12.0, []) is None -from netsleuth.models import SpeedResult, TierAttempt +from netsleuth.models import SpeedResult from netsleuth.speed import NDT7_CONSENT_NOTICE, run_speed_cascade