Strip Wunderground data from city cache responses

This commit is contained in:
2569718930@qq.com
2026-06-14 23:47:25 +08:00
parent d1124ae17e
commit 3b34ddbf12
4 changed files with 12 additions and 47 deletions
+5 -6
View File
@@ -53,7 +53,7 @@ def test_city_payloads_expose_wunderground_current():
assert detail["timeseries"]["wunderground_today_obs"] == [{"time": "13:30", "temp": 26}]
def test_api_payload_overlay_uses_cached_wunderground_state_without_fetch(monkeypatch):
def test_api_payload_overlay_strips_cached_wunderground_state_without_fetch(monkeypatch):
stale_payload = {
"name": "guangzhou",
"temp_symbol": "°C",
@@ -87,12 +87,11 @@ def test_api_payload_overlay_uses_cached_wunderground_state_without_fetch(monkey
monkeypatch.setattr(city_runtime._weather, "fetch_wunderground_historical", fail_fetch)
overlay = getattr(city_runtime, "_overlay_latest_wunderground_current", None)
assert callable(overlay), "city API must preserve cached WU state without direct fetch"
assert callable(overlay), "city API must strip cached WU state without direct fetch"
payload = overlay("guangzhou", stale_payload)
assert payload["wunderground_current"]["temp"] == 36
assert payload["wunderground_current"]["max_so_far"] == 36
assert payload["official"]["wunderground_current"]["max_so_far"] == 36
assert payload["timeseries"]["wunderground_today_obs"] == [{"time": "14:00", "temp": 36}]
assert "wunderground_current" not in payload
assert "wunderground_current" not in payload["official"]
assert "wunderground_today_obs" not in payload["timeseries"]
assert stale_payload["wunderground_current"]["max_so_far"] == 36
assert fetch_calls == []
-1
View File
@@ -205,7 +205,6 @@ def test_fetch_all_sources_delegates_non_hf_forecast_bundle(monkeypatch, tmp_pat
monkeypatch.setattr(collector, "_log_temperature_unit", lambda *args, **kwargs: None)
monkeypatch.setattr(collector, "_evict_city_caches", lambda *args, **kwargs: None)
monkeypatch.setattr(collector, "_attach_settlement_sources", lambda *args, **kwargs: None)
monkeypatch.setattr(collector, "_attach_wunderground_historical", lambda *args, **kwargs: None)
monkeypatch.setattr(collector, "_supports_aviationweather", lambda city: False)
monkeypatch.setattr(collector, "_attach_turkish_mgm_data", lambda *args, **kwargs: None)
monkeypatch.setattr(collector, "_attach_korean_amos_data", lambda *args, **kwargs: None)