tests.test_binaries moduleΒΆ

Tests for the download, verification and cache of binary tools.

tests.test_binaries.test_download_and_verify_success(tmp_path)[source]ΒΆ

Successful download with matching checksum writes the file.

tests.test_binaries.test_download_and_verify_no_content_length(tmp_path)[source]ΒΆ

A response without Content-Length downloads via the indeterminate Spinner.

tests.test_binaries.test_download_and_verify_mismatch(tmp_path)[source]ΒΆ

A checksum mismatch raises its own error and removes the download.

tests.test_binaries.test_download_and_verify_retries_transient_failure(tmp_path)[source]ΒΆ

A transient network failure is retried and the next attempt succeeds.

tests.test_binaries.test_download_and_verify_gives_up_after_attempts(tmp_path)[source]ΒΆ

A persistent network failure surfaces after the last attempt.

tests.test_binaries.test_download_and_verify_does_not_retry_a_client_error(tmp_path, status)[source]ΒΆ

A client error gets the same answer every time, so it fails at once.

tests.test_binaries.test_download_and_verify_retries_a_server_error(tmp_path)[source]ΒΆ

A server error is transient, so the download is tried again.

tests.test_binaries.test_download_and_verify_truncated(tmp_path)[source]ΒΆ

A body shorter than Content-Length fails as truncated, not as a mismatch.

A truncated transfer (proxy hiccup, dropped connection) hashes to a wrong digest, which would read as a stale pin or a tampered artifact when the registry checksum is correct. Truncation is retried like any network failure, so the error only surfaces once every attempt came up short.

tests.test_binaries.test_extract_binary_raw(tmp_path)[source]ΒΆ

RAW format renames the archive to the executable name.

tests.test_binaries.test_extract_binary_tar(tmp_path, archive_format, mode)[source]ΒΆ

A tar archive yields the named executable, made executable.

tests.test_binaries.test_extract_binary_tar_with_strip_components(tmp_path)[source]ΒΆ

Leading path components are stripped before the executable is matched.

tests.test_binaries.test_extract_binary_zip(tmp_path)[source]ΒΆ

A ZIP archive yields the executable, .exe suffix included.

tests.test_binaries.test_extract_binary_zip_with_strip_components(tmp_path)[source]ΒΆ

Leading path components are stripped in a ZIP archive too.

tests.test_binaries.test_extract_binary_refuses_a_bad_archive(tmp_path, archive_format, member, message)[source]ΒΆ

A missing executable or a traversing path is an install failure.

tests.test_binaries.test_extract_binary_refuses_a_corrupt_archive(tmp_path)[source]ΒΆ

An archive that cannot be read is an install failure, not a traceback.

tests.test_binaries.TARBALL_URL = 'https://example.com/{version}/tool.tar.gz'ΒΆ

Download URL for the tests that go through the extract step.

tests.test_binaries.test_install_binary_missing_platform()[source]ΒΆ

A platform with no binary is an install failure of its own kind.

tests.test_binaries.test_install_binary_refuses_a_platform_with_no_checksum(cache_env)[source]ΒΆ

A URL with no recorded digest fails closed before any download.

tests.test_binaries.test_install_binary_cache_hit(cache_env)[source]ΒΆ

A cached binary whose sidecar matches is used as is.

tests.test_binaries.test_install_binary_cache_hit_on_a_nested_archive_executable(cache_env, cached_name)[source]ΒΆ

A cached entry is found whatever path the executable held in the archive.

archive_executable names a location inside the archive, while the cache keys an entry on the extracted file’s own name. Probing with the nested path matched nothing, so a tool declaring one re-downloaded on every call.

tests.test_binaries.test_install_binary_cache_miss_stores(tmp_path, cache_env)[source]ΒΆ

A download lands in the cache with its digest sidecar, staging removed.

tests.test_binaries.test_install_binary_no_cache_flag(tmp_path, cache_env)[source]ΒΆ

no_cache bypasses the cache and keeps the staging copy alive.

tests.test_binaries.test_install_binary_cache_integrity_failure(tmp_path, cache_env)[source]ΒΆ

A cached binary that fails its sidecar check is downloaded again.

tests.test_binaries.test_install_binary_cache_store_fallback(tmp_path, cache_env)[source]ΒΆ

An install the cache loses falls back to the staging copy.

tests.test_binaries.test_install_binary_cleans_staging_after_a_failed_download(tmp_path, cache_env)[source]ΒΆ

A failed download leaves no staging directory behind.

tests.test_binaries.test_ensure_binary_memoizes_per_tool(mock_install_binary, tmp_path)[source]ΒΆ

Repeated calls install once and return the same path.

Callers in a loop (format-images optimizing one PNG per call) must not pay the install-and-verify path once per file.

tests.test_binaries.test_ensure_binary_rejects_a_tool_without_binary(name, message)[source]ΒΆ

Only a registry binary has an executable to hand out.