feat: add realtime GNSS monitor with telemetry websocket
All checks were successful
Deploy to Production / deploy (push) Successful in 1m10s
All checks were successful
Deploy to Production / deploy (push) Successful in 1m10s
This commit is contained in:
@@ -85,3 +85,65 @@ def test_worker_marks_failed_without_retry_schedule(monkeypatch) -> None:
|
||||
|
||||
def test_schema_excludes_terminal_observation_event_table() -> None:
|
||||
assert "terminal_observation_event" not in SQLModel.metadata.tables
|
||||
|
||||
|
||||
def test_ingest_and_parse_real_nmea_sample() -> None:
|
||||
from pathlib import Path
|
||||
|
||||
sample_path = Path(__file__).parent / "nmea.txt"
|
||||
payload = sample_path.read_bytes()
|
||||
|
||||
with _session() as session:
|
||||
raw = insert_raw_message(
|
||||
session=session,
|
||||
device_id="device-real-sample",
|
||||
topic="terminal/device-real-sample/raw",
|
||||
payload=payload,
|
||||
qos=1,
|
||||
retain=False,
|
||||
)
|
||||
|
||||
processed = process_pending_batch(session=session, batch_size=10)
|
||||
assert processed == 1
|
||||
|
||||
refreshed = session.get(TerminalMessageRaw, raw.id)
|
||||
assert refreshed is not None
|
||||
assert refreshed.parsed_at is not None
|
||||
assert refreshed.parse_error is None
|
||||
|
||||
state = session.get(TerminalDeviceState, "device-real-sample")
|
||||
assert state is not None
|
||||
assert state.lat is not None
|
||||
assert state.lon is not None
|
||||
|
||||
|
||||
def test_worker_builds_satellite_distribution_summary() -> None:
|
||||
payload = (
|
||||
b"$GNGGA,123519,3723.2475,N,12158.3416,W,4,12,0.8,10.0,M,-25.0,M,,*65\r\n"
|
||||
b"$GPGSA,A,3,02,05,12,,,,,,,,,,1.50,0.90,1.20*00\r\n"
|
||||
b"$GPGSV,1,1,04,02,17,213,40,05,29,121,37,12,66,314,44,25,14,048,39*71\r\n"
|
||||
)
|
||||
|
||||
with _session() as session:
|
||||
insert_raw_message(
|
||||
session=session,
|
||||
device_id="device-gsv",
|
||||
topic="terminal/device-gsv/raw",
|
||||
payload=payload,
|
||||
qos=1,
|
||||
retain=False,
|
||||
)
|
||||
|
||||
processed = process_pending_batch(session=session, batch_size=10)
|
||||
|
||||
assert processed == 1
|
||||
state = session.get(TerminalDeviceState, "device-gsv")
|
||||
assert state is not None
|
||||
assert state.fix_status == "4"
|
||||
summary = state.satellite_signal_summary
|
||||
assert summary is not None
|
||||
assert summary["satellites_in_view"] == 4
|
||||
assert summary["snr_values"] == [40, 37, 44, 39]
|
||||
assert summary["used_satellite_ids"] == ["02", "05", "12"]
|
||||
assert summary["constellations"]["GPS"]["count"] == 4
|
||||
assert summary["constellations"]["GPS"]["used_in_navigation"] == 3
|
||||
|
||||
Reference in New Issue
Block a user