Skip to content

Commit 538d345

Browse files
RHOAIENG-27792: rayjob test improvements
1 parent aea0cff commit 538d345

File tree

5 files changed

+362
-81
lines changed

5 files changed

+362
-81
lines changed

poetry.lock

Lines changed: 40 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cryptography = "43.0.3"
3333
executing = "1.2.0"
3434
pydantic = "< 2"
3535
ipywidgets = "8.1.2"
36-
python-client = { git = "https://github.com/ray-project/kuberay.git", subdirectory = "clients/python-client", rev = "a16c0365e3b19a202d835097e1139eca9406b383" }
36+
python-client = { git = "https://github.com/ray-project/kuberay.git", subdirectory = "clients/python-client", rev = "b2fd91b58c2bbe22f9b4f730c5a8f3180c05e570" }
3737

3838
[[tool.poetry.source]]
3939
name = "pypi"
@@ -59,6 +59,10 @@ pytest-mock = "3.11.1"
5959
pytest-timeout = "2.3.1"
6060
jupyterlab = "4.3.1"
6161

62+
63+
[tool.poetry.group.dev.dependencies]
64+
diff-cover = "^9.6.0"
65+
6266
[tool.pytest.ini_options]
6367
filterwarnings = [
6468
"ignore::DeprecationWarning:pkg_resources",

src/codeflare_sdk/ray/rayjobs/test_config.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,40 @@ def test_gpu_validation_fails_with_unsupported_accelerator():
8282
ManagedClusterConfig(head_accelerators={"unsupported.com/accelerator": 1})
8383

8484

85+
def test_config_type_validation_errors(mocker):
86+
"""Test that type validation properly raises errors with incorrect types."""
87+
# Mock the _is_type method to return False for type checking
88+
mocker.patch.object(
89+
ManagedClusterConfig,
90+
"_is_type",
91+
side_effect=lambda value, expected_type: False, # Always fail type check
92+
)
93+
94+
# This should raise TypeError during initialization
95+
with pytest.raises(TypeError, match="Type validation failed"):
96+
ManagedClusterConfig()
97+
98+
99+
def test_config_is_type_method():
100+
"""Test the _is_type static method for type checking."""
101+
# Test basic types
102+
assert ManagedClusterConfig._is_type("test", str) is True
103+
assert ManagedClusterConfig._is_type(123, int) is True
104+
assert ManagedClusterConfig._is_type(123, str) is False
105+
106+
# Test optional types (Union with None)
107+
from typing import Optional
108+
109+
assert ManagedClusterConfig._is_type(None, Optional[str]) is True
110+
assert ManagedClusterConfig._is_type("test", Optional[str]) is True
111+
assert ManagedClusterConfig._is_type(123, Optional[str]) is False
112+
113+
# Test dict types
114+
assert ManagedClusterConfig._is_type({}, dict) is True
115+
assert ManagedClusterConfig._is_type({"key": "value"}, dict) is True
116+
assert ManagedClusterConfig._is_type([], dict) is False
117+
118+
85119
def test_ray_usage_stats_always_disabled_by_default():
86120
"""Test that RAY_USAGE_STATS_ENABLED is always set to '0' by default"""
87121
config = ManagedClusterConfig()

0 commit comments

Comments
 (0)