Skip to content

[test]: Backend unit test for query sorting (ascending and descending)#8304

Open
rijulpoudel wants to merge 4 commits into
mainfrom
issue-8303
Open

[test]: Backend unit test for query sorting (ascending and descending)#8304
rijulpoudel wants to merge 4 commits into
mainfrom
issue-8303

Conversation

@rijulpoudel

@rijulpoudel rijulpoudel commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Fixes #8303

Summary by CodeRabbit

  • Tests
    • Added coverage to verify that stored query results are returned in the correct ascending order.
    • Added coverage to verify that stored query results are returned in the correct descending order.
    • Confirmed stable ordering and successful responses for ephemeral stored queries.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

Warning

One or more dependencies are approaching or past End-of-Life.
Please plan upgrades accordingly.

STATUS=WARNING
NODE_VERSION=20
NODE_CYCLE=20
EOL_DATE=2026-04-30
DAYS_REMAINING=-76

--- Node.js ---
Version: 20
EOL: 2026-04-30
Status: WARNING

STATUS=OK
PYTHON_VERSION=3.12
PYTHON_CYCLE=3.12
EOL_DATE=2028-10-31
DAYS_REMAINING=839

--- Python ---
Version: 3.12
EOL: 2028-10-31
Status: OK

STATUS=WARNING
DJANGO_VERSION=4.2
DJANGO_CYCLE=4.2
EOL_DATE=2026-04-07
DAYS_REMAINING=-99

--- Django ---
Version: 4.2
EOL: 2026-04-07
Status: WARNING


@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@CarolineDenis, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b12d2f59-7a9a-4587-9a84-ef820902562d

📥 Commits

Reviewing files that changed from the base of the PR and between 25ec887 and f11a669.

📒 Files selected for processing (1)
  • specifyweb/backend/stored_queries/tests/test_views/test_sorting.py
📝 Walkthrough

Walkthrough

Adds Django tests for ephemeral stored query sorting, covering authenticated ascending and descending requests and validating five returned rows in the expected order.

Changes

Stored query sorting

Layer / File(s) Summary
Ascending and descending sorting coverage
specifyweb/backend/stored_queries/tests/test_views/test_sorting.py
Defines TestSorting and verifies that authenticated ephemeral stored query requests return five rows in ascending or descending order based on sorttype.
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the new backend tests for ascending and descending query sorting.
Linked Issues check ✅ Passed The PR adds backend tests for query sorting as requested by issue #8303, covering both ascending and descending order.
Out of Scope Changes check ✅ Passed The changes are limited to a new sorting test module and do not show unrelated scope creep.
Automatic Tests ✅ Passed PR adds an automatic Django test module with two test_ methods in the tests tree for sorting behavior.
Testing Instructions ✅ Passed New tests explicitly cover /stored_query/ephemeral/ sorting in both directions and match the stored-query execution path.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-8303

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 value

Simplify JSON response parsing.

Django's HttpResponse provides a .json() method that automatically decodes the JSON content, making json.loads(response.content.decode()) unnecessary. You can also remove the import json statement at the top of the file if you apply this change.

  • specifyweb/backend/stored_queries/tests/test_views/test_sorting.py#L22-L22: Replace with results = response.json()["results"].
  • specifyweb/backend/stored_queries/tests/test_views/test_sorting.py#L44-L44: Replace with results = 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2deb51a and 25ec887.

📒 Files selected for processing (1)
  • specifyweb/backend/stored_queries/tests/test_views/test_sorting.py

Comment thread specifyweb/backend/stored_queries/tests/test_views/test_sorting.py Outdated
@github-project-automation github-project-automation Bot moved this from 📋Back Log to Dev Attention Needed in General Tester Board Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Dev Attention Needed

Development

Successfully merging this pull request may close these issues.

[test]: Backend unit test for query sorting

2 participants