Skip to content

Commit d15b85d

Browse files
committed
Add integration test for max length
1 parent bd3386d commit d15b85d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/integration/endpoints/test_rlsapi_v1_integration.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import pytest
1515
from fastapi import HTTPException, status
16+
from fastapi.testclient import TestClient
1617
from llama_stack_client import APIConnectionError
1718
from pytest_mock import MockerFixture
1819

@@ -494,3 +495,22 @@ async def test_rlsapi_v1_infer_skip_rag(
494495
auth=test_auth,
495496
)
496497
assert isinstance(response, RlsapiV1InferResponse)
498+
499+
500+
@pytest.mark.parametrize(
501+
"json",
502+
(
503+
({"question": "?" * 10_241}),
504+
({"question": "Q", "context": {"stdin": "a" * 65_537}}),
505+
({"question": "Q", "context": {"attachments": {"contents": "A" * 65_537}}}),
506+
({"question": "Q", "context": {"terminal": {"output": "T" * 65_537}}}),
507+
),
508+
ids=["question", "stdin", "attachment_contents", "terminal_output"],
509+
)
510+
def test_infer_size_limit(integration_http_client: TestClient, json) -> None:
511+
"""Test that a field exceeding limit is rejected."""
512+
response = integration_http_client.post("/v1/infer", json=json)
513+
detail = response.json()["detail"]
514+
515+
assert response.status_code == status.HTTP_422_UNPROCESSABLE_CONTENT
516+
assert "string_too_long" in {item["type"] for item in detail}

0 commit comments

Comments
 (0)