Files
intercept/tests/test_capabilities.py
T
James Smith 0588055d1f refactor: extract shared capability detection from agent
utils/capabilities.py now owns interface detection and mode
availability; the agent delegates via detect_interfaces() and
detect_mode_availability(). The agent keeps config gating and
tool_details population to preserve its result shape exactly.

The moved fallback path uses utils.dependencies.check_tool instead of
the agent's old shutil.which fallback; check_tool also searches
Homebrew paths, a strict superset (strictly better detection).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 08:31:54 +01:00

44 lines
1.5 KiB
Python

"""Tests for shared capability detection."""
from unittest.mock import patch
from utils.capabilities import detect_interfaces, detect_mode_availability
class TestModeAvailability:
def test_all_tools_present(self):
with patch("utils.capabilities.check_all_dependencies") as mock_deps:
mock_deps.return_value = {
key: {"ready": True}
for key in (
"pager",
"sensor",
"aircraft",
"ais",
"acars",
"aprs",
"wifi",
"bluetooth",
"tscm",
"satellite",
)
}
modes = detect_mode_availability()
assert modes.get("sensor") is True
assert modes.get("pager") is True
assert modes.get("adsb") is True # maps from dep key "aircraft"
def test_no_tools_present(self):
with patch("utils.capabilities.check_all_dependencies") as mock_deps:
mock_deps.return_value = {}
modes = detect_mode_availability()
assert modes.get("sensor") is False
class TestInterfaceDetection:
def test_returns_expected_shape(self, fake_process):
with patch("subprocess.Popen", return_value=fake_process()):
interfaces = detect_interfaces()
assert set(interfaces) == {"wifi_interfaces", "bt_adapters", "sdr_devices"}
assert isinstance(interfaces["wifi_interfaces"], list)