throttle added

This commit is contained in:
Jun-te Kim 2026-05-13 14:02:36 +00:00
parent ff4ad07a2b
commit 2fb6a99956

View file

@ -1,12 +1,24 @@
# tests/test_address_to_uprn_csv.py
import csv
import time
import pytest
from pathlib import Path
from backend.address2UPRN.main import get_uprn
FIXTURE_PATH = Path(__file__).parent / "test_data.csv"
# Delay between live EPC API calls to stay under the (undocumented) rate limit.
# Each parametrized case fires at least one EPC request; without throttling,
# GitHub-hosted runners burst fast enough to hit 429s.
EPC_THROTTLE_SECONDS = 1.0
@pytest.fixture(autouse=True)
def _throttle_epc_requests():
yield
time.sleep(EPC_THROTTLE_SECONDS)
def load_test_cases():
with open(FIXTURE_PATH, newline="", encoding="utf-8") as f: