# AUTOGENERATED - modify shared_anyscale_util in root directory to make changes
import pytest

from shared_anyscale_utils.utils.ray_semver import (
    get_byod_ray_version_alias,
    ray_semver_compare,
)


@pytest.mark.parametrize(
    ("a", "b", "expected_result"),
    [
        ("ray2.7.0", "ray2.7.0", 0),
        ("ray2.7.0optimized", "ray2.7.0", 0),
        ("ray2.7.0oss", "ray2.7.0", 0),
        ("ray2.0.1rc", "ray2.0.1", 0),
        ("ray3.5.1customsuffix", "ray3.5.1", 0),
        ("ray1.2.3.dev456", "ray1.2.3", 0),
        ("ray2.0.0.final", "ray2.0.0", 0),
        ("ray2.7.0", "ray2.6.0", 1),
        ("ray2.0.1rc", "ray2.0.2", -1),
        ("ray2.7.0optimized", "ray2.7.0oss", 0),
    ],
)
def test_ray_semver_compare(a, b, expected_result):
    assert ray_semver_compare(a, b) == expected_result


@pytest.mark.parametrize(
    ("ray_version", "expected_alias"),
    [
        ("2.7.0rc1", "2.7.0rc1"),
        ("2.6.0", "2.6.0"),
        ("2.7.1", "2.7.1optimized"),
        ("2.7.0", "2.7.0optimized"),
        ("nightly", "nightly"),
    ],
)
def test_get_byod_ray_version_alias(ray_version, expected_alias):
    assert get_byod_ray_version_alias(ray_version) == expected_alias
