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>
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
"""
|
|
Tests for models listing router.
|
|
"""
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_list_models(client: TestClient) -> None:
|
|
"""Test listing available models."""
|
|
response = client.get("/v1/models")
|
|
|
|
assert response.status_code == 200
|
|
data = response.json()
|
|
|
|
# Verify response structure
|
|
assert data["object"] == "list"
|
|
assert "data" in data
|
|
assert isinstance(data["data"], list)
|
|
|
|
# Should have both models from registry
|
|
assert len(data["data"]) == 2
|
|
|
|
# Check for expected model IDs
|
|
model_ids = [m["id"] for m in data["data"]]
|
|
assert "lorem-tester" in model_ids
|
|
assert "Tatlock" in model_ids
|
|
|
|
# Verify model structure
|
|
for model in data["data"]:
|
|
assert model["object"] == "model"
|
|
assert "id" in model
|
|
assert "created" in model
|
|
assert "owned_by" in model
|
|
assert model["owned_by"] == "tatlock"
|
|
|
|
|
|
@pytest.mark.unit
|
|
def test_models_endpoint_returns_json(client: TestClient) -> None:
|
|
"""Test that models endpoint returns valid JSON."""
|
|
response = client.get("/v1/models")
|
|
|
|
assert response.status_code == 200
|
|
assert response.headers["content-type"] == "application/json"
|
|
|
|
# Should be able to parse as JSON
|
|
data = response.json()
|
|
assert isinstance(data, dict)
|