Add comprehensive test coverage for broken_wikicode check#161
Open
xenacode-art wants to merge 1 commit into
Open
Add comprehensive test coverage for broken_wikicode check#161xenacode-art wants to merge 1 commit into
xenacode-art wants to merge 1 commit into
Conversation
This commit adds complete test coverage for the broken_wikicode detection
system, which previously had zero tests despite being a critical feature for
auto-review decisions.
Added tests cover:
1. Visible text extraction (9 tests)
- Basic text extraction from HTML
- Removal of script, style, code, pre, tt, syntaxhighlight tags
- Ensures code examples don't trigger false positives
- Edge cases: empty and None inputs
2. Math article detection (7 tests)
- Detection via math class attributes
- Detection via math tags
- Detection via LaTeX backslash syntax
- Detection via dollar sign inline math
- False negatives for regular articles
- Edge cases: empty and None inputs
3. Localized media keywords (5 tests)
- English, Finnish, German, French keywords
- Unknown language defaults to English
- Ensures internationalization works correctly
4. Indicator detection (14 tests)
- Template syntax {{}}
- Internal link syntax [[]]
- Broken ref, div, span tags (with HTML escaping)
- File/Category syntax with localization
- Section headers (== ignored in math articles)
- Code block exclusion to prevent false positives
- Multiple simultaneous indicators
- Empty input edge cases
5. Threshold logic and parent comparison (9 tests)
- Clean HTML returns no broken wikicode
- Single indicator low count (<3) ignored as noise
- Single indicator high count (>=3) detected
- Multiple indicator types (2+) always detected
- NEW indicators compared to parent HTML
- Pre-existing indicators not flagged
- Details message format verification
- Edge cases for threshold boundaries
- Localized keyword integration
Test results: All 44 tests pass successfully
This brings test coverage from 0% to comprehensive coverage of all
major code paths and edge cases in the broken_wikicode detection system.
Contributor
Author
|
Why threshold logic matters: Without it, a single stray Test Resultscd app
python manage.py test reviews.tests.autoreview.test_broken_wikicode
# Ran 44 tests in 0.041s - OK ✅
Impact
- Before: 0% test coverage on critical feature
- After: Comprehensive coverage of all code paths
- Benefits:
- Safe to refactor and improve detection logic
- Prevents regressions when making changes
- Documents expected behavior for future contributors
- Shows thorough understanding of internationalization needs
Key Testing Insights
1. HTML Entity Escaping: Tests use < and > because BeautifulSoup parses actual HTML
2. Math Article Special Handling: Tests verify == is ignored in math contexts
3. Threshold Edge Cases: Tests verify boundaries (count=2 vs 3, types=1 vs 2)
4. Localization: Tests cover multiple languages to ensure international wikis work
5. False Positive Prevention: Tests verify code blocks don't trigger detection
Checklist
- All 44 tests pass
- Tests cover all major code paths
- Tests cover edge cases (None, empty, boundaries)
- Tests document complex threshold logic
- Tests verify internationalization works
- No changes to production code (pure test addition) |
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.
Hi @zache-fi @ad-an-26 @ademolaomosanya ,
This commit adds complete test coverage for the broken_wikicode detection system, which previously had zero tests despite being a critical feature for auto-review decisions.
Added tests cover:
Visible text extraction (9 tests)
Math article detection (7 tests)
Localized media keywords (5 tests)
Indicator detection (14 tests)
Threshold logic and parent comparison (9 tests)
Test results: All 44 tests pass successfully
This brings test coverage from 0% to comprehensive coverage of all major code paths and edge cases in the broken_wikicode detection system.