[test]: Backend unit test for the Like operator in QueryOps#8292
[test]: Backend unit test for the Like operator in QueryOps#8292rijulpoudel wants to merge 5 commits into
Conversation
|
Warning One or more dependencies are approaching or past End-of-Life. |
|
Warning Review limit reached
Next review available in: 51 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 backend unit tests for ChangesQueryOps LIKE tests
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 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.
🧹 Nitpick comments (1)
specifyweb/backend/stored_queries/tests/test_query_ops.py (1)
10-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider extracting a shared assertion helper to reduce duplication.
All four test methods repeat the same three-step pattern: call
op_like, compile withliteral_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
📒 Files selected for processing (1)
specifyweb/backend/stored_queries/tests/test_query_ops.py
Fixes #8291
Summary by CodeRabbit