forked from singularityhub/singularity-hpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_version_naming.py
100 lines (78 loc) · 2.77 KB
/
test_version_naming.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/python
# Copyright (C) 2021-2023 Vanessa Sochat.
# This Source Code Form is subject to the terms of the
# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
# with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
import io
import os
import shutil
import pytest
import shpc.main.registry as registry
import shpc.utils
from .helpers import here, init_client
@pytest.mark.parametrize(
"module_sys,module_file,container_tech",
[
("lmod", "module.lua", "singularity"),
("lmod", "module.lua", "podman"),
("tcl", "module.tcl", "singularity"),
("tcl", "module.tcl", "podman"),
("lmod", "module.lua", "singularity"),
("lmod", "module.lua", "podman"),
("tcl", "module.tcl", "singularity"),
(
"tcl",
"module.tcl",
"podman",
),
],
)
def test_version_naming_install(tmp_path, module_sys, module_file, container_tech):
"""
Test that version naming install makes module file as version number
"""
client = init_client(str(tmp_path), module_sys, container_tech)
client.settings.set("version_naming", True)
assert client.settings.get("version_naming") == True
# Install known tag
client.install("python:3.9.2-alpine")
# Modules folder is created
assert os.path.exists(client.settings.module_base)
module_dir = os.path.join(client.settings.module_base, "python")
assert os.path.exists(module_dir)
module_file = os.path.join(module_dir, "3.9.2-alpine")
assert os.path.exists(module_file)
@pytest.mark.parametrize(
"module_sys,module_file,container_tech",
[
("lmod", "module.lua", "singularity"),
("lmod", "module.lua", "podman"),
("tcl", "module.tcl", "singularity"),
("tcl", "module.tcl", "podman"),
("lmod", "module.lua", "singularity"),
("lmod", "module.lua", "podman"),
("tcl", "module.tcl", "singularity"),
(
"tcl",
"module.tcl",
"podman",
),
],
)
def test_disabled_version_naming_install(
tmp_path, module_sys, module_file, container_tech
):
"""
Test that version naming install makes module file as version number
"""
client = init_client(str(tmp_path), module_sys, container_tech)
client.settings.set("version_naming", False)
assert client.settings.get("version_naming") == False
# Install known tag
client.install("python:3.9.2-alpine")
# Modules folder is created
assert os.path.exists(client.settings.module_base)
module_dir = os.path.join(client.settings.module_base, "python", "3.9.2-alpine")
assert os.path.exists(module_dir)
module_file = os.path.join(module_dir, module_file)
assert os.path.exists(module_file)