Repository navigation
test: external_predict and config coverage — final pre-synthesis gates - #21
Merged
Merged
Conversation
…gates - tests/test_external_predict.py (31 tests): write_pilot_fasta: file creation, FASTA header format (id/rank/seed), sequence body, empty panel, missing optional fields, newline termination write_external_predict_checklist: all 3 tools named, panel size, result table rows, 2/3-agreement gate, disclaimer, generated_at conditional, fasta path ref write_confident_panel: keeps only specified IDs, re-ranks 1..n, handles empty and nonexistent IDs, writes .csv and .md outputs - tests/test_config.py (11 tests): load_config: valid YAML, real pipeline config (filters/weights/selection), weights sum to 1.0, string path, missing file raises, empty YAML, list/numeric/bool values preserved 705 tests total (was 663).
…ormed YAML test
test_external_predict.py:
- fix E741: rename l → line in list comprehension
- add test_empty_sequence_in_candidate_writes_blank_body_line: documents that
callers must validate sequences before write_pilot_fasta (blank FASTA body line
risks silent misparse by external prediction tools)
- add test_output_order_follows_panel_not_keep_ids: documents that keep_ids order
is not honoured — output order is always panel order
- fix test_two_thirds_agreement_rule_stated: use '≥2' or '2/3' instead of '2'
config.py:
- load_config now raises ValueError('Config file is empty') when yaml.safe_load
returns None; protects all downstream callers expecting a dict
test_config.py:
- test_empty_yaml_raises: replaces test_empty_yaml_returns_none_or_dict (was
accepting None which would crash any caller doing result['key'])
- test_malformed_yaml_raises: new test verifying yaml.YAMLError propagates
- test_default_config_weights_are_positive: replaces fragile sum-to-1.0 check
(ensemble scorer normalises by total weight so sum doesn't have to be 1.0)
- test_default_config_selection_present: add max_safety_risk assertion
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
tests/test_external_predict.pyfor the mandatory pre-synthesis external validation gate (write_pilot_fasta,write_external_predict_checklist,write_confident_panel)tests/test_config.pyforload_configincluding the real pipeline.yamlThese were the two CRITICAL zero-coverage gaps before synthesis spend.
What's tested
write_pilot_fasta— FASTA file format: one>id|rank=N|seed=Sheader per candidate, sequence on next line, file ends with newline, missing optional fields don't crash, empty panel produces empty-like file, parent directories createdwrite_external_predict_checklist— markdown output: all three tools (CAMPR4, AMPScanner v2, dbAMP 2.0) present, panel size in text, result table rows contain each candidate ID, ≥2/3 agreement rule stated, synthesis stop gate present, disclaimer text present,generated_atconditional inclusion, fasta path referencedwrite_confident_panel— filtering: keeps only specified IDs, re-ranks kept candidates starting at 1, emptykeep_idsreturns empty, unknown IDs silently ignored, writes.csvand.mdoutputsload_config— valid YAML, realconfigs/pipeline.yamlintegrity (filters, weights sum to 1.0, selection keys), string path accepted, missing file raises FileNotFoundError, empty YAML, list/numeric/bool values preservedTest plan