Skip to content

Commit 7fe4219

Browse files
author
Himani Anil Deshpande
committed
[SlurmTopo] Do not support Slurm Topology for AL2
1 parent 73ead41 commit 7fe4219

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

test/unit/slurm/test_topology_generator.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@
1010
# limitations under the License.
1111

1212
import pytest
13-
import yaml
1413
import os
1514
from assertpy import assert_that
16-
from config_utils import get_template_folder
17-
from unittest.mock import mock_open, patch
1815
from pcluster_topology_generator import (
16+
cleanup_topology_config_file,
1917
generate_topology_config_file,
20-
CriticalError,
21-
_load_cluster_config,
2218
)
2319

2420

@@ -41,21 +37,17 @@ def test_generate_topology_config(test_datadir, tmpdir, file_name_suffix):
4137
_assert_files_are_equal(output_file_path, test_datadir / "expected_outputs" / output_file_name)
4238

4339

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()
6153

0 commit comments

Comments
 (0)