mirror of
https://github.com/smittix/intercept.git
synced 2026-06-18 18:39:47 -07:00
d4652017f5
- meshcore pin >=2.3.0 (EventType.STATS_CORE floor); setup.sh derives optional packages from requirements.txt; Python 3.10 warning - agent-mode wifi clients proxy route + bare-array response handling - remove dead AIS/ACARS/VDL2 SPA wiring and orphaned partials/CSS - agent TLE download to data/tle/ (was littering repo root as gp.php) - gate deferred background init off under pytest (mock-pollution race) - complete Popen mocks (context manager protocol, communicate tuples) - real pipe fds in weather-sat decoder tests (fd 10/11 collision caused 10s SQLite stalls); satellite tests no longer rewrite data/satellites.py - register 'live' pytest marker, excluded by default - update stale test assertions to current APIs Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
122 lines
3.2 KiB
Python
122 lines
3.2 KiB
Python
"""Tests for the Signal Identification (guess) API endpoint."""
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def auth_client(client):
|
|
"""Client with logged-in session."""
|
|
with client.session_transaction() as sess:
|
|
sess["logged_in"] = True
|
|
return client
|
|
|
|
|
|
def test_signal_guess_fm_broadcast(auth_client):
|
|
"""FM broadcast frequency should return a known signal type."""
|
|
resp = auth_client.post(
|
|
"/receiver/signal/guess",
|
|
json={
|
|
"frequency_mhz": 98.1,
|
|
"modulation": "wfm",
|
|
},
|
|
)
|
|
assert resp.status_code == 200
|
|
data = resp.get_json()
|
|
assert data["status"] == "ok"
|
|
assert data["primary_label"]
|
|
assert data["confidence"] in ("HIGH", "MEDIUM", "LOW")
|
|
|
|
|
|
def test_signal_guess_airband(auth_client):
|
|
"""Airband frequency should be identified."""
|
|
resp = auth_client.post(
|
|
"/receiver/signal/guess",
|
|
json={
|
|
"frequency_mhz": 121.5,
|
|
"modulation": "am",
|
|
},
|
|
)
|
|
assert resp.status_code == 200
|
|
data = resp.get_json()
|
|
assert data["status"] == "ok"
|
|
assert data["primary_label"]
|
|
|
|
|
|
def test_signal_guess_ism_band(auth_client):
|
|
"""ISM band frequency (433.92 MHz) should be identified."""
|
|
resp = auth_client.post(
|
|
"/receiver/signal/guess",
|
|
json={
|
|
"frequency_mhz": 433.92,
|
|
},
|
|
)
|
|
assert resp.status_code == 200
|
|
data = resp.get_json()
|
|
assert data["status"] == "ok"
|
|
assert data["primary_label"]
|
|
assert data["confidence"] in ("HIGH", "MEDIUM", "LOW")
|
|
|
|
|
|
def test_signal_guess_missing_frequency(auth_client):
|
|
"""Missing frequency should return 400."""
|
|
resp = auth_client.post("/receiver/signal/guess", json={})
|
|
assert resp.status_code == 400
|
|
data = resp.get_json()
|
|
assert data["status"] == "error"
|
|
|
|
|
|
def test_signal_guess_invalid_frequency(auth_client):
|
|
"""Invalid frequency value should return 400."""
|
|
resp = auth_client.post(
|
|
"/receiver/signal/guess",
|
|
json={
|
|
"frequency_mhz": "abc",
|
|
},
|
|
)
|
|
assert resp.status_code == 400
|
|
|
|
|
|
def test_signal_guess_negative_frequency(auth_client):
|
|
"""Negative frequency should return 400."""
|
|
resp = auth_client.post(
|
|
"/receiver/signal/guess",
|
|
json={
|
|
"frequency_mhz": -5.0,
|
|
},
|
|
)
|
|
assert resp.status_code == 400
|
|
|
|
|
|
def test_signal_guess_with_region(auth_client):
|
|
"""Specifying region should work."""
|
|
resp = auth_client.post(
|
|
"/receiver/signal/guess",
|
|
json={
|
|
"frequency_mhz": 462.5625,
|
|
"region": "US",
|
|
},
|
|
)
|
|
assert resp.status_code == 200
|
|
data = resp.get_json()
|
|
assert data["status"] == "ok"
|
|
|
|
|
|
def test_signal_guess_response_structure(auth_client):
|
|
"""Response should have all expected fields."""
|
|
resp = auth_client.post(
|
|
"/receiver/signal/guess",
|
|
json={
|
|
"frequency_mhz": 146.52,
|
|
"modulation": "fm",
|
|
},
|
|
)
|
|
assert resp.status_code == 200
|
|
data = resp.get_json()
|
|
assert "primary_label" in data
|
|
assert "confidence" in data
|
|
assert "alternatives" in data
|
|
assert "explanation" in data
|
|
assert "tags" in data
|
|
assert isinstance(data["alternatives"], list)
|
|
assert isinstance(data["tags"], list)
|