mirror of
https://github.com/smittix/intercept.git
synced 2026-07-14 12:38:11 -07:00
test(drone): fix test_start_stop isolation and add out-of-band filter coverage
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -70,14 +70,25 @@ def test_hackrf_sweep_below_threshold_ignored(detector):
|
|||||||
assert q.empty()
|
assert q.empty()
|
||||||
|
|
||||||
|
|
||||||
|
def test_out_of_band_frequency_ignored(detector):
|
||||||
|
det, q = detector
|
||||||
|
# 915 MHz is not in any drone band
|
||||||
|
line = json.dumps({"freq": 915_000_000, "rssi": -50.0, "protocol": "Generic"})
|
||||||
|
det._handle_rtl433_line(line)
|
||||||
|
assert q.empty()
|
||||||
|
|
||||||
|
|
||||||
def test_start_stop(detector):
|
def test_start_stop(detector):
|
||||||
det, q = detector
|
det, q = detector
|
||||||
mock_proc = MagicMock()
|
mock_proc = MagicMock()
|
||||||
mock_proc.stdout = MagicMock()
|
mock_proc.stdout = MagicMock()
|
||||||
mock_proc.stdout.readline = MagicMock(side_effect=[b""])
|
mock_proc.stdout.readline = MagicMock(side_effect=[b""])
|
||||||
with patch("subprocess.Popen", return_value=mock_proc):
|
# Patch both shutil.which calls (rtl_433 in _run_rtl433, hackrf_sweep in _run_hackrf)
|
||||||
with patch("shutil.which", return_value="/usr/bin/rtl_433"):
|
with (
|
||||||
det.start(rtl_sdr_index=0)
|
patch("subprocess.Popen", return_value=mock_proc),
|
||||||
|
patch("utils.drone.rf_detector.shutil.which", return_value=None),
|
||||||
|
):
|
||||||
|
det.start(rtl_sdr_index=0, use_hackrf=False)
|
||||||
assert det.running
|
assert det.running
|
||||||
det.stop()
|
det.stop()
|
||||||
assert not det.running
|
assert not det.running
|
||||||
|
|||||||
Reference in New Issue
Block a user