Files
agessaman f279f2be0e refactor: one make_retry_session for the weather HTTP clients
wx, rain and the weather service each built the same requests session (two retries on connection errors and 5xx for GET, 0.3 s backoff, status codes not raised, 10x20 connection pool). It now lives in modules/http_retry.py; each class keeps its _create_retry_session as a one-line delegate, and each keeps its own session lifetime (rain still builds one per call).
2026-10-01 01:38:51 -07:00

22 lines
790 B
Python

"""make_retry_session keeps the retry policy the weather paths were built with."""
from modules.http_retry import make_retry_session
def test_retry_policy_and_pooling():
session = make_retry_session()
for prefix in ("https://", "http://"):
adapter = session.get_adapter(prefix + "example.invalid")
retry = adapter.max_retries
assert retry.total == 2
assert retry.backoff_factor == 0.3
assert set(retry.status_forcelist) == {500, 502, 503, 504}
assert set(retry.allowed_methods) == {"GET"}
assert retry.raise_on_status is False
assert adapter._pool_connections == 10
assert adapter._pool_maxsize == 20
def test_each_call_returns_a_new_session():
assert make_retry_session() is not make_retry_session()