Repository navigation
Add unit tests for CFM parsers and line_segment_strike - #164
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <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.
Closes #149
What was missing
parse_timeframe_unit,fault_sense_parseandline_segment_strikeinsource_modelling/community_fault_model.pyhad no direct unit tests. The CFM loading test used them, but never checked them against known values.What changed
This PR only adds tests, in
tests/test_community_fault_model.py. No library code changed.test_parse_timeframe_unit:""->None,"yrs"-> 1,"100 yrs"-> 100,"1,000s yrs"-> 1000,"Ma"-> 1,000,000.test_parse_timeframe_unit_unknown: strings that don't match ("days","kyr","1000") raiseValueError.test_fault_sense_parse: each single sense, the combinations"reverse dextral"and"normal sinistral", and""->MovementSense(0).test_loaded_faults_have_sense: every fault in the loaded CFM has a non-emptysense. If the parser's case ever stopped matching the shapefile data, that fault would quietly becomeMovementSense(0); this test catches it.test_line_segment_strike: segments due north, east, south and west from an NZTM point (northing, easting) give strikes of about 0/90/180/270°. The tolerance is 3° to allow for NZTM grid convergence.Notes for reviewers
The current code is correct, so these tests pass before and after this PR. They are there to pin the current behaviour, not to show a bug. The full suite passes (
860 passed), and ruff check and ruff format are clean.🤖 Generated with Claude Code