pelicun.tests.basic.test_dlml

These are unit tests on the dlml module of pelicun.

Functions

mock_download_env()

Mocks the common environment for a data download test.

test_check_dlml_data_cli_invocation_bypass()

Test check_dlml_data returns immediately when invoked via CLI for dlml update.

test_check_dlml_data_download_failure()

Test check_dlml_data handles download failures appropriately.

test_check_dlml_data_permission_error()

Test check_dlml_data handles permission errors appropriately.

test_check_dlml_data_version_check_failure()

Test check_dlml_data handles version check failures gracefully.

test_check_dlml_data_with_empty_directory()

Test check_dlml_data with an empty temporary directory.

test_check_dlml_data_with_existing_data_no_update()

Test check_dlml_data with existing data and no update available.

test_check_dlml_data_with_existing_data_update_available()

Test check_dlml_data with existing data and update available.

test_check_dlml_version_corrupted_timestamp()

Test check_dlml_version handles corrupted timestamp in cache.

test_check_dlml_version_invalid_version_format()

Test check_dlml_version handles invalid version format in API response.

test_check_dlml_version_semantic_version_comparison()

Test check_dlml_version correctly compares semantic versions.

test_check_dlml_version_with_cached_result()

Test check_dlml_version returns cached result when within 24 hours.

test_check_dlml_version_with_commit_based_version()

Test check_dlml_version handles commit-based versions.

test_check_dlml_version_with_expired_cache()

Test check_dlml_version performs new check when cache is expired.

test_check_dlml_version_with_network_error()

Test check_dlml_version handles network errors gracefully.

test_download_data_files_corrupted_local_file_smart_update()

Test download_data_files re-downloads corrupted local file during smart update.

test_download_data_files_empty_model_files()

Test download_data_files handles empty model_files.txt gracefully.

test_download_data_files_model_file_not_found()

Test handling when model_files.txt doesn't exist after download.

test_download_data_files_model_file_read_error()

Test handling of general file reading exceptions.

test_download_data_files_with_cache(...)

Test downloading with caching enabled.

test_download_data_files_with_commit(...)

Test downloading with a specific commit.

test_download_data_files_with_latest_commit(...)

Test downloading with the 'latest' commit.

test_download_data_files_with_version(...)

Test downloading with a specific version.

test_download_file_request_exception()

Test handling of download failures.

test_download_file_success()

Test downloading a file from a valid URL.

test_format_initial_download_error(...)

Test _format_initial_download_error with various exception types.

test_get_file_hash_different_content()

Test hash calculation for files with different content.

test_get_file_hash_empty_file()

Test hash calculation for empty files.

test_get_file_hash_existing_file()

Test hash calculation for existing files.

test_get_file_hash_nonexistent_file()

Test hash calculation for non-existent files.

test_load_cache_corrupted_file()

Test loading from a corrupted cache file.

test_load_cache_nonexistent_file()

Test loading from a non-existent cache file.

test_load_cache_valid_file()

Test loading from a valid cache file.

test_main_commit_download()

Test successful commit-based download via dlml_update() function.

test_main_commit_with_no_cache()

Test dlml_update() function with commit and no cache.

test_main_default_latest_version()

Test dlml_update() function with default 'latest' version when no version specified.

test_main_download_error_handling()

Test error handling when download_data_files raises exceptions via dlml_update() function.

test_main_no_cache_flag()

Test no-cache functionality via dlml_update() function.

test_main_version_download()

Test successful version-based download via dlml_update() function.

test_progress_bar_initialization(...)

Test progress bar initialization with different file counts.

test_progress_bar_updates(mock_download_env)

Test progress bar updates during downloads.

test_progress_reporting_for_skipped_files(...)

Test progress reporting for skipped files.

test_save_cache()

Test saving cache data to a file.

test_validate_commit_sha(commit_sha, expected)

Test validation of commit SHA with various inputs.

Classes

TestGetChangedFiles()

A dedicated test class for the _get_changed_files function.

TestResolveVersionToCommitSHA()

Test class for the _resolve_version_to_commit_sha helper function.

class pelicun.tests.basic.test_dlml.TestGetChangedFiles[source]

A dedicated test class for the _get_changed_files function.

test_get_changed_files_api_failure() None[source]

Test the function’s behavior when the GitHub API call fails.

test_get_changed_files_downgrade() None[source]

Test the downgrade path where commits are behind, triggering a second API call.

test_get_changed_files_upgrade() None[source]

Test the standard upgrade path where commits are ahead.

class pelicun.tests.basic.test_dlml.TestResolveVersionToCommitSHA[source]

Test class for the _resolve_version_to_commit_sha helper function.

test_api_call_failure_raises_runtime_error() None[source]

Test gracefully handling RuntimeError when API calls fail.

test_empty_commits_list_raises_runtime_error() None[source]

Test handling empty commits list when fetching latest commit.

test_fallback_to_target_commitish_on_tag_api_failure() None[source]

Test fallback to target_commitish when tag API fails.

test_invalid_commit_sha_format_raises_value_error() None[source]

Test gracefully handling ValueError for invalid commit SHA formats.

test_missing_commit_sha_in_release_raises_runtime_error() None[source]

Test handling missing commit SHA in release data.

test_resolve_annotated_tag() None[source]

Test handling annotated tags (key new test).

test_resolve_latest_commit() None[source]

Test resolving the ‘latest’ commit.

test_resolve_latest_version_tag() None[source]

Test resolving the ‘latest’ version tag.

test_resolve_specific_commit_sha() None[source]

Test resolving a specific commit SHA.

test_resolve_specific_version_tag() None[source]

Test resolving a specific version tag (e.g., ‘v1.2.0’).

pelicun.tests.basic.test_dlml.mock_download_env() Generator[dict[str, Any], None, None][source]

Mocks the common environment for a data download test.

pelicun.tests.basic.test_dlml.test_check_dlml_data_cli_invocation_bypass() None[source]

Test check_dlml_data returns immediately when invoked via CLI for dlml update.

pelicun.tests.basic.test_dlml.test_check_dlml_data_download_failure() None[source]

Test check_dlml_data handles download failures appropriately.

pelicun.tests.basic.test_dlml.test_check_dlml_data_permission_error() None[source]

Test check_dlml_data handles permission errors appropriately.

pelicun.tests.basic.test_dlml.test_check_dlml_data_version_check_failure() None[source]

Test check_dlml_data handles version check failures gracefully.

pelicun.tests.basic.test_dlml.test_check_dlml_data_with_empty_directory() None[source]

Test check_dlml_data with an empty temporary directory.

This mocks DLML_DATA_DIR to use a temporary directory, ensuring the function triggers a download when data is missing. It also reloads the module to ensure the original, un-mocked function is tested.

pelicun.tests.basic.test_dlml.test_check_dlml_data_with_existing_data_no_update() None[source]

Test check_dlml_data with existing data and no update available.

pelicun.tests.basic.test_dlml.test_check_dlml_data_with_existing_data_update_available() None[source]

Test check_dlml_data with existing data and update available.

pelicun.tests.basic.test_dlml.test_check_dlml_version_corrupted_timestamp() None[source]

Test check_dlml_version handles corrupted timestamp in cache.

pelicun.tests.basic.test_dlml.test_check_dlml_version_invalid_version_format() None[source]

Test check_dlml_version handles invalid version format in API response.

pelicun.tests.basic.test_dlml.test_check_dlml_version_semantic_version_comparison() None[source]

Test check_dlml_version correctly compares semantic versions.

pelicun.tests.basic.test_dlml.test_check_dlml_version_with_cached_result() None[source]

Test check_dlml_version returns cached result when within 24 hours.

pelicun.tests.basic.test_dlml.test_check_dlml_version_with_commit_based_version() None[source]

Test check_dlml_version handles commit-based versions.

pelicun.tests.basic.test_dlml.test_check_dlml_version_with_expired_cache() None[source]

Test check_dlml_version performs new check when cache is expired.

pelicun.tests.basic.test_dlml.test_check_dlml_version_with_network_error() None[source]

Test check_dlml_version handles network errors gracefully.

pelicun.tests.basic.test_dlml.test_download_data_files_corrupted_local_file_smart_update() None[source]

Test download_data_files re-downloads corrupted local file during smart update.

pelicun.tests.basic.test_dlml.test_download_data_files_empty_model_files() None[source]

Test download_data_files handles empty model_files.txt gracefully.

pelicun.tests.basic.test_dlml.test_download_data_files_model_file_not_found() None[source]

Test handling when model_files.txt doesn’t exist after download.

pelicun.tests.basic.test_dlml.test_download_data_files_model_file_read_error() None[source]

Test handling of general file reading exceptions.

pelicun.tests.basic.test_dlml.test_download_data_files_with_cache(mock_download_env: dict[str, Any]) None[source]

Test downloading with caching enabled.

pelicun.tests.basic.test_dlml.test_download_data_files_with_commit(mock_download_env: dict[str, Any]) None[source]

Test downloading with a specific commit.

pelicun.tests.basic.test_dlml.test_download_data_files_with_latest_commit(mock_download_env: dict[str, Any]) None[source]

Test downloading with the ‘latest’ commit.

pelicun.tests.basic.test_dlml.test_download_data_files_with_version(mock_download_env: dict[str, Any]) None[source]

Test downloading with a specific version.

pelicun.tests.basic.test_dlml.test_download_file_request_exception() None[source]

Test handling of download failures.

pelicun.tests.basic.test_dlml.test_download_file_success() None[source]

Test downloading a file from a valid URL.

pelicun.tests.basic.test_dlml.test_format_initial_download_error(exception: Exception, expected_messages: list[str]) None[source]

Test _format_initial_download_error with various exception types.

pelicun.tests.basic.test_dlml.test_get_file_hash_different_content() None[source]

Test hash calculation for files with different content.

pelicun.tests.basic.test_dlml.test_get_file_hash_empty_file() None[source]

Test hash calculation for empty files.

pelicun.tests.basic.test_dlml.test_get_file_hash_existing_file() None[source]

Test hash calculation for existing files.

pelicun.tests.basic.test_dlml.test_get_file_hash_nonexistent_file() None[source]

Test hash calculation for non-existent files.

pelicun.tests.basic.test_dlml.test_load_cache_corrupted_file() None[source]

Test loading from a corrupted cache file.

pelicun.tests.basic.test_dlml.test_load_cache_nonexistent_file() None[source]

Test loading from a non-existent cache file.

pelicun.tests.basic.test_dlml.test_load_cache_valid_file() None[source]

Test loading from a valid cache file.

pelicun.tests.basic.test_dlml.test_main_commit_download() None[source]

Test successful commit-based download via dlml_update() function.

pelicun.tests.basic.test_dlml.test_main_commit_with_no_cache() None[source]

Test dlml_update() function with commit and no cache.

pelicun.tests.basic.test_dlml.test_main_default_latest_version() None[source]

Test dlml_update() function with default ‘latest’ version when no version specified.

pelicun.tests.basic.test_dlml.test_main_download_error_handling() None[source]

Test error handling when download_data_files raises exceptions via dlml_update() function.

pelicun.tests.basic.test_dlml.test_main_no_cache_flag() None[source]

Test no-cache functionality via dlml_update() function.

pelicun.tests.basic.test_dlml.test_main_version_download() None[source]

Test successful version-based download via dlml_update() function.

pelicun.tests.basic.test_dlml.test_progress_bar_initialization(mock_download_env: dict[str, Any]) None[source]

Test progress bar initialization with different file counts.

pelicun.tests.basic.test_dlml.test_progress_bar_updates(mock_download_env: dict[str, Any]) None[source]

Test progress bar updates during downloads.

pelicun.tests.basic.test_dlml.test_progress_reporting_for_skipped_files(mock_download_env: dict[str, Any]) None[source]

Test progress reporting for skipped files.

pelicun.tests.basic.test_dlml.test_save_cache() None[source]

Test saving cache data to a file.

pelicun.tests.basic.test_dlml.test_validate_commit_sha(commit_sha: str, expected: bool) None[source]

Test validation of commit SHA with various inputs.