Add pytest markers to separate fast tests from network/credential test - #118
Add pytest markers to separate fast tests from network/credential test#118toakinrele wants to merge 4 commits into
Conversation
quinnylee
left a comment
There was a problem hiding this comment.
This is cool. I wonder if it would be possible to tease out some unit tests from all the integration tests that we have skipped? The fast test suite doesn't run anything from test_channelrouting.py, test_forcingprocessor.py, test_hf2ds.py, test_nrds_fp.py, or test_plotter.py
| return bool(os.environ.get("AWS_PROFILE") or os.environ.get("AWS_SESSION_TOKEN")) | ||
|
|
||
|
|
||
| def pytest_collection_modifyitems(config, items): |
There was a problem hiding this comment.
For the five files you named, the tests are mostly thin wrappers (call hf2ds()/prep_ngen_data() with a real source, assert a file landed). The network call and the computation are fused inside those functions, so there's no clean pure logic to pull out without refactoring the source itself.
I did find three pure functions already sitting in processor.py (distribute_work, load_balance, calculate_vpu_precip_stats) that were only ever tested indirectly. Added direct unit tests for them, fast suite is now 18 tests, still ~3s. I also found a real bug in load_balance (it mishandles the all-zero-work case), so I marked it xfail with an explanation rather than fixing it here. (c6305c3)
There was a problem hiding this comment.
Maybe this is something we can delay until we merge the refactor branch?
quinnylee
left a comment
There was a problem hiding this comment.
Thanks for the work! This topic (unit tests) will need to get revisited once we figure out what to do with the refactoring branch.
Closes #115
Adds
networkandaws_credspytest markers so the fast unit tests can be run separately from tests that need network access or AWS/GCS credentials.pyproject.tomlconftest.pyauto-tags tests based on which fixtures they use (download_gpkg,clean_s3_test, etc.), and auto-skipsaws_credstests when no AWS credentials are detected
test_hf2ds.py, some oftest_trouterestarts.py)Makefilewithtest-fast/test-network/test-alltargetsLocal fast loop:
make test-fast- 7 tests in ~3s instead of the full ~30 min suite, no credentials required.