perf: slim fires/cameras/events/news map payloads
Heatmap uses {lat,lon,i,c}. Camera list drops URLs (detail via GET
/api/cameras/{id}). Event blips skip body. News omits content unless
include_content=true.
This commit is contained in:
parent
9c14b899ee
commit
8f89994201
3 changed files with 131 additions and 24 deletions
47
tests/test_map_payloads.py
Normal file
47
tests/test_map_payloads.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
"""Slim map-payload helpers (no DB)."""
|
||||
|
||||
from uuid import uuid4
|
||||
|
||||
from main import camera_map_row, fire_heat_row
|
||||
|
||||
|
||||
def test_fire_heat_row_is_tiny():
|
||||
row = {
|
||||
"latitude": 35.0,
|
||||
"longitude": -78.0,
|
||||
"brightness": 340.1,
|
||||
"confidence": "h",
|
||||
"satellite": "N21",
|
||||
"acq_time": "2026-08-27T00:00:00Z",
|
||||
"instrument": "VIIRS",
|
||||
"frp": 12.4,
|
||||
}
|
||||
out = fire_heat_row(row)
|
||||
assert out == {"lat": 35.0, "lon": -78.0, "i": 340.1, "c": "h"}
|
||||
assert "satellite" not in out
|
||||
assert "frp" not in out
|
||||
|
||||
|
||||
def test_camera_map_row_omits_urls():
|
||||
cid = uuid4()
|
||||
row = {
|
||||
"id": cid,
|
||||
"location_lat": 37.8,
|
||||
"location_lon": -122.4,
|
||||
"device_type": "hls",
|
||||
"discovery_source": "caltrans",
|
||||
"location_name": "I-80 WB",
|
||||
"source_url": "https://example.invalid/playlist.m3u8",
|
||||
"snapshot_url": "https://example.invalid/cam.jpg",
|
||||
"vendor": "Caltrans",
|
||||
"first_seen": None,
|
||||
"last_seen": None,
|
||||
}
|
||||
out = camera_map_row(row)
|
||||
assert out["id"] == str(cid)
|
||||
assert out["lat"] == 37.8
|
||||
assert out["lon"] == -122.4
|
||||
assert out["device_type"] == "hls"
|
||||
assert "source_url" not in out
|
||||
assert "snapshot_url" not in out
|
||||
assert "vendor" not in out
|
||||
Loading…
Reference in a new issue