Summary
test_package_endpoint_throttling in packagedb/tests/test_throttling.py
is consistently failing with a 429 Too Many Requests response when
the test expects a 200 OK.
Steps to Reproduce
Run the test suite:
python manage_purldb.py test packagedb.tests.test_throttling
Expected Behavior
The test should return 200 OK as the throttle limit should not
be triggered during a controlled test environment.
Actual Behavior
FAIL: test_package_endpoint_throttling
AssertionError: 429 != 200
Root Cause (suspected)
The throttle rate counter is likely not being reset between test runs,
causing requests from previous tests to count toward the throttle limit.
This means by the time test_package_endpoint_throttling runs, the
throttle has already been triggered.
Possible Fix
- Override
DEFAULT_THROTTLE_RATES to None or a high value in test settings
- Or explicitly reset the throttle cache between tests using
cache.clear() in the test setUp() method
Environment
- Python 3.13
- Django test runner via
manage_purldb.py
References
- Related to throttling logic in
packagedb/throttling.py
- Test file:
packagedb/tests/test_throttling.py
Summary
test_package_endpoint_throttlinginpackagedb/tests/test_throttling.pyis consistently failing with a
429 Too Many Requestsresponse whenthe test expects a
200 OK.Steps to Reproduce
Run the test suite:
python manage_purldb.py test packagedb.tests.test_throttlingExpected Behavior
The test should return
200 OKas the throttle limit should notbe triggered during a controlled test environment.
Actual Behavior
Root Cause (suspected)
The throttle rate counter is likely not being reset between test runs,
causing requests from previous tests to count toward the throttle limit.
This means by the time
test_package_endpoint_throttlingruns, thethrottle has already been triggered.
Possible Fix
DEFAULT_THROTTLE_RATEStoNoneor a high value in test settingscache.clear()in the testsetUp()methodEnvironment
manage_purldb.pyReferences
packagedb/throttling.pypackagedb/tests/test_throttling.py