From d0da3aa80e56d5e84ad3a8a91cbe490123835f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20P=C3=A9rez?= Date: Sun, 20 Sep 2026 23:48:18 -0300 Subject: [PATCH] test(report): cover peer latitude/longitude/height in topology payload #84 added the fields to _TOPOLOGY_PEER_FIELDS with no test covering either direction: that they appear (validated against schemas/report-v2.json) when the peer sends coordinates, and that they're omitted, not emitted as null/empty, when it doesn't. --- tests/application/test_report_payloads.py | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/application/test_report_payloads.py b/tests/application/test_report_payloads.py index be44e34..f4b9605 100644 --- a/tests/application/test_report_payloads.py +++ b/tests/application/test_report_payloads.py @@ -380,6 +380,53 @@ def test_build_topology_includes_peer_display_fields() -> None: assert peer["slots"] == "2" +def test_build_topology_includes_peer_coordinates(validator: jsonschema.Draft202012Validator) -> None: + systems = { + "MASTER-A": { + "MODE": "MASTER", + "ENABLED": True, + "PEERS": { + bytes_3(3120001): { + "CONNECTION": "YES", + "CALLSIGN": b"CE5RPY ", + "LATITUDE": b"-33.4489\x00", + "LONGITUDE": b"-70.6693\x00", + "HEIGHT": b"12\x00", + } + }, + } + } + doc = build_topology(systems, seq=1, ts=1.0) + validator.validate(doc) + peer = doc["systems"][0]["peers"][0] + assert peer["latitude"] == "-33.4489" + assert peer["longitude"] == "-70.6693" + assert peer["height"] == "12" + + +def test_build_topology_omits_empty_peer_coordinates() -> None: + systems = { + "MASTER-A": { + "MODE": "MASTER", + "ENABLED": True, + "PEERS": { + bytes_3(3120001): { + "CONNECTION": "YES", + "CALLSIGN": b"CE5RPY ", + "LATITUDE": b"", + "LONGITUDE": b"", + "HEIGHT": b"", + } + }, + } + } + doc = build_topology(systems, seq=1, ts=1.0) + peer = doc["systems"][0]["peers"][0] + assert "latitude" not in peer + assert "longitude" not in peer + assert "height" not in peer + + def test_topology_strips_nul_padded_callsign() -> None: systems = { "MASTER-A": {