style: apply ruff's automatic fixes and formatter
Mechanical only, and separated from the judgment calls that follow so the reviewable changes are not buried in a 98-file whitespace diff. 227 automatic fixes: 60 blank lines carrying whitespace, 60 unsorted import blocks, 34 Optional[X] to X | None, 28 unused imports, 16 deprecated typing imports, 12 datetime.timezone.utc to datetime.UTC, and assorted smaller modernisations. Then `ruff format` over src and tests: 98 files reformatted, 35 already conforming. No file among the unused-import findings defines __all__ or is an __init__.py, so nothing here removes a re-export. `make test`: 658 passed, unchanged from HEAD. Two things observed while verifying, neither addressed here: `pytest tests/` cannot collect — tests/e2e/test_orchestration_e2e.py uses an `e2e` marker that is not registered, and the config is strict about markers. This fails identically at HEAD, so it predates this change; `make test` passes because it ignores tests/e2e, tests/integration and tests/contracts. test_tatlock_tool_call_logging_calculator is flaky. It failed once in a full run with these changes and passed on the next, passes in isolation with them, and fails in isolation at HEAD. It is order- or timing-dependent, not a regression from this commit — established by running the full suite both ways rather than by reasoning about which change could have caused it. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
"""
|
||||
Tests for error handling in Responses API.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from httpx import AsyncClient
|
||||
@@ -12,10 +14,8 @@ def test_model_not_found_error(client: TestClient) -> None:
|
||||
"""Test response when model doesn't exist."""
|
||||
request_data = {
|
||||
"model": "nonexistent-model-12345",
|
||||
"input": [
|
||||
{"role": "user", "content": "Hello"}
|
||||
],
|
||||
"stream": False
|
||||
"input": [{"role": "user", "content": "Hello"}],
|
||||
"stream": False,
|
||||
}
|
||||
|
||||
response = client.post("/v1/responses", json=request_data)
|
||||
@@ -29,11 +29,7 @@ def test_model_not_found_error(client: TestClient) -> None:
|
||||
@pytest.mark.unit
|
||||
def test_validation_error_missing_model(client: TestClient) -> None:
|
||||
"""Test validation error when model field is missing."""
|
||||
request_data = {
|
||||
"input": [
|
||||
{"role": "user", "content": "Hello"}
|
||||
]
|
||||
}
|
||||
request_data = {"input": [{"role": "user", "content": "Hello"}]}
|
||||
|
||||
response = client.post("/v1/responses", json=request_data)
|
||||
|
||||
@@ -45,10 +41,8 @@ def test_validation_error_invalid_temperature(client: TestClient) -> None:
|
||||
"""Test validation error for out-of-range temperature."""
|
||||
request_data = {
|
||||
"model": "lorem-tester",
|
||||
"input": [
|
||||
{"role": "user", "content": "Hello"}
|
||||
],
|
||||
"temperature": 3.0 # Max is 2.0
|
||||
"input": [{"role": "user", "content": "Hello"}],
|
||||
"temperature": 3.0, # Max is 2.0
|
||||
}
|
||||
|
||||
response = client.post("/v1/responses", json=request_data)
|
||||
@@ -61,10 +55,8 @@ def test_rate_limit_error(client: TestClient) -> None:
|
||||
"""Test rate limit error trigger."""
|
||||
request_data = {
|
||||
"model": "lorem-tester",
|
||||
"input": [
|
||||
{"role": "user", "content": "trigger_rate_limit"}
|
||||
],
|
||||
"stream": False
|
||||
"input": [{"role": "user", "content": "trigger_rate_limit"}],
|
||||
"stream": False,
|
||||
}
|
||||
|
||||
response = client.post("/v1/responses", json=request_data)
|
||||
@@ -78,10 +70,8 @@ def test_context_overflow_error(client: TestClient) -> None:
|
||||
"""Test context length overflow error trigger."""
|
||||
request_data = {
|
||||
"model": "lorem-tester",
|
||||
"input": [
|
||||
{"role": "user", "content": "trigger_context_overflow"}
|
||||
],
|
||||
"stream": False
|
||||
"input": [{"role": "user", "content": "trigger_context_overflow"}],
|
||||
"stream": False,
|
||||
}
|
||||
|
||||
response = client.post("/v1/responses", json=request_data)
|
||||
@@ -96,10 +86,8 @@ async def test_streaming_model_not_found(async_client: AsyncClient) -> None:
|
||||
"""Test streaming response with nonexistent model."""
|
||||
request_data = {
|
||||
"model": "nonexistent-streaming-model",
|
||||
"input": [
|
||||
{"role": "user", "content": "Hello"}
|
||||
],
|
||||
"stream": True
|
||||
"input": [{"role": "user", "content": "Hello"}],
|
||||
"stream": True,
|
||||
}
|
||||
|
||||
async with async_client.stream(
|
||||
@@ -133,10 +121,8 @@ async def test_streaming_rate_limit_error(async_client: AsyncClient) -> None:
|
||||
"""Test streaming with rate limit error."""
|
||||
request_data = {
|
||||
"model": "lorem-tester",
|
||||
"input": [
|
||||
{"role": "user", "content": "trigger_rate_limit"}
|
||||
],
|
||||
"stream": True
|
||||
"input": [{"role": "user", "content": "trigger_rate_limit"}],
|
||||
"stream": True,
|
||||
}
|
||||
|
||||
async with async_client.stream(
|
||||
@@ -177,10 +163,8 @@ async def test_streaming_context_overflow_error(async_client: AsyncClient) -> No
|
||||
"""Test streaming with context overflow error."""
|
||||
request_data = {
|
||||
"model": "lorem-tester",
|
||||
"input": [
|
||||
{"role": "user", "content": "trigger_context_overflow"}
|
||||
],
|
||||
"stream": True
|
||||
"input": [{"role": "user", "content": "trigger_context_overflow"}],
|
||||
"stream": True,
|
||||
}
|
||||
|
||||
async with async_client.stream(
|
||||
@@ -215,17 +199,9 @@ def test_function_call_output_item(client: TestClient) -> None:
|
||||
"""Test response with function call items."""
|
||||
request_data = {
|
||||
"model": "lorem-tester",
|
||||
"input": [
|
||||
{"role": "user", "content": "Use the search tool"}
|
||||
],
|
||||
"tools": [
|
||||
{
|
||||
"name": "search",
|
||||
"description": "Search for information",
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"stream": False
|
||||
"input": [{"role": "user", "content": "Use the search tool"}],
|
||||
"tools": [{"name": "search", "description": "Search for information", "parameters": {}}],
|
||||
"stream": False,
|
||||
}
|
||||
|
||||
response = client.post("/v1/responses", json=request_data)
|
||||
@@ -248,10 +224,8 @@ def test_pipeline_prefix_stripping(client: TestClient) -> None:
|
||||
"""Test that pipeline prefixes are stripped from model names."""
|
||||
request_data = {
|
||||
"model": "some_pipeline.lorem-tester",
|
||||
"input": [
|
||||
{"role": "user", "content": "Hello"}
|
||||
],
|
||||
"stream": False
|
||||
"input": [{"role": "user", "content": "Hello"}],
|
||||
"stream": False,
|
||||
}
|
||||
|
||||
response = client.post("/v1/responses", json=request_data)
|
||||
@@ -267,10 +241,8 @@ def test_multiple_pipeline_prefixes(client: TestClient) -> None:
|
||||
"""Test multiple dots in model name (only first is prefix)."""
|
||||
request_data = {
|
||||
"model": "pipeline.sub.lorem-tester",
|
||||
"input": [
|
||||
{"role": "user", "content": "Hello"}
|
||||
],
|
||||
"stream": False
|
||||
"input": [{"role": "user", "content": "Hello"}],
|
||||
"stream": False,
|
||||
}
|
||||
|
||||
response = client.post("/v1/responses", json=request_data)
|
||||
|
||||
Reference in New Issue
Block a user