fix(topology): correct mission anchors and rover ports

This commit is contained in:
2026-07-09 21:49:52 +08:00
parent 808276e225
commit e7becba0b0
2 changed files with 71 additions and 2 deletions
+49
View File
@@ -1,6 +1,7 @@
from __future__ import annotations
import unittest
from datetime import datetime, timezone
from pathlib import Path
from topology_api.app import create_app
@@ -42,6 +43,18 @@ class TopologyApiServingTests(unittest.TestCase):
class TopologyApiQueryTests(unittest.TestCase):
EXPECTED_LAST_EVENTS = {
"BL-01": "2024-05-17T23:01:00+00:00",
"GHC-01": "2024-06-16T07:23:00+00:00",
"JC-01": "2024-06-17T08:19:00+00:00",
"BL-02": "2024-06-23T05:23:00+00:00",
"GHC-02": "2024-07-15T03:16:00+00:00",
"GHC-03": "2024-08-30T12:45:00+00:00",
"BL-03": "2024-09-23T19:20:00+00:00",
"GHC-04": "2024-11-20T13:57:00+00:00",
"GHC-05": "2025-01-22T10:52:00+00:00",
}
@classmethod
def setUpClass(cls) -> None:
app = create_app()
@@ -75,6 +88,42 @@ class TopologyApiQueryTests(unittest.TestCase):
self.assertIn("occurrenceStatus", mission)
self.assertIn("lastEventAt", mission)
def test_each_mission_uses_its_last_timeline_record(self) -> None:
response = self.client.get("/api/v1/bases/guanghan/missions")
actual = {
mission["code"]: datetime.fromisoformat(
mission["lastEventAt"]
).astimezone(timezone.utc)
for mission in response.get_json()["missions"]
}
expected = {
code: datetime.fromisoformat(value)
for code, value in self.EXPECTED_LAST_EVENTS.items()
}
self.assertEqual(actual, expected)
def test_binglun_connections_use_west_south_east_hub_ports(self) -> None:
response = self.client.get(
"/api/v1/bases/guanghan/snapshot?mission=GHC-05"
)
connections = response.get_json()["connections"]
hub_ports = {}
for connection in connections:
from_component = connection["fromPort"].split(".", 1)[0]
if (
from_component in {"binglun_1", "binglun_2", "binglun_3"}
and connection["type"] == "power"
):
hub_ports[from_component] = connection["toPort"]
self.assertEqual(
hub_ports,
{
"binglun_1": "power_module_hub.west",
"binglun_2": "power_module_hub.south",
"binglun_3": "power_module_hub.east",
},
)
if __name__ == "__main__":
unittest.main()