feat: lean-Pi WS fan-out, geofences, DVR playback, fire/aircraft correlation
Phase 1: in-memory ConnectionManager viewport fan-out, 500ms map debounce, cachetools TTLCache, background masscan/ffmpeg, compose memory caps. Phase 2: PostGIS geofences + ST_Intersects alerts, Timescale 1-min CAGGs and timestamp playback, FIRMS/WFIGS x firefighting ADS-B within 20 miles. No Redis/Kafka/Celery.
This commit is contained in:
parent
8978324d33
commit
5ea9a4e879
28 changed files with 2318 additions and 50 deletions
|
|
@ -85,3 +85,87 @@ def test_ingest_fire_row_drops_malformed(clean_fires):
|
|||
assert await ingest_fire_row(make_fire_msg(acq_time="garbage")) is False
|
||||
|
||||
asyncio.run(run())
|
||||
|
||||
|
||||
class _InsertSession:
|
||||
"""async_session stand-in: fire insert succeeds (rowcount=1)."""
|
||||
|
||||
def __init__(self):
|
||||
self.rowcount = 1
|
||||
|
||||
async def execute(self, *a, **k):
|
||||
return self
|
||||
|
||||
async def commit(self):
|
||||
return None
|
||||
|
||||
async def __aenter__(self):
|
||||
return self
|
||||
|
||||
async def __aexit__(self, *a):
|
||||
return False
|
||||
|
||||
|
||||
def test_ingest_fire_row_geofence_when_cache_empty(monkeypatch):
|
||||
"""Ingester process has empty geofence cache; still notify on FIRMS insert."""
|
||||
import geofence
|
||||
import ingestor
|
||||
import live_layers
|
||||
|
||||
geofence._cache.clear()
|
||||
live_layers.aircraft_last_known.clear()
|
||||
notified = []
|
||||
|
||||
async def fake_record(**kw):
|
||||
notified.append(kw)
|
||||
return 1
|
||||
|
||||
async def no_markers(*a, **k):
|
||||
return []
|
||||
|
||||
monkeypatch.setattr(ingestor, "async_session", _InsertSession)
|
||||
monkeypatch.setattr(geofence, "record_and_notify", fake_record)
|
||||
monkeypatch.setattr("tracks.recent_markers", no_markers)
|
||||
|
||||
assert asyncio.run(ingest_fire_row(make_fire_msg())) is True
|
||||
assert len(notified) == 1
|
||||
assert notified[0]["source_kind"] == "firms"
|
||||
assert notified[0]["lat"] == 39.45678
|
||||
assert notified[0]["lon"] == -121.12345
|
||||
|
||||
|
||||
def test_ingest_fire_row_correlates_from_hypertable_when_last_known_empty(monkeypatch):
|
||||
"""FIRMS ingester has no ADS-B last-known; still correlate from aircraft_positions."""
|
||||
import geofence
|
||||
import ingestor
|
||||
import live_layers
|
||||
|
||||
geofence._cache.clear()
|
||||
live_layers.aircraft_last_known.clear()
|
||||
correlated = []
|
||||
|
||||
async def fake_record(**kw):
|
||||
return 0
|
||||
|
||||
async def fake_recent(kind, limit=2000):
|
||||
assert kind == "aircraft"
|
||||
return [{
|
||||
"id": "acf001",
|
||||
"lat": 39.45,
|
||||
"lon": -121.12,
|
||||
"extra": {"type": "AT802"},
|
||||
}]
|
||||
|
||||
async def fake_corr(fires, aircraft):
|
||||
correlated.append((fires, aircraft))
|
||||
return aircraft
|
||||
|
||||
monkeypatch.setattr(ingestor, "async_session", _InsertSession)
|
||||
monkeypatch.setattr(geofence, "record_and_notify", fake_record)
|
||||
monkeypatch.setattr("tracks.recent_markers", fake_recent)
|
||||
monkeypatch.setattr("fire_aircraft.correlate_and_notify", fake_corr)
|
||||
|
||||
assert asyncio.run(ingest_fire_row(make_fire_msg())) is True
|
||||
assert len(correlated) == 1
|
||||
assert correlated[0][1][0]["id"] == "acf001"
|
||||
assert correlated[0][0][0]["lat"] == 39.45678
|
||||
|
|
|
|||
Loading…
Reference in a new issue