e6a12b9a7c
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
"""Deprecation header tests (Stage 1 PR5)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from starlette.testclient import TestClient
|
|
|
|
|
|
def _make_app():
|
|
from fastapi import FastAPI
|
|
|
|
from app.gateway.deprecation_middleware import ApiDeprecationMiddleware
|
|
|
|
app = FastAPI()
|
|
app.add_middleware(ApiDeprecationMiddleware)
|
|
|
|
@app.get("/api/threads")
|
|
async def legacy():
|
|
return {"ok": True}
|
|
|
|
@app.get("/api/v1/threads")
|
|
async def versioned():
|
|
return {"ok": True}
|
|
|
|
@app.get("/api/langgraph/info")
|
|
async def lg():
|
|
return {"ok": True}
|
|
|
|
@app.get("/api/assistants/info")
|
|
async def assistants():
|
|
return {"ok": True}
|
|
|
|
return app
|
|
|
|
|
|
def test_legacy_path_gets_deprecation_header():
|
|
client = TestClient(_make_app())
|
|
r = client.get("/api/threads")
|
|
assert r.headers.get("X-API-Deprecated") == "2027-01-01"
|
|
|
|
|
|
def test_versioned_path_no_header():
|
|
client = TestClient(_make_app())
|
|
r = client.get("/api/v1/threads")
|
|
assert "X-API-Deprecated" not in r.headers
|
|
|
|
|
|
def test_langgraph_path_no_header():
|
|
client = TestClient(_make_app())
|
|
r = client.get("/api/langgraph/info")
|
|
assert "X-API-Deprecated" not in r.headers
|
|
|
|
|
|
def test_assistants_compat_path_gets_deprecation_header():
|
|
# assistants_compat is an un-versioned LangGraph-platform stub; it
|
|
# intentionally carries the deprecation header (it is /api/, not
|
|
# /api/v1 or /api/langgraph). Documented here to prevent confusion.
|
|
client = TestClient(_make_app())
|
|
r = client.get("/api/assistants/info")
|
|
assert r.headers.get("X-API-Deprecated") == "2027-01-01"
|