-
-
Notifications
You must be signed in to change notification settings - Fork 8
fix: update import to fix test #291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds a mock-based test for a commit-message file-not-found path and updates a branch-validator test to patch Changes
Sequence Diagram(s)sequenceDiagram
participant Test as pytest
participant Engine as commit_check.engine
participant Git as git (mocked)
rect rgba(200,230,255,0.25)
note over Test,Engine: Commit message validator (file-not-found path)
Test->>Engine: call validator (get_commit_info patched)
Engine->>Git: patched get_commit_info side_effect -> simulate missing file / invalid message
Git-->>Engine: error / invalid output
Engine-->>Test: validator returns failure/assertion observed
end
rect rgba(220,255,220,0.18)
note over Test,Engine: Branch validation (patched import path)
Test->>Engine: call branch validator (get_branch_name patched at engine)
Engine-->>Test: mocked branch name returned -> validation path executed
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #291 +/- ##
===========================================
- Coverage 97.80% 79.94% -17.87%
===========================================
Files 8 8
Lines 365 673 +308
===========================================
+ Hits 357 538 +181
- Misses 8 135 +127 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #291 will not alter performanceComparing Summary
Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/engine_test.py (1)
97-111: Consider using.get()for safer dict lookup and adding call count assertion.The test correctly mocks the file-not-found scenario, but could be improved for consistency:
Line 101-104 uses
[format_str]for dict lookup, which raisesKeyErrorif an unexpected format string is passed. The similar test at line 120 uses.get(format_str, "")which is safer.The similar test at line 128-129 verifies
mock_get_commit_info.call_count == 2. Consider adding the same assertion here for consistency.Apply this diff for improved robustness:
# Mock git fallback to return a message that doesn't match regex mock_get_commit_info.side_effect = lambda format_str: { "s": "invalid commit message", "b": "", - }[format_str] + }.get(format_str, "") rule = ValidationRule(check="message", regex=r"^feat:") validator = CommitMessageValidator(rule) context = ValidationContext(commit_file="/nonexistent/file") result = validator.validate(context) assert result == ValidationResult.FAIL + assert mock_get_commit_info.call_count == 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/engine_test.py(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
tests/**
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Ensure tests run via pytest -v and cover commit, branch, author, and CLI behaviors
Files:
tests/engine_test.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: install (3.13, ubuntu-24.04)
- GitHub Check: install (3.13, windows-latest)
- GitHub Check: install (3.10, macos-latest)
- GitHub Check: install (3.11, windows-latest)
- GitHub Check: install (3.12, ubuntu-24.04)
- GitHub Check: install (3.10, ubuntu-24.04)
- GitHub Check: install (3.12, windows-latest)
- GitHub Check: install (3.9, windows-latest)
- GitHub Check: install (3.9, macos-latest)
- GitHub Check: install (3.10, windows-latest)
- GitHub Check: Run benchmarks
🔇 Additional comments (1)
tests/engine_test.py (1)
133-133: LGTM! Patch target correctly aligned with engine module.The decorator now patches
commit_check.engine.get_branch_name, which aligns with where the function is imported in the engine module. This is consistent with other tests in the file (lines 145, 349) and fixes the test as indicated in the PR title.
|



Summary by CodeRabbit
Tests
Documentation