Repository navigation
test: add coverage for lab_results dir loading and toxicity flag branches - #80
Merged
Merged
Conversation
…lags data/lab_results.py: 74% → 100% - load_lab_results_dir() was completely untested (lines 40-54 uncovered) - Added TestLoadLabResultsDir with 7 tests: empty directory, load all valid files, sort by assay_date, sort by result_id within same date, skip invalid JSON with warning, skip schema-invalid files with warning, ignore non-.json files - This function is the entry point for wet-lab result ingestion in the active-learning loop — covering it is scientifically important reports/batch_pack.py: 97% → 100% - Four _toxicity_flags() branches uncovered (charge_density, cysteine_fraction, longest_repeat_run, length_exceeds_35aa) - Cluster truncation line (>20 clusters → "more clusters" footer) uncovered - Added 6 new tests in TestToxicityHemolysisRiskReport and TestWriteBatchPackMarkdown to cover all remaining branches Overall coverage: 87.40% → 88.22% (+0.82 pp, 13 fewer uncovered lines) 1258 tests (was 1245)
HIGH: - test_sorted_by_assay_date: file creation order and date order were identical (RES-000→2026-07-01, etc.) so the sort was never exercised. Rewrote to use out-of-order dates (0→03, 1→01, 2→02) and assert the first result has the earliest date — a genuine regression test now. - test_skips_schema_invalid_file_with_warning: added identity assertion `results[0]["result_id"] == "GOOD-001"` matching the pattern from the sibling JSON-parse test; prevents a silent inversion where the wrong file is retained. LOW: - test_length_exceeds_35aa_flagged: sequence is 36 AA (not 37), corrected comment; removed redundant explicit features["length"] override since _make_candidate already derives length from len(sequence)
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.
Summary
Two modules had meaningful coverage gaps that are now closed.
data/lab_results.py: 74% → 100%load_lab_results_dir()was completely untested (all 12 lines uncovered). This function is the primary entry point for reading wet-lab assay results in the active-learning loop — if it silently drops malformed result files, the active-learning cycle would feed the next generation with a corrupted dataset.Added
TestLoadLabResultsDirwith 7 tests:test_empty_directory_returns_empty_listtest_loads_all_valid_filestest_sorted_by_assay_datetest_sorted_by_result_id_within_same_datetest_skips_invalid_json_file_with_warning— confirms malformed JSON triggers a Python warning and the valid files still loadtest_skips_schema_invalid_file_with_warning— confirms schema violations are skipped safelytest_non_json_files_ignoredreports/batch_pack.py: 97% → 100%Five branches uncovered:
_toxicity_flags()had 4 branch-true paths untested:high_charge_density,high_cysteine_fraction,long_repeat_run,length_exceeds_35aawrite_batch_pack_markdown()had the cluster-truncation footer ("| … | … | (N more clusters)") untested — only triggered with >20 distinct clustersAdded 6 new tests to
TestToxicityHemolysisRiskReportandTestWriteBatchPackMarkdown:test_high_charge_density_flaggedtest_high_cysteine_fraction_flaggedtest_long_repeat_run_flaggedtest_length_exceeds_35aa_flaggedtest_n_with_risk_flags_counts_correctlytest_markdown_truncates_clusters_beyond_20Metrics
lab_results.pybatch_pack.pyTest plan
make coverage→ 1258 passed, 88.22%🤖 Generated with Claude Code