Shorten the climate period to what the free hourly limit allows, and wait out that limit

This commit is contained in:
swaits committed 2026-11-20 10:50:09 -07:00
1 parent f7e2757e2b
commit 987a25c6cb
3 files changed
+63 -18

No files matched your search

+20
View File
@@ -92,6 +92,26 @@ class OpenMeteoTest(unittest.TestCase):
opener=FakeOpener("open_meteo_nodata.json"))
self.assertIsNone(got)
def test_a_429_is_retried_after_a_pause(self):
import urllib.error
from unittest import mock
calls = []
def flaky(req, timeout=None):
calls.append(req.full_url)
if len(calls) == 1:
raise urllib.error.HTTPError(
req.full_url, 429, "Too Many Requests",
{"Retry-After": "0"}, None)
return FakeResponse(fixture_bytes("open_meteo_alpine.json"))
with tempfile.TemporaryDirectory() as cache:
with mock.patch.object(C.time, "sleep", lambda s: None):
got = C.fetch_normals(37.7, -119.5, 3400.0, cache=cache,
opener=flaky)
self.assertIsNotNone(got)
self.assertEqual(len(calls), 2)
def test_the_desert_and_coast_fixtures_parse(self):
with tempfile.TemporaryDirectory() as cache:
desert = C.fetch_normals(32.2, -110.9, 800.0, cache=cache,