Test coverage for reader.py and selection.py (0% → 79% / 100%) - #10
Merged
Conversation
These two modules had no test coverage. Add unit tests with no network: - test_selection.py: drives the interactive CaseSelector/wrappers via a fake Prompt.ask queue (pagination, single/multi/range selection, actions, the back/quit loops) -> selection.py 100%. - test_reader.py: DocketParser (fast parse, bs4 parse_data, the metadata extractors with crafted HTML, parse_dir) and DocketProcessor (text/docket/dir search + match writers), plus the no-bs4 fallback branches -> reader.py 79%. No source changes. The DocumentSorter stub is deliberately not tested (it is dead code removed in the governance PR), so these tests are compatible with both master and that branch. 58 new tests; full suite 218 passed, 6 skipped.
There was a problem hiding this comment.
Pull request overview
Adds comprehensive pytest coverage for two previously uncovered interactive/data-processing modules (selection.py and reader.py), without modifying runtime source code. This improves confidence in CLI/TUI selection flows and docket parsing/search behavior as coverage reporting is introduced.
Changes:
- Add deterministic tests for
CaseSelector/interactive_case_select/interactive_multi_selectby monkeypatchingPrompt.askwith a FIFO answer queue. - Add broad tests for
DocketParserandDocketProcessor, including parsing, directory processing, searching, and CSV output writers (with bs4-dependent portions gated byimportorskip/HAS_BS4).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/test_selection.py | Adds tests driving the Rich prompt-based selection logic via monkeypatched prompt responses. |
| tests/test_reader.py | Adds tests for docket parsing, metadata extraction, searching, and CSV writing behaviors in reader.py. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+79
to
+81
| # --------------------------------------------------------------------------- | ||
| # bs4-fallback branches (these run *because* bs4 is absent in this env) | ||
| # --------------------------------------------------------------------------- |
Comment on lines
+84
to
+85
| class TestDocketParserNoBs4Fallbacks: | ||
| """Cover the `if not HAS_BS4` early-return branches.""" |
…iew) The section header / class docstring implied the HAS_BS4-fallback tests run in this environment; under CI's .[dev,full] install bs4 is present so they skip. Reword to describe the condition (bs4 absent) per Copilot review.
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.
Fixes the two 0%-coverage modules surfaced when coverage reporting was wired up. Test-only — no source changes, branched off
masterso it's independent of the governance PRs (#6/#9).What's covered
tests/test_selection.py→selection.py0% → 100%. Drives the interactiveCaseSelector+interactive_case_select/interactive_multi_selectby swappingPrompt.askfor a queue of canned answers: pagination math, single-select (valid/out-of-range/non-numeric/next/prev/quit), multi-select (comma list, ranges, quit, bad format), the action menu, and the back/quit loops.tests/test_reader.py→reader.py0% → 79%. CoversDocketParser(fastparse/parse_file, the bs4parse_data, the metadata extractors with crafted HTML — new-dict + legacy-tupledetailed_info, lawyer/party tables — andparse_dir) andDocketProcessor(text/docket/dir search + the CSV match writers), plus theif not HAS_BS4fallback branches (which run when bs4 is absent).58 new tests; full suite 218 passed, 6 skipped (the skips are the no-bs4 fallback tests, which only run when the
[full]extra isn't installed). pyflakes clean.Notes
DocumentSorterstub is intentionally not tested — it's removed in the governance PR (Preventive spend-governance layer + PACER-native MCP server #6), so skipping it keeps these tests compatible with bothmasterand that branch.reader.pygaps are the deadDocumentSorterlines (gone after Preventive spend-governance layer + PACER-native MCP server #6) and the one most-intricate legacy extractor (extract_case_metapositive path). The network-bound modules (downloader.py,pcl.py) are a separate, larger effort (they need an HTTP mock layer) and are not in scope here.https://claude.ai/code/session_01NNvhsYRVWhjfcdgaSmU5bt
Generated by Claude Code