Expand Moscow nearby station map coverage
This commit is contained in:
@@ -19,6 +19,12 @@ RUSSIA_MOSCOW_STATIONS: Dict[str, Dict[str, Any]] = {
|
||||
"lat": 55.5870,
|
||||
"lon": 37.2500,
|
||||
},
|
||||
"27500": {
|
||||
"station_code": "27500",
|
||||
"station_label": "Tolstopaltsevo",
|
||||
"lat": 55.5900,
|
||||
"lon": 37.1940,
|
||||
},
|
||||
"27518": {
|
||||
"station_code": "27518",
|
||||
"station_label": "Podmoskovnaya",
|
||||
@@ -37,6 +43,18 @@ RUSSIA_MOSCOW_STATIONS: Dict[str, Dict[str, Any]] = {
|
||||
"lat": 55.5780,
|
||||
"lon": 37.5541,
|
||||
},
|
||||
"27614": {
|
||||
"station_code": "27614",
|
||||
"station_label": "Mikhailovskoye",
|
||||
"lat": 55.3671,
|
||||
"lon": 37.2033,
|
||||
},
|
||||
"27601": {
|
||||
"station_code": "27601",
|
||||
"station_label": "Krasnogorsk",
|
||||
"lat": 55.8069,
|
||||
"lon": 37.3446,
|
||||
},
|
||||
"27416": {
|
||||
"station_code": "27416",
|
||||
"station_label": "Moscow (Strogino)",
|
||||
@@ -49,8 +67,22 @@ RUSSIA_MOSCOW_STATIONS: Dict[str, Dict[str, Any]] = {
|
||||
"lat": 55.7455,
|
||||
"lon": 37.6300,
|
||||
},
|
||||
"27619": {
|
||||
"station_code": "27619",
|
||||
"station_label": "Moscow (Tushino)",
|
||||
"lat": 55.8783,
|
||||
"lon": 37.4367,
|
||||
},
|
||||
"27621": {
|
||||
"station_code": "27621",
|
||||
"station_label": "Gorki Leninskie",
|
||||
"lat": 55.5079,
|
||||
"lon": 37.7755,
|
||||
},
|
||||
}
|
||||
|
||||
RUSSIA_MOSCOW_MAP_STATION_LIMIT = 10
|
||||
|
||||
|
||||
class RussiaStationSourceMixin:
|
||||
def _ru_http_get_text(self, url: str) -> str:
|
||||
@@ -312,7 +344,7 @@ class RussiaStationSourceMixin:
|
||||
item.get("station_label") or "",
|
||||
)
|
||||
)
|
||||
trimmed = rows[:6]
|
||||
trimmed = rows[:RUSSIA_MOSCOW_MAP_STATION_LIMIT]
|
||||
record_source_call(
|
||||
"ru_station_web",
|
||||
"nearby",
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
from src.data_collection.russia_station_sources import (
|
||||
RUSSIA_MOSCOW_MAP_STATION_LIMIT,
|
||||
RUSSIA_MOSCOW_STATIONS,
|
||||
RussiaStationSourceMixin,
|
||||
)
|
||||
|
||||
|
||||
def test_moscow_station_registry_includes_vnukovo_nearby_ring():
|
||||
assert "27524" in RUSSIA_MOSCOW_STATIONS
|
||||
assert "27500" in RUSSIA_MOSCOW_STATIONS
|
||||
assert RUSSIA_MOSCOW_STATIONS["27500"]["station_label"] == "Tolstopaltsevo"
|
||||
assert RUSSIA_MOSCOW_MAP_STATION_LIMIT == 10
|
||||
|
||||
|
||||
def test_fetch_moscow_official_nearby_keeps_nearest_ten_station_rows():
|
||||
class FakeRussiaSource(RussiaStationSourceMixin):
|
||||
CITY_REGISTRY = {
|
||||
"moscow": {
|
||||
"lat": 55.5915,
|
||||
"lon": 37.2615,
|
||||
}
|
||||
}
|
||||
|
||||
def _ru_cached_station_current(self, station_code, station_meta, use_fahrenheit=False):
|
||||
return {
|
||||
"station_code": station_code,
|
||||
"station_label": station_meta["station_label"],
|
||||
"name": station_meta["station_label"],
|
||||
"lat": station_meta["lat"],
|
||||
"lon": station_meta["lon"],
|
||||
"temp": 10.0,
|
||||
"source_code": "ru_station_web",
|
||||
}
|
||||
|
||||
rows = FakeRussiaSource().fetch_russia_moscow_official_nearby("moscow")
|
||||
|
||||
assert len(rows) == RUSSIA_MOSCOW_MAP_STATION_LIMIT
|
||||
assert rows[0]["station_code"] == "27524"
|
||||
assert rows[1]["station_code"] == "27500"
|
||||
assert all(row["distance_km"] is not None for row in rows)
|
||||
Reference in New Issue
Block a user