10
10
# limitations under the License.
11
11
12
12
import pytest
13
- import yaml
14
13
import os
15
14
from assertpy import assert_that
16
- from config_utils import get_template_folder
17
- from unittest .mock import mock_open , patch
18
15
from pcluster_topology_generator import (
16
+ cleanup_topology_config_file ,
19
17
generate_topology_config_file ,
20
- CriticalError ,
21
- _load_cluster_config ,
22
18
)
23
19
24
20
@@ -41,21 +37,17 @@ def test_generate_topology_config(test_datadir, tmpdir, file_name_suffix):
41
37
_assert_files_are_equal (output_file_path , test_datadir / "expected_outputs" / output_file_name )
42
38
43
39
44
-
45
- def test_load_cluster_config_file_not_found ():
46
- """Test loading a non-existent configuration file."""
47
- with pytest .raises (FileNotFoundError ):
48
- _load_cluster_config ("nonexistent_file.yaml" )
49
-
50
-
51
- def test_generate_topology_config_missing_key (tmp_path ):
52
- """Test generating topology config with missing required key."""
53
- invalid_config = {"Scheduling" : {}} # Missing SlurmQueues
54
- config_path = tmp_path / "invalid_config.yaml"
55
- with open (config_path , 'w' ) as f :
56
- yaml .dump (invalid_config , f )
57
-
58
- output_file = str (tmp_path / "topology.conf" )
59
- with pytest .raises (CriticalError ):
60
- generate_topology_config_file (output_file , str (config_path ), "9,18" )
40
+ @pytest .mark .parametrize ("file_exists" , [
41
+ True ,
42
+ False
43
+ ])
44
+ def test_cleanup_topology_config_file (mocker , tmpdir , file_exists ):
45
+ topology_file_path = tmpdir / "topology.conf"
46
+ mocker .patch ("os.path.exists" , return_value = file_exists )
47
+ mock_remove = mocker .patch ("os.remove" )
48
+ cleanup_topology_config_file (str (topology_file_path ))
49
+ if file_exists :
50
+ mock_remove .assert_called_once_with (str (topology_file_path ))
51
+ else :
52
+ mock_remove .assert_not_called ()
61
53
0 commit comments