Unit tests for base_store - #2254
Conversation
📝 WalkthroughWalkthroughThe test module adds an SQLite-backed ChangesCRUD store tests
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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 |
|
Reviewed: additive expansion of the existing base_store tests (+13, 0 deleted) - CRUD, rowcounts, duplicate-key integrity, and owner-scoping isolation incl. the id-not-owner scoping negatives. On-card, merging on green. The highest-value base_store test is still missing though - a red-capable pin of the SCHEMA-runs-before-_post_init ordering contract (the boot-brick class that has bitten three stores); carding that separately rather than blocking this. |
PR Summary by QodoAdd CRUD-focused tests for BaseStore connection lifecycle
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
|
nemotron-ultra-kilo review VERDICT: Minor style inconsistency; tests are comprehensive and correct.
Automated first-pass review by the nemotron-ultra-kilo lane. The lead still reviews before merge. |
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTo customize comments, go to the Qodo configuration screen, or learn more in the docs. |
|
nemotron-ultra-orB review VERDICT: Tests are functionally correct but have fragile patterns and missing edge-case coverage.
Automated first-pass review by the nemotron-ultra-orB lane. The lead still reviews before merge. |
|
nemotron-super review VERDICT: Pass Automated first-pass review by the nemotron-super lane. The lead still reviews before merge. |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
tests/test_base_store.py (2)
165-170: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider
zip(..., strict=True)for column/row alignment.
_row_to_dictzips_COLUMNSwithrowwithoutstrict=True. If a future SELECT statement's column list and_COLUMNSever fall out of sync,zipsilently truncates instead of raising an error.♻️ Proposed fix
def _row_to_dict(row) -> dict | None: - return dict(zip(_COLUMNS, row)) if row is not None else None + return dict(zip(_COLUMNS, row, strict=True)) if row is not None else None🤖 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_base_store.py` around lines 165 - 170, Update _row_to_dict to use strict zip semantics when pairing _COLUMNS with row, so mismatched column and row lengths raise an error instead of silently truncating; preserve the existing None-to-None behavior.Source: Linters/SAST tools
172-183: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value
UNIQUE(owner, key)does not prevent duplicate keys whenownerisNULL.SQLite treats
NULLvalues as distinct for uniqueness purposes, so two rows withowner = NULLand the samekeywould both insert successfully without raisingsqlite3.IntegrityError. None of the added tests exercise this case (test_duplicate_owner_key_raises_integrityandtest_duplicate_key_allowed_across_ownersonly use non-null owners). Confirm whether this NULL-owner gap is intentional for this fixture, since a reader could otherwise assume(owner, key)is always enforced as unique.🤖 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_base_store.py` around lines 172 - 183, The CrudStore schema’s UNIQUE(owner, key) constraint does not enforce uniqueness for NULL owners. Update the fixture or its tests to explicitly define and verify the intended NULL-owner behavior, ensuring readers are not misled about whether duplicate keys with owner=NULL should be rejected.
🤖 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_base_store.py`:
- Around line 165-170: Update _row_to_dict to use strict zip semantics when
pairing _COLUMNS with row, so mismatched column and row lengths raise an error
instead of silently truncating; preserve the existing None-to-None behavior.
- Around line 172-183: The CrudStore schema’s UNIQUE(owner, key) constraint does
not enforce uniqueness for NULL owners. Update the fixture or its tests to
explicitly define and verify the intended NULL-owner behavior, ensuring readers
are not misled about whether duplicate keys with owner=NULL should be rejected.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 9f956f33-5200-4c8b-b81a-b812bff0824e
📒 Files selected for processing (1)
tests/test_base_store.py
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 file)
Reviewed by step-3.7-flash · Input: 139.2K · Output: 26K · Cached: 1.2M |
CARD TITLE (intent, not commit subject): Unit tests for base_store
Autonomous build of board card tsk-k44oda.
Files:
tests/test_base_store.py | 226 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 225 insertions(+), 1 deletion(-)
Summary by CodeRabbit