Add tests for mhr.download_assets asset download and zip handling - #79
Draft
rootkiller6788 wants to merge 1 commit into
Draft
Add tests for mhr.download_assets asset download and zip handling#79rootkiller6788 wants to merge 1 commit into
rootkiller6788 wants to merge 1 commit into
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.
Summary
mhr/download_assets.py(themhr-download-assetsentry point) had no unit-test coverage. It implements the asset download pipeline, zip integrity validation, zip-slip path-traversal protection, and single-member extraction, so its behavior is worth pinning down.This PR adds
tests/test_download_assets.pywith 21 cases covering:_asset_url:latestvs. pinned release URL construction_positive_int: positive parsing and rejection of zero/negative/non-integer retry values_validate_zip: accepts valid archives, rejects non-zip and CRC-corrupted archives_safe_members: accepts normal members, rejects../parent-path traversal_extract: full-archive extraction, single-member extraction (flattened to--destand to an explicit--output), missing-member error, and traversal rejection_download: content write, retry-then-succeed on a transientURLError,RuntimeErrorafter retries are exhausted (with the temp file cleaned up), and rejection of empty responsesThe tests are dependency-light (stdlib only) and run without
pymomentum,torch, orsmplx.Test plan
pytest tests/test_download_assets.py -v # 21 passed