Harden Open-Meteo rate limiting

This commit is contained in:
2569718930@qq.com
2026-05-18 00:13:51 +08:00
parent 6cee86ec7b
commit fd59cd018d
8 changed files with 178 additions and 23 deletions
+11
View File
@@ -4,6 +4,7 @@ import time
from src.database.runtime_state import (
DailyRecordRepository,
OpenMeteoCacheRepository,
OpenMeteoRateLimitRepository,
ProbabilitySnapshotRepository,
RuntimeStateDB,
TelegramAlertStateRepository,
@@ -77,6 +78,16 @@ def test_open_meteo_cache_repository_roundtrip(tmp_path, monkeypatch):
assert loaded['ensemble']['ankara']['spread'] == 1.5
def test_open_meteo_rate_limit_repository_roundtrip(tmp_path, monkeypatch):
monkeypatch.setenv('POLYWEATHER_DB_PATH', str(tmp_path / 'polyweather.db'))
repo = OpenMeteoRateLimitRepository(RuntimeStateDB(str(tmp_path / 'polyweather.db')))
repo.set_until(12345.0, reason='429')
loaded = repo.load_until()
assert loaded == 12345.0
def test_truth_record_repository_tracks_revisions(tmp_path, monkeypatch):
monkeypatch.setenv('POLYWEATHER_DB_PATH', str(tmp_path / 'polyweather.db'))
db = RuntimeStateDB(str(tmp_path / 'polyweather.db'))