-
-
Notifications
You must be signed in to change notification settings - Fork 313
Skip throttle checks during tests #4429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: DonnieBLT <[email protected]>
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Co-authored-by: DonnieBLT <[email protected]>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This PR resolves the issue where the throttling middleware was interfering with tests by rate-limiting requests during test execution. Tests often need to make many requests quickly, which would trigger the throttling mechanism and cause test failures.
Changes Made
1. Modified
blt/middleware/throttling.pysysimport to detect test modeshould_skip_throttle()method when"test" in sys.argv2. Updated
website/test_throttling_middleware.pytest_throttling_skipped_during_tests()to explicitly validate the skip behaviorTechnical Details
The solution uses Django's standard approach for detecting test mode by checking
sys.argv, which is consistent with how other parts of the codebase detect test execution. When tests are running, the middleware logs "Skipping throttling for test mode" and bypasses all throttling logic.Benefits
Verification
The debug logs clearly demonstrate the behavior:
DEBUG Skipping throttling for test modeDEBUG Throttle check for GET /path from IP: 127.0.0.1 - Current: 1/100Fixes #4428.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python manage.py test website.test_api --verbosity=1(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.