pelicun.tests.basic.test_dlml
These are unit tests on the dlml module of pelicun.
Functions
Mocks the common environment for a data download test. |
|
Test check_dlml_data returns immediately when invoked via CLI for dlml update. |
|
Test check_dlml_data handles download failures appropriately. |
|
Test check_dlml_data handles permission errors appropriately. |
|
Test check_dlml_data handles version check failures gracefully. |
|
Test check_dlml_data with an empty temporary directory. |
|
Test check_dlml_data with existing data and no update available. |
|
Test check_dlml_data with existing data and update available. |
|
Test check_dlml_version handles corrupted timestamp in cache. |
|
Test check_dlml_version handles invalid version format in API response. |
|
Test check_dlml_version correctly compares semantic versions. |
|
Test check_dlml_version returns cached result when within 24 hours. |
|
Test check_dlml_version handles commit-based versions. |
|
Test check_dlml_version performs new check when cache is expired. |
|
Test check_dlml_version handles network errors gracefully. |
|
|
Test download_data_files re-downloads corrupted local file during smart update. |
Test download_data_files handles empty model_files.txt gracefully. |
|
Test handling when model_files.txt doesn't exist after download. |
|
Test handling of general file reading exceptions. |
|
Test downloading with caching enabled. |
|
Test downloading with a specific commit. |
|
Test downloading with the 'latest' commit. |
|
Test downloading with a specific version. |
|
Test handling of download failures. |
|
Test downloading a file from a valid URL. |
|
Test _format_initial_download_error with various exception types. |
|
Test hash calculation for files with different content. |
|
Test hash calculation for empty files. |
|
Test hash calculation for existing files. |
|
Test hash calculation for non-existent files. |
|
Test loading from a corrupted cache file. |
|
Test loading from a non-existent cache file. |
|
Test loading from a valid cache file. |
|
Test successful commit-based download via dlml_update() function. |
|
Test dlml_update() function with commit and no cache. |
|
Test dlml_update() function with default 'latest' version when no version specified. |
|
Test error handling when download_data_files raises exceptions via dlml_update() function. |
|
Test no-cache functionality via dlml_update() function. |
|
Test successful version-based download via dlml_update() function. |
|
Test progress bar initialization with different file counts. |
|
|
Test progress bar updates during downloads. |
Test progress reporting for skipped files. |
|
Test saving cache data to a file. |
|
|
Test validation of commit SHA with various inputs. |
Classes
A dedicated test class for the _get_changed_files function. |
|
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.
- 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.
- 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.