Improve testability of pdb_deposition.py - #84
Merged
Conversation
Refactoring: - substitute_tokens(): pure function for all $Token replacement, pulled out of the inline block in process_input() - merge_mmcifgen_into_structure(): extracts the for-item loop that applied the mmcif-gen template block onto a per-crystal CIF block - run() gains mmcifgen_runner= parameter (default run_mmcifgen) so tests can substitute a stub without running the full external tool Tests (31 total, all passing): - tests/test_pdb_deposition.py: unit tests for substitute_tokens, read_fragalysis_csv, read_cmpd_codes; CIF-level tests for merge_mmcifgen_into_structure using in-memory gemmi objects - tests/test_validate_structure_cif_doc.py: extended with in-memory CIF fixtures covering missing categories, R-factor range checks, unsubstituted placeholders, and software ordinal validation Closes #83 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
Summary
substitute_tokens()— a pure function handling all$CompoundCode,$CrystalName,$PoseID, and$ExternalCodeNreplacement, replacing the inline block previously buried insideprocess_input()merge_mmcifgen_into_structure()— pulls the loop that applied the mmcif-gen template block onto a per-crystal CIF block into its own testable functionmmcifgen_runner=run_mmcifgenparameter torun()so tests can inject a stub without invoking the real external toolCloses #83
Test plan
pytest tests/test_pdb_deposition.py -v— 20 new tests (unit + CIF-level)pytest tests/test_validate_structure_cif_doc.py -v— 11 tests (3 existing + 8 new)pytest— full suite stays green🤖 Generated with Claude Code