feat(map): derive station regions from GPS
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import importlib.util
|
||||
import io
|
||||
import json
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
@@ -11,21 +13,24 @@ SPEC.loader.exec_module(server)
|
||||
|
||||
class StationNavigationTest(unittest.TestCase):
|
||||
def test_directory_is_a_positive_allowlist_without_hydrogen_data(self):
|
||||
source = [{
|
||||
source = {
|
||||
"status": "ok",
|
||||
"asOf": "2026-08-12 12:00:00",
|
||||
"summary": {"totalStations": 1, "cooperativeStations": 1},
|
||||
"stations": [{
|
||||
"id": "GD-1", "name": "广州合作站", "province": "广东省", "city": "广州市",
|
||||
"district": "黄埔区", "address": "开源大道1号", "longitude": 113.2, "latitude": 23.1,
|
||||
"cooperative": True, "monthlyHydrogenKg": 88.8, "totalHydrogenKg": 999.9,
|
||||
"vehicleCount": 20,
|
||||
}]
|
||||
with patch.object(server, "_post_open_platform", return_value=source):
|
||||
"cooperative": True,
|
||||
}],
|
||||
}
|
||||
with patch.object(server, "urlopen", return_value=io.BytesIO(json.dumps(source).encode("utf-8"))):
|
||||
result = server._load_station_directory()
|
||||
|
||||
self.assertEqual(result["summary"], {"totalStations": 1, "cooperativeStations": 1})
|
||||
station = result["stations"][0]
|
||||
self.assertEqual(station["name"], "广州合作站")
|
||||
self.assertNotIn("monthlyHydrogenKg", station)
|
||||
self.assertNotIn("totalHydrogenKg", station)
|
||||
self.assertNotIn("vehicleCount", station)
|
||||
self.assertEqual(station["province"], "广东省")
|
||||
self.assertEqual(server.VEHICLE_MAP_INTERNAL_BASE_URL, "http://127.0.0.1:20800")
|
||||
|
||||
def test_static_assets_are_fingerprinted(self):
|
||||
self.assertRegex(server.STATIC_ASSET_VERSION, r"^[0-9a-f]{16}$")
|
||||
|
||||
Reference in New Issue
Block a user