[test]: Backend unit test for query sorting (ascending and descending)#8304
[test]: Backend unit test for query sorting (ascending and descending)#8304rijulpoudel wants to merge 4 commits into
Conversation
|
Warning One or more dependencies are approaching or past End-of-Life. |
|
Warning Review limit reached
Next review available in: 58 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds Django tests for ephemeral stored query sorting, covering authenticated ascending and descending requests and validating five returned rows in the expected order. ChangesStored query sorting
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
specifyweb/backend/stored_queries/tests/test_views/test_sorting.py (1)
22-22: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSimplify JSON response parsing.
Django's
HttpResponseprovides a.json()method that automatically decodes the JSON content, makingjson.loads(response.content.decode())unnecessary. You can also remove theimport jsonstatement at the top of the file if you apply this change.
specifyweb/backend/stored_queries/tests/test_views/test_sorting.py#L22-L22: Replace withresults = response.json()["results"].specifyweb/backend/stored_queries/tests/test_views/test_sorting.py#L44-L44: Replace withresults = response.json()["results"].🤖 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 `@specifyweb/backend/stored_queries/tests/test_views/test_sorting.py` at line 22, In specifyweb/backend/stored_queries/tests/test_views/test_sorting.py at lines 22-22 and 44-44, replace both manual JSON decoding expressions with response.json()["results"], and remove the now-unused json import.
🤖 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.
Inline comments:
In `@specifyweb/backend/stored_queries/tests/test_views/test_sorting.py`:
- Around line 16-17: In
specifyweb/backend/stored_queries/tests/test_views/test_sorting.py at lines
16-17 and 38-39, replace the shallow .copy() on get_simple_query(...) with
copy.deepcopy(...) and add the copy import, preserving the existing nested
sorttype mutations without sharing state between tests.
---
Nitpick comments:
In `@specifyweb/backend/stored_queries/tests/test_views/test_sorting.py`:
- Line 22: In specifyweb/backend/stored_queries/tests/test_views/test_sorting.py
at lines 22-22 and 44-44, replace both manual JSON decoding expressions with
response.json()["results"], and remove the now-unused json import.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 55100934-8154-41cb-a7d8-49de3e5c40f7
📒 Files selected for processing (1)
specifyweb/backend/stored_queries/tests/test_views/test_sorting.py
Fixes #8303
Summary by CodeRabbit