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