Skip to content

Commit

Permalink
Add testing of custom coordinate transpiling
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-el committed Jan 17, 2025
1 parent 93e30fb commit 5b6925a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/input/test_custom_coordinate_release.yml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions tests/test_release_transpiler.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import os
from contextlib import contextmanager

import pytest
import yaml

from komodo.release_transpiler import (
transpile_releases,
transpile_releases_for_pip,
)
from tests import _get_test_root

@contextmanager
def does_not_raise():
yield

@pytest.mark.parametrize(
"matrix",
Expand All @@ -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"),
Expand Down

0 comments on commit 5b6925a

Please sign in to comment.