Skip to content

Add tests for mhr.download_assets asset download and zip handling - #79

Draft
rootkiller6788 wants to merge 1 commit into
facebookresearch:mainfrom
rootkiller6788:add-download-assets-tests
Draft

Add tests for mhr.download_assets asset download and zip handling#79
rootkiller6788 wants to merge 1 commit into
facebookresearch:mainfrom
rootkiller6788:add-download-assets-tests

Conversation

@rootkiller6788

Copy link
Copy Markdown

Summary

mhr/download_assets.py (the mhr-download-assets entry 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.py with 21 cases covering:

  • _asset_url: latest vs. 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 --dest and to an explicit --output), missing-member error, and traversal rejection
  • _download: content write, retry-then-succeed on a transient URLError, RuntimeError after retries are exhausted (with the temp file cleaned up), and rejection of empty responses

The tests are dependency-light (stdlib only) and run without pymomentum, torch, or smplx.

Test plan

pytest tests/test_download_assets.py -v
# 21 passed

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant