Skip to content

Fix throttle test cache reset#850

Open
clencyc wants to merge 2 commits intoaboutcode-org:mainfrom
clencyc:fix-throttle-test-cache-reset
Open

Fix throttle test cache reset#850
clencyc wants to merge 2 commits intoaboutcode-org:mainfrom
clencyc:fix-throttle-test-cache-reset

Conversation

@clencyc
Copy link
Copy Markdown

@clencyc clencyc commented Mar 20, 2026

Summary

Fixes a flaky test where test_package_endpoint_throttling was
failing with 429 != 200.

Root Cause

The throttle cache was not being cleared between test runs. Request
counts from previous tests were spilling over into this test, causing
the rate limit to trigger prematurely before the expected threshold.

Fix

Added cache.clear() at the start of setUp() to reset the throttle
cache before each test run.

Testing

All 109 tests now pass.

Fixes #849

clencyc added 2 commits March 20, 2026 16:26
- Add PackageMetadataFile model with ForeignKey to Package
- Store filename, filetype, content, download_url and sha1
- Add migration for new model
- Add test for PackageMetadataFile creation

Closes aboutcode-org#840

Signed-off-by: clencyc <clency2023@gmail.com>
The throttle cache was not being reset between test runs, causing
request counts from previous tests to spill over and trigger the
rate limit prematurely.

Fix by calling cache.clear() at the start of setUp().

Fixes #<replace-with-your-issue-number>

Signed-off-by: clencyc <clency2023@gmail.com>
@clencyc clencyc force-pushed the fix-throttle-test-cache-reset branch from f2e5136 to 8b8d061 Compare March 20, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_package_endpoint_throttling fails with 429 instead of expected 200

1 participant