[Frontend] [gpt-oss] Mcp type bug (#27689)

Signed-off-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
Signed-off-by: Alec Solder <alecs@fb.com>
Signed-off-by: Ye (Charlotte) Qi <yeq@meta.com>
Co-authored-by: Jialin Ouyang <Jialin.Ouyang@gmail.com>
Co-authored-by: Alec Solder <alecs@fb.com>
Co-authored-by: Ye (Charlotte) Qi <yeq@meta.com>
This commit is contained in:
Alec S
2025-10-29 10:01:32 +00:00
committed by GitHub
co-authored by Jialin Ouyang Alec Solder Ye Qi
parent 3c7fefdeba
commit ab2eb27b74
7 changed files with 293 additions and 44 deletions
+108
View File
@@ -10,6 +10,7 @@ import vllm.envs as envs
from vllm.envs import (
enable_envs_cache,
env_list_with_choices,
env_set_with_choices,
env_with_choices,
environment_variables,
)
@@ -257,3 +258,110 @@ class TestEnvListWithChoices:
with patch.dict(os.environ, {"TEST_ENV": "option1,option1,option2"}):
env_func = env_list_with_choices("TEST_ENV", [], ["option1", "option2"])
assert env_func() == ["option1", "option1", "option2"]
class TestEnvSetWithChoices:
"""Test cases for env_set_with_choices function."""
def test_default_list_returned_when_env_not_set(self):
"""Test that default list is returned when env var is not set."""
env_func = env_set_with_choices(
"NONEXISTENT_ENV", ["default1", "default2"], ["option1", "option2"]
)
assert env_func() == {"default1", "default2"}
def test_empty_default_list_returned_when_env_not_set(self):
"""Test that empty default list is returned when env not set."""
env_func = env_set_with_choices("NONEXISTENT_ENV", [], ["option1", "option2"])
assert env_func() == set()
def test_single_valid_value_parsed_correctly(self):
"""Test that single valid value is parsed correctly."""
with patch.dict(os.environ, {"TEST_ENV": "option1"}):
env_func = env_set_with_choices("TEST_ENV", [], ["option1", "option2"])
assert env_func() == {"option1"}
def test_multiple_valid_values_parsed_correctly(self):
"""Test that multiple valid values are parsed correctly."""
with patch.dict(os.environ, {"TEST_ENV": "option1,option2"}):
env_func = env_set_with_choices("TEST_ENV", [], ["option1", "option2"])
assert env_func() == {"option1", "option2"}
def test_values_with_whitespace_trimmed(self):
"""Test that values with whitespace are trimmed correctly."""
with patch.dict(os.environ, {"TEST_ENV": " option1 , option2 "}):
env_func = env_set_with_choices("TEST_ENV", [], ["option1", "option2"])
assert env_func() == {"option1", "option2"}
def test_empty_values_filtered_out(self):
"""Test that empty values are filtered out."""
with patch.dict(os.environ, {"TEST_ENV": "option1,,option2,"}):
env_func = env_set_with_choices("TEST_ENV", [], ["option1", "option2"])
assert env_func() == {"option1", "option2"}
def test_empty_string_returns_default(self):
"""Test that empty string returns default."""
with patch.dict(os.environ, {"TEST_ENV": ""}):
env_func = env_set_with_choices(
"TEST_ENV", ["default"], ["option1", "option2"]
)
assert env_func() == {"default"}
def test_only_commas_returns_default(self):
"""Test that string with only commas returns default."""
with patch.dict(os.environ, {"TEST_ENV": ",,,"}):
env_func = env_set_with_choices(
"TEST_ENV", ["default"], ["option1", "option2"]
)
assert env_func() == {"default"}
def test_case_sensitive_validation(self):
"""Test case sensitive validation."""
with patch.dict(os.environ, {"TEST_ENV": "option1,OPTION2"}):
env_func = env_set_with_choices(
"TEST_ENV", [], ["option1", "option2"], case_sensitive=True
)
with pytest.raises(ValueError, match="Invalid value 'OPTION2' in TEST_ENV"):
env_func()
def test_case_insensitive_validation(self):
"""Test case insensitive validation."""
with patch.dict(os.environ, {"TEST_ENV": "OPTION1,option2"}):
env_func = env_set_with_choices(
"TEST_ENV", [], ["option1", "option2"], case_sensitive=False
)
assert env_func() == {"OPTION1", "option2"}
def test_invalid_value_in_list_raises_error(self):
"""Test that invalid value in list raises ValueError."""
with patch.dict(os.environ, {"TEST_ENV": "option1,invalid,option2"}):
env_func = env_set_with_choices("TEST_ENV", [], ["option1", "option2"])
with pytest.raises(ValueError, match="Invalid value 'invalid' in TEST_ENV"):
env_func()
def test_callable_choices_resolved_correctly(self):
"""Test that callable choices are resolved correctly."""
def get_choices():
return ["dynamic1", "dynamic2"]
with patch.dict(os.environ, {"TEST_ENV": "dynamic1,dynamic2"}):
env_func = env_set_with_choices("TEST_ENV", [], get_choices)
assert env_func() == {"dynamic1", "dynamic2"}
def test_callable_choices_with_invalid_value(self):
"""Test that callable choices raise error for invalid values."""
def get_choices():
return ["dynamic1", "dynamic2"]
with patch.dict(os.environ, {"TEST_ENV": "dynamic1,invalid"}):
env_func = env_set_with_choices("TEST_ENV", [], get_choices)
with pytest.raises(ValueError, match="Invalid value 'invalid' in TEST_ENV"):
env_func()
def test_duplicate_values_deduped(self):
"""Test that duplicate values in the list are deduped."""
with patch.dict(os.environ, {"TEST_ENV": "option1,option1,option2"}):
env_func = env_set_with_choices("TEST_ENV", [], ["option1", "option2"])
assert env_func() == {"option1", "option2"}