Signed-off-by: Nick Cao <ncao@redhat.com> Co-authored-by: Codex <noreply@openai.com>
42 lines
1.7 KiB
Python
42 lines
1.7 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
|
"""Unit tests for AsyncOmni input streaming parameter validation."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from vllm.sampling_params import RequestOutputKind, SamplingParams
|
|
|
|
from vllm_omni.entrypoints.async_omni import AsyncOmni
|
|
|
|
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
|
|
|
|
|
|
class TestAsyncOmniStreamingParamsValidation:
|
|
def test_accepts_streaming_friendly_params(self) -> None:
|
|
p = SamplingParams(
|
|
n=1,
|
|
stop=[],
|
|
output_kind=RequestOutputKind.DELTA,
|
|
)
|
|
AsyncOmni._validate_streaming_input_sampling_params(p)
|
|
|
|
def test_rejects_non_sampling_params(self) -> None:
|
|
with pytest.raises(ValueError, match="Input streaming"):
|
|
AsyncOmni._validate_streaming_input_sampling_params(object()) # type: ignore[arg-type]
|
|
|
|
def test_rejects_n_greater_than_one(self) -> None:
|
|
p = SamplingParams(n=2, stop=[], output_kind=RequestOutputKind.DELTA)
|
|
with pytest.raises(ValueError, match="Input streaming"):
|
|
AsyncOmni._validate_streaming_input_sampling_params(p)
|
|
|
|
def test_rejects_final_only(self) -> None:
|
|
p = SamplingParams(n=1, stop=[], output_kind=RequestOutputKind.FINAL_ONLY)
|
|
with pytest.raises(ValueError, match="Input streaming"):
|
|
AsyncOmni._validate_streaming_input_sampling_params(p)
|
|
|
|
def test_rejects_stop_strings(self) -> None:
|
|
p = SamplingParams(n=1, stop=["\n"], output_kind=RequestOutputKind.DELTA)
|
|
with pytest.raises(ValueError, match="Input streaming"):
|
|
AsyncOmni._validate_streaming_input_sampling_params(p)
|