#1230: Mock Maven in NPath unit tests#1247
Conversation
📝 WalkthroughWalkthroughThis PR updates several test files: it removes an ChangesTest Suite Fixes and Unskipping
Estimated code review effort: 2 (Simple) | ~12 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ 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)
test/metrics/npath/test_all_types.py (1)
28-52: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueFake
subprocess.runstub tightly bound to production call signature.
fake_run(args, cwd, check, **kwargs)requirescwdandcheckto be passed as they currently are inaibolit/metrics/npath/main.py(subprocess.run(['mvn', 'pmd:pmd'], cwd=root, check=True, ...)). If that call signature ever changes (e.g., dropscheckor passescwdpositionally in a different order), these mocks will raise aTypeErrorinstead of a meaningful assertion failure.♻️ Optional: decouple stub from exact kwarg names
- def fake_run(args, cwd, check, **kwargs): + def fake_run(*args, cwd, **kwargs):🤖 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 `@test/metrics/npath/test_all_types.py` around lines 28 - 52, The fake subprocess.run helpers in _write_pmd_error_report and _write_pmd_complexity_report are too tightly coupled to the current call signature, so make fake_run accept arbitrary positional and keyword arguments instead of requiring cwd and check. Update the stub to extract only the values it needs from kwargs and avoid assuming the exact argument order used by aibolit/metrics/npath/main.py, so the tests fail with assertions rather than TypeError when the production call changes.
🤖 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 `@test/metrics/npath/test_all_types.py`:
- Around line 28-52: The fake subprocess.run helpers in _write_pmd_error_report
and _write_pmd_complexity_report are too tightly coupled to the current call
signature, so make fake_run accept arbitrary positional and keyword arguments
instead of requiring cwd and check. Update the stub to extract only the values
it needs from kwargs and avoid assuming the exact argument order used by
aibolit/metrics/npath/main.py, so the tests fail with assertions rather than
TypeError when the production call changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 83159d80-c236-42b7-a5e7-12ed1e1e99b8
⛔ Files ignored due to path filters (1)
test/stats/results_test.csvis excluded by!**/*.csv
📒 Files selected for processing (4)
test/config/test_config.pytest/metrics/npath/test_all_types.pytest/recommend/test_recommend_pipeline.pytest/stats/test_stats.py
Summary by CodeRabbit