Skip to content

[test]: Backend unit test for the Like operator in QueryOps#8292

Open
rijulpoudel wants to merge 5 commits into
mainfrom
issue-8291
Open

[test]: Backend unit test for the Like operator in QueryOps#8292
rijulpoudel wants to merge 5 commits into
mainfrom
issue-8291

Conversation

@rijulpoudel

@rijulpoudel rijulpoudel commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Fixes #8291

Summary by CodeRabbit

  • Tests
    • Added automated coverage for search pattern matching.
    • Verified support for percent and underscore wildcards, exact values, and standard contains-style patterns.

@github-actions

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=-71

--- 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=844

--- 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=-94

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


@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

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

Next review available in: 51 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: 2393a518-8c62-497b-bca4-27da71eeb824

📥 Commits

Reviewing files that changed from the base of the PR and between 966aa35 and 5a649d5.

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

Walkthrough

Adds backend unit tests for QueryOps.op_like, covering SQL compilation with percent wildcards, underscore wildcards, and exact input values.

Changes

QueryOps LIKE tests

Layer / File(s) Summary
LIKE expression test coverage
specifyweb/backend/stored_queries/tests/test_query_ops.py
Adds a QueryOps test fixture and checks compiled SQL for four op_like input patterns.
🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Testing Instructions ⚠️ Warning The PR body leaves the required Testing instructions section empty, so there's no clear verification step for the QueryOps.op_like change. Add a brief testing section, e.g. run specifyweb/backend/stored_queries/tests/test_query_ops.py, and note it covers QueryOps.op_like.
✅ Passed checks (5 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 main change: backend unit tests for QueryOps Like behavior.
Linked Issues check ✅ Passed The new tests cover QueryOps op_like behavior for basic, wildcard, and non-wildcard patterns as requested.
Out of Scope Changes check ✅ Passed The changes are limited to the requested unit tests and do not introduce unrelated scope.
Automatic Tests ✅ Passed PASS: The PR adds an automatic unit test module with TestCase/test_ methods covering QueryOps.op_like, so tests are included.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-8291

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.

🧹 Nitpick comments (1)
specifyweb/backend/stored_queries/tests/test_query_ops.py (1)

10-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider extracting a shared assertion helper to reduce duplication.

All four test methods repeat the same three-step pattern: call op_like, compile with literal_binds, assert the SQL string. A small helper would centralize the compile logic and make adding future cases trivial.

♻️ Optional refactor
     def setUp(self):
         self.ops = QueryOps(uiformatter=None)

+    def assert_like_sql(self, value, expected_sql):
+        result = self.ops.op_like(column("catalogNumber"), value)
+        sql = str(result.compile(compile_kwargs={"literal_binds": True}))
+        self.assertEqual(sql, expected_sql)
+
     def test_op_like_basic(self):
-        result = self.ops.op_like(column("catalogNumber"), "%test%")
-        sql = str(result.compile(compile_kwargs={"literal_binds": True}))
-        self.assertEqual(sql, '"catalogNumber" LIKE \'%test%\'')
+        self.assert_like_sql("%test%", '"catalogNumber" LIKE \'%test%\'')

     def test_op_like_percent_wildcard(self):
-        result = self.ops.op_like(column("catalogNumber"), "2025%")
-        sql = str(result.compile(compile_kwargs={"literal_binds": True}))
-        self.assertEqual(sql, '"catalogNumber" LIKE \'2025%\'')
+        self.assert_like_sql("2025%", '"catalogNumber" LIKE \'2025%\'')

     def test_op_like_underscore_wildcard(self):
-        result = self.ops.op_like(column("catalogNumber"), "202_")
-        sql = str(result.compile(compile_kwargs={"literal_binds": True}))
-        self.assertEqual(sql, '"catalogNumber" LIKE \'202_\'')
+        self.assert_like_sql("202_", '"catalogNumber" LIKE \'202_\'')

     def test_op_like_no_wildcard(self):
-        result = self.ops.op_like(column("catalogNumber"), "exact")
-        sql = str(result.compile(compile_kwargs={"literal_binds": True}))
-        self.assertEqual(sql, '"catalogNumber" LIKE \'exact\'')
+        self.assert_like_sql("exact", '"catalogNumber" LIKE \'exact\'')
🤖 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_query_ops.py` around lines 10 -
28, Extract the repeated op_like invocation, SQL compilation, and assertion into
a shared helper method in the test class, then update test_op_like_basic,
test_op_like_percent_wildcard, test_op_like_underscore_wildcard, and
test_op_like_no_wildcard to call it with the pattern and expected SQL.
🤖 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 `@specifyweb/backend/stored_queries/tests/test_query_ops.py`:
- Around line 10-28: Extract the repeated op_like invocation, SQL compilation,
and assertion into a shared helper method in the test class, then update
test_op_like_basic, test_op_like_percent_wildcard,
test_op_like_underscore_wildcard, and test_op_like_no_wildcard to call it with
the pattern and expected SQL.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2dce53be-e623-4f01-b7a5-9f3ae72dc36a

📥 Commits

Reviewing files that changed from the base of the PR and between 192882b and 966aa35.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋Back Log

Development

Successfully merging this pull request may close these issues.

[test]: Backend unit test for the Like operator in QueryOps

1 participant