feat: allow per-call GET request timeouts - #24
Conversation
|
Warning Review limit reached
More reviews will be available in 55 minutes and 17 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds per-call timeout override support to the REST API client. The ChangesPer-call timeout override
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/test_request_timeout.py (1)
75-84: ⚡ Quick winAdd a retry-path assertion for timeout reuse.
This test validates the first GET call timeout, but not the 401 re-auth retry path that was also changed. Please add a case that forces a 401 then verifies the retried
session.get(...)still uses the same per-call timeout override.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_request_timeout.py` around lines 75 - 84, Update the test_get_requests_allow_per_call_timeout_override to also exercise the 401 re-auth retry path: configure the fake session used by make_controller to return a 401 response first and a successful 200 on the retry (so controller.invoke_get_rest_api_call triggers the retry), call invoke_get_rest_api_call with timeout=2.5 as before, and then assert that the retried call recorded in controller.session.get_calls[1][1]["timeout"] is also 2.5 (i.e., verify the second get call preserves the per-call timeout override).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/test_request_timeout.py`:
- Around line 75-84: Update the
test_get_requests_allow_per_call_timeout_override to also exercise the 401
re-auth retry path: configure the fake session used by make_controller to return
a 401 response first and a successful 200 on the retry (so
controller.invoke_get_rest_api_call triggers the retry), call
invoke_get_rest_api_call with timeout=2.5 as before, and then assert that the
retried call recorded in controller.session.get_calls[1][1]["timeout"] is also
2.5 (i.e., verify the second get call preserves the per-call timeout override).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a6929cbb-2c8e-452f-be19-27ae77e9778a
📒 Files selected for processing (2)
tests/test_request_timeout.pyunifi_controller_api/api_client.py
|
Addressed in 0858194. Added Validation:
|
Summary
timeoutoverride toinvoke_get_rest_api_call(...)Test Plan
python -m pytest tests/test_request_timeout.py::test_get_requests_allow_per_call_timeout_override -q— failed before implementation withTypeErrorpython -m pytest tests/test_request_timeout.py -q— passpython -m pytest -q— passruff check .— passpython -m pip install -e '.[dev,docs]'— passpytest -q— passpython -m build— passtwine check dist/*— passsphinx-build -E -W -b html docs docs/_build/html— passgit diff --check— passSummary by CodeRabbit
New Features
Tests