feat: Add test suite, unit tests on PR, and weekly live-service tests - #52
Merged
Conversation
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.
This pull request adds a test suite and continuous-integration coverage to pytRIBS. Until now the GitHub Actions workflow only installed the package and imported it. Multiple failure modes are now covered by tests, in two tiers: fast unit tests that run on every pull request, and scheduled live-service tests that run weekly against the real external APIs.
Unit tests (run on every PR)
test_rosetta_soil_params.py: direct regression guard. Feeds four textbook textures (sand, loam, clay, silt loam) through_rosetta_to_tribs_paramsand asserts (1) literature-informed plausibility windows on Ks per texture, physical bounds on theta_r/theta_s/psib/m, and correct texture ordering and (2) "golden values" frozen fromrosetta-soil0.3.x at a loose ±25% tolerance to flag subtler prediction drift. Also verifies the ROSETTA model-code selection.test_soil_map.py: USDA texture classification throughcreate_soil_map, covering both the ISRIC (g/kg) and SOLUS (% mass) input conventions and the sequential class renumbering.test_ks_decay.py: generates synthetic Ks-with-depth grids from a known decay parameter and assertscompute_ks_decayrecovers it, floors uniform profiles atmin_f, and propagates nodata.test_met_conversions.py: hand-checked "golden values" for the NLDAS unit conversions (Pa to hPa, K to degC, specific humidity to RH, 10 m to 2 m wind log-profile scaling), the GMT timestamp shift,.mdf/.sdfround trips, and the observation-station validation errors.test_soil_tables.py/test_ascii_io.py: round trips for the.sdtsoil table and the ESRI ASCII raster writer/reader, including NaN-to-nodata replacement and cell-size preservation.test_evaluate_metrics.py: known-answer checks for NSE, KGE, RMSE, and percent bias.test_classes.py: constructs every top-level class bare and from a written.infile, locking in the constructor fix and the input-file write/read round trip.Live-service canaries (automatic, weekly)
Small real requests with plausibility gates on the responses, so an upstream API change is flagged by a failed-workflow email instead of by a broken user run:
get_nldas_pointswallows per-variable fetch errors, a missing column is the failure signal.Continuous integration
install_and_test.yml: now installs.[test]and runspytest(network tests excluded by marker) after the import smoke test, on Python 3.11 and 3.13. Because dependencies are unpinned, every PR run also exercises the newest dependency releases.canary.yml(new): scheduled Mondays 12:00 UTC plus manual dispatch. Installs the latest release of every dependency and runs the full unit suite, so a breaking dependency release is caught within a week even with no pushes. The Giovanni test authenticates via theEARTHDATA_USERNAME/EARTHDATA_PASSWORDrepository secrets.Technical changes
tests/(new): nine test modules plus aconftest.pyfixture that writes small georeferenced ESRI ASCII grids for the raster-based tests.pytRIBS/classes.py: fixed the brokeninput_filepath in theSoil,Land,Met, andMeshconstructors described above; each now also carries a populatedoptionsdictionary, consistent withResults.pyproject.toml: added atestextra (pytest>=8.0) and pytest configuration..github/workflows/install_and_test.yml: unit test step added..github/workflows/canary.yml: new scheduled canary workflow.Running the tests