Skip to content
Snippets Groups Projects
Commit aa13e8ee authored by Jithu Murugan's avatar Jithu Murugan
Browse files

- Corrected the failing unit tests and minor refactorings.

parent 5e4b78f9
No related branches found
No related tags found
1 merge request!4feat(spack_operation): implement setup_spack_env functionality
Pipeline #59543 canceled with stages
in 20 minutes and 29 seconds
...@@ -60,12 +60,16 @@ class TestBuildCacheManager: ...@@ -60,12 +60,16 @@ class TestBuildCacheManager:
result = mock_build_cache_manager.get_public_key_from_cache(str(build_cache_dir)) result = mock_build_cache_manager.get_public_key_from_cache(str(build_cache_dir))
# Assert # Assert
# Cannot assure the order in which the OS returns the files,
# hence check if the result is in the expected list
assert result in [str(build_cache_dir / "project0" / "_pgp" / "key0.pub"), assert result in [str(build_cache_dir / "project0" / "_pgp" / "key0.pub"),
str(build_cache_dir / "project0" / "_pgp" / "key1.pub"), str(build_cache_dir / "project0" / "_pgp" / "key1.pub"),
str(build_cache_dir / "project1" / "_pgp" / "key0.pub")] str(build_cache_dir / "project1" / "_pgp" / "key0.pub")]
log = (expected_log_message, pgp_folders, pgp_folders[0]) if test_id == "more_than_one_gpg_folder" else ( assert mock_build_cache_manager._logger.warning.call_args[0][0] == expected_log_message
expected_log_message, key_files, key_files[0]) assert set(mock_build_cache_manager._logger.warning.call_args[0][1]) == set(
mock_build_cache_manager._logger.warning.assert_called_once_with(*log) pgp_folders) if test_id == "more_than_one_gpg_folder" else set(key_files)
assert mock_build_cache_manager._logger.warning.call_args[0][
2] in pgp_folders if test_id == "more_than_one_gpg_folder" else key_files
@pytest.mark.parametrize("build_cache_dir, expected_log_message", [ @pytest.mark.parametrize("build_cache_dir, expected_log_message", [
(None, 'Build cache directory does not exist!'), (None, 'Build cache directory does not exist!'),
......
...@@ -5,12 +5,10 @@ ...@@ -5,12 +5,10 @@
# Description: Brief description of the file. # Description: Brief description of the file.
# Created by: Murugan, Jithu <j.murugan@fz-juelich.de> # Created by: Murugan, Jithu <j.murugan@fz-juelich.de>
# Created on: 2025-02-20 # Created on: 2025-02-20
import logging
from pathlib import Path from pathlib import Path
import pytest import pytest
from dedal.commands.command_runner import CommandRunner
from dedal.error_handling.exceptions import NoSpackEnvironmentException from dedal.error_handling.exceptions import NoSpackEnvironmentException
from dedal.spack_factory.SpackOperationUseCache import SpackOperationUseCache from dedal.spack_factory.SpackOperationUseCache import SpackOperationUseCache
...@@ -51,7 +49,7 @@ class TestSpackOperationUseCache: ...@@ -51,7 +49,7 @@ class TestSpackOperationUseCache:
spack_operation_use_cache_mock.build_cache.download.assert_called_once_with( spack_operation_use_cache_mock.build_cache.download.assert_called_once_with(
spack_operation_use_cache_mock.spack_config.buildcache_dir) spack_operation_use_cache_mock.spack_config.buildcache_dir)
spack_operation_use_cache_mock.build_cache.get_public_key_from_cache.assert_called_once_with( spack_operation_use_cache_mock.build_cache.get_public_key_from_cache.assert_called_once_with(
spack_operation_use_cache_mock.spack_config.buildcache_dir) str(spack_operation_use_cache_mock.spack_config.buildcache_dir))
if key_path: if key_path:
spack_operation_use_cache_mock.trust_gpg_key.assert_called_once_with(key_path) spack_operation_use_cache_mock.trust_gpg_key.assert_called_once_with(key_path)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment