pelicun.tests.tools.test_dlml_integration
Integration tests for the pelicun DLML (Damage and Loss Model Library) module.
Functions
Verify that cache version tracking and updating work correctly. |
|
Verify CLI correctly handles invalid actions. |
|
Verify CLI correctly handles missing required arguments. |
|
Verify all download modes (version, commit, latest) function correctly. |
|
Verify that the _download_file function properly creates files on disk. |
|
|
Verify the entire DLML download process using a local HTTP server. |
Verify that import failures are properly handled. |
|
|
Verify successful import integration with check_dlml_data. |
|
Verify that the module-level logger is configured and used correctly. |
Verify integration with pelicun's warning system. |
|
Verify that commented lines in model_files.txt are properly ignored. |
|
|
Verify the download process handles empty model_files.txt gracefully. |
|
Verify the download process works with a large number of files. |
Verify the download process handles paths with special characters. |
|
|
Verify the complete download workflow using real filesystem operations. |
- pelicun.tests.tools.test_dlml_integration.test_cache_version_tracking_integration(mock_load_cache: MagicMock, mock_save_cache: MagicMock, mock_get: MagicMock, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) None [source]
Verify that cache version tracking and updating work correctly.
Tests the interaction between the cache system and version checking, ensuring version comparisons are correct and cache gets updated.
- pelicun.tests.tools.test_dlml_integration.test_cli_integration_invalid_action() None [source]
Verify CLI correctly handles invalid actions.
Tests that the CLI returns the expected error code and message when an invalid action is provided.
- pelicun.tests.tools.test_dlml_integration.test_cli_integration_missing_arguments() None [source]
Verify CLI correctly handles missing required arguments.
Tests that the CLI returns the expected error code and message when required arguments are missing.
- pelicun.tests.tools.test_dlml_integration.test_different_download_modes_integration(mock_get: MagicMock, mock_tqdm: MagicMock, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) None [source]
Verify all download modes (version, commit, latest) function correctly.
Tests that the different ways to specify what version to download (via version string, commit SHA, or ‘latest’) all work properly.
- pelicun.tests.tools.test_dlml_integration.test_download_file_creates_real_file_in_cache(mock_get: MagicMock, tmp_path: Path) None [source]
Verify that the _download_file function properly creates files on disk.
This test checks that actual filesystem operations work correctly with only the network request being mocked.
- pelicun.tests.tools.test_dlml_integration.test_full_download_flow_e2e(httpserver: HTTPServer, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) None [source]
Verify the entire DLML download process using a local HTTP server.
This test simulates the complete download workflow against a controlled local HTTP server that mimics GitHub’s API responses and file content delivery.
- pelicun.tests.tools.test_dlml_integration.test_import_integration_failure(mock_check_dlml_data: MagicMock) None [source]
Verify that import failures are properly handled.
Tests that errors during the import process are correctly raised.
- pelicun.tests.tools.test_dlml_integration.test_import_integration_success(mock_check: MagicMock) None [source]
Verify successful import integration with check_dlml_data.
Tests that the import process works correctly when check_dlml_data succeeds.
- pelicun.tests.tools.test_dlml_integration.test_logging_configuration(mock_get: MagicMock, mock_warning: MagicMock) None [source]
Verify that the module-level logger is configured and used correctly.
Tests that the dlml module’s logger is properly configured and that logging calls are made at the appropriate points.
- pelicun.tests.tools.test_dlml_integration.test_warning_system_integration(mock_check_version: MagicMock, mock_warn: MagicMock, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) None [source]
Verify integration with pelicun’s warning system.
Tests that warnings about available updates are correctly issued through the pelicun warning system with the proper warning class.
- pelicun.tests.tools.test_dlml_integration.test_with_commented_lines_in_model_files(mock_get: MagicMock, mock_tqdm: MagicMock, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) None [source]
Verify that commented lines in model_files.txt are properly ignored.
Tests that lines starting with # in model_files.txt are skipped during download, ensuring only actual file entries are processed.
- pelicun.tests.tools.test_dlml_integration.test_with_empty_model_files(mock_get: MagicMock, mock_tqdm: MagicMock, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) None [source]
Verify the download process handles empty model_files.txt gracefully.
Tests that when model_files.txt is empty, the download process completes without error and doesn’t attempt to download any additional files.
- pelicun.tests.tools.test_dlml_integration.test_with_large_number_of_files(mock_get: MagicMock, mock_tqdm: MagicMock, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) None [source]
Verify the download process works with a large number of files.
Tests the system’s ability to handle downloading many files at once by simulating 50 files in the model_files.txt listing.
- pelicun.tests.tools.test_dlml_integration.test_with_special_characters_in_paths(mock_get: MagicMock, mock_tqdm: MagicMock, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) None [source]
Verify the download process handles paths with special characters.
Tests that file paths containing spaces, hash symbols, and question marks are correctly processed and the files are created in the expected locations.
- pelicun.tests.tools.test_dlml_integration.test_workflow_with_real_downloads(mock_get: MagicMock, mock_tqdm: MagicMock, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) None [source]
Verify the complete download workflow using real filesystem operations.
Tests the end-to-end download process with URL-specific mock responses to simulate different API responses and file contents.