[Test Improver] tests: improve coverage for security scanner and audit command#317
Draft
danielmeppiel wants to merge 1 commit intomainfrom
Draft
Conversation
- Add TestClassify for ContentScanner.classify() (lines 195-201) - Add tests for corrupt/invalid lockfile path (audit.py line 87) - Add test for missing deployed file skipped silently (line 104) - Add test for symlink skipping in directory scans (line 65) - Add TestApplyStripEdgeCases: nonexistent abs path (line 302) and write error handling (lines 311-312) - Add test for _render_summary info+warning combined note (line 270) content_scanner.py: 91% → 100% audit.py: 92% → 96% Total new tests: +12 (67 → 79) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is a draft PR from Test Improver, an automated AI assistant focused on improving tests.
Goal and rationale
The
apm auditcommand andContentScannersecurity module were merged in #313 with good initial tests (26 tests), but several meaningful code paths were untested — particularly theclassify()utility method, error-handling branches, and edge cases that guard against malformed lockfiles and filesystem issues. Since this is security-critical code (detecting hidden Unicode prompt injection), strong test coverage is especially valuable.Approach
Targeted tests for uncovered code paths, organized into logical classes:
test_content_scanner.py— newTestClassifyclass:ContentScanner.classify()method (lines 195–201): combinedhas_critical + summarizein one pass — not tested at all previously.test_audit_command.py— new and extended tests:TestApplyStripEdgeCases:modified=0without crashing_render_summaryshows combined note when both info and warning findings are presentCoverage impact
security/content_scanner.pycommands/audit.pyTests added: 67 → 79 (+12)
The only remaining uncovered lines (205–220) are the Rich→plaintext fallback rendering path, which would require mocking Rich's import mechanism and adds test complexity disproportionate to the value.
Test status
All existing tests continue to pass. Black + isort applied.
Reproducibility