diff --git a/tests/input/test_custom_coordinate_release.yml b/tests/input/test_custom_coordinate_release.yml new file mode 100644 index 000000000..ba017ed5d --- /dev/null +++ b/tests/input/test_custom_coordinate_release.yml @@ -0,0 +1,26 @@ +parcel: + numpy1: 1.0.0 + numpy2: 2.0.0 +letter: + py38: + numpy1: 1.38.0 + numpy2: 2.28.0 + py311: + numpy1: 1.311.0 + numpy2: 2.211.0 +box: + rhel8: + py38: + numpy1: 1.38.8 + numpy2: 2.28.8 + py311: + numpy1: 1.311.8 + numpy2: 2.211.8 + rhel9: + py38: + numpy1: 1.38.9 + numpy2: 2.28.9 + py311: + numpy1: 1.311.9 + numpy2: 2.211.9 +case: 0.0.1 \ No newline at end of file diff --git a/tests/test_release_transpiler.py b/tests/test_release_transpiler.py index a59af1437..bcc1635f4 100644 --- a/tests/test_release_transpiler.py +++ b/tests/test_release_transpiler.py @@ -1,6 +1,8 @@ import os +from contextlib import contextmanager import pytest +import yaml from komodo.release_transpiler import ( transpile_releases, @@ -8,6 +10,9 @@ ) from tests import _get_test_root +@contextmanager +def does_not_raise(): + yield @pytest.mark.parametrize( "matrix", @@ -29,6 +34,42 @@ def test_transpile_add_argument(tmpdir, matrix): f"{release_base}-{py_coordinate_filename_format}-{rhel_coordinate_filename_format}.yml" ) +@pytest.mark.parametrize( + ("matrix", "expectation"), + [ + ({"py": ["3.8"], "rhel": ["8"], "numpy": ["1"]}, does_not_raise()), + ({"py": ["3.11"], "rhel": ["9"], "numpy": ["2"]}, does_not_raise()), + ({"py": ["3.8", "3.11"], "rhel": ["8", "9"], "numpy": ["1", "2"]}, does_not_raise()), + ({"py": ["3.8", "3.11"], "rhel": ["8", "9"]}, pytest.raises(KeyError)), + ({"py": ["3.8", "3.11"], "rhel": ["8", "9"], "numpy": ["3"]}, pytest.raises(KeyError)), + ], +) +def test_transpile_custom_coordinate_releases(tmpdir, matrix, expectation): + release_file = os.path.join(_get_test_root(), "input", "test_custom_coordinate_release.yml") + release_base = os.path.basename(release_file).strip(".yml") + + packages = ["parcel", "letter", "box", "case"] + keywords = ["rhel", "py", "numpy"] + + with tmpdir.as_cwd(): + with expectation: + transpile_releases(release_file, os.getcwd(), matrix) + + for rhel_coordinate in matrix["rhel"]: + rhel_coordinate_filename_format = f"rhel{rhel_coordinate}" + for py_coordinate in matrix["py"]: + py_coordinate_filename_format = f"py{py_coordinate.replace('.', '')}" + for custom_coordinate in matrix["numpy"]: + custom_coordinate_filename_format = f"numpy{custom_coordinate}" + + release_file = f"{release_base}-{py_coordinate_filename_format}-{rhel_coordinate_filename_format}-{custom_coordinate_filename_format}.yml" + assert os.path.isfile(release_file) + content = yaml.safe_load(open(release_file)) + + for p in packages: + assert p in content + for k in keywords: + assert k not in content @pytest.mark.parametrize( ("matrix", "error_message_content"),