Skip to content

Add regression tests for the bug classes that escaped 0.4.x CI#87

Merged
ZachHoppinen merged 1 commit into
mainfrom
add-regression-tests
May 11, 2026
Merged

Add regression tests for the bug classes that escaped 0.4.x CI#87
ZachHoppinen merged 1 commit into
mainfrom
add-regression-tests

Conversation

@ZachHoppinen

Copy link
Copy Markdown
Contributor

Adds four targeted tests for the bug classes that leaked through to released versions during the 0.4.0-0.4.4 cycle. All run as pure unit tests — no network, no Earthdata creds — and would have flagged the regressions on PR rather than in user-facing crashes.

What's covered

Test Bug class Closes the gap from
`test_snow_index.py::test_calc_delta_cross_ratio_disjoint_orbits_with_singleton` Multi-orbit + disjoint times + single-acquisition orbit. In-place `.loc[time=...]` write into broadcast-backed read-only buffer under numpy 2.x. PR #85
`test_wetsnow.py::test_flag_wet_snow_snowcover_mask_applied_to_all_timesteps` Stale-`ts` loop variable used outside its loop scope; snowcover mask applied only to the last timestep. PR #79 piggyback fix
`test_generating_dataarrays.py::test_generate_forest_fraction_dataarray_outside_conus` Non-CONUS FCF code path never exercised by existing test AOI. Mocks `download_proba_v` to a synthetic tif and runs both the no-ref and with-ref branches end-to-end. PRs #79 (TypeError), #80 (eager-load OOM), #85 (clip_box WindowError)
`test_pipeline_synthetic.py::test_post_download_pipeline_runs_end_to_end` (new file) Whole post-download pipeline (preprocessing → snow-index → wet-snow) against a multi-orbit + single-acquisition synthetic dataset. Offline counterpart to the integration test. All snow-index / wet-snow regressions

What's still NOT covered

  • Real download paths (asf_search, earthaccess) — unit tests still mock these. A bug in URL construction that only manifests against the real APIs would still escape.
  • Numerical correctness — the synthetic pipeline test asserts the pipeline runs and outputs are in plausible ranges (non-negative snow_depth, binary wet_snow), not that the numbers are right. A snapshot fixture from a real run could harden this.
  • `generate_reference_grid` y-orientation flip (Fix non-CONUS snow-depth pipeline (FCF + snow_index + VIIRS tile filter) #85) — defensive code that fires only on the degenerate single-acquisition track case. Hard to exercise without real S1 burst data; left as a known gap.

Future work for higher confidence: either run `RUN_INTEGRATION=1` in CI (needs Earthdata creds), or record a tiny real-data fixture for the post-download pipeline test.

Test plan

  • `pytest tests/` — 77/77 pass (was 73; +4 new).
  • Verified test_calc_delta_cross_ratio_disjoint_orbits_with_singleton fixture has exactly the shape that triggered the read-only error (3 orbits with disjoint times + a single-acquisition orbit).

🤖 Generated with Claude Code

Adds four targeted tests for bug classes that escaped CI during the
0.4.0-0.4.4 release cycle:

1. tests/test_snow_index.py: multi-orbit calc_delta_cross_ratio with
   disjoint time sets and a single-acquisition orbit (T021-shape).
   Would have caught the read-only-buffer regression under numpy 2.x
   + newer xarray (fixed in #85).

2. tests/test_wetsnow.py: multi-timestep flag_wet_snow snowcover-mask
   coverage. Asserts wet_snow is 0/NaN wherever snowcover is False
   across ALL timesteps, not just the last. Would have caught the
   stale-`ts` bug (#79).

3. tests/test_generating_dataarrays.py: non-CONUS smoke test for
   generate_forest_fraction_dataarray. Mocks download_proba_v to a
   small synthetic tif and runs both the no-ref and with-ref branches.
   Would have caught the missing-arg/OOM/clip_box class (#79, #80, #85).

4. tests/test_pipeline_synthetic.py (new file): runs the entire
   post-download pipeline (preprocessing -> snow-index -> wet-snow)
   against a synthetic multi-orbit + single-acquisition dataset. Offline
   counterpart to the integration test we still don't run in CI;
   catches regressions in the s1 preprocessing -> snow-index -> wet
   snow chain without network or Earthdata creds.

All 77 unit tests pass (was 73 before these additions).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ZachHoppinen ZachHoppinen merged commit 22ae28b into main May 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant