Skip to content

Add unit tests for CFM parsers and line_segment_strike - #164

Merged
lispandfound merged 1 commit into
mainfrom
ai/issue-149
Oct 22, 2026
Merged

lispandfound merged 1 commit into
mainfrom
ai/issue-149

Conversation

@claude

@claude claude Bot commented Oct 22, 2026

Copy link
Copy Markdown

Closes #149

What was missing

parse_timeframe_unit, fault_sense_parse and line_segment_strike in source_modelling/community_fault_model.py had 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") raise ValueError.
  • 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-empty sense. If the parser's case ever stopped matching the shapefile data, that fault would quietly become MovementSense(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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude claude Bot added the ai-generated Opened by the scheduled Claude jobs label Oct 22, 2026
@claude
claude Bot requested a review from lispandfound October 22, 2026 13:35
@lispandfound
lispandfound merged commit 0a7c700 into main Oct 22, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Opened by the scheduled Claude jobs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

community_fault_model.py: add unit tests for parse_timeframe_unit, fault_sense_parse and line_segment_strike

1 participant