61 / 65 · 14 API Testing Fundamentals · API Versioning← prev⊞ allnext →☰ Read as one page
8.4Deprecation Testing
def test_deprecated_endpoint_returns_warning(api):
"""Deprecated endpoints should include a deprecation warning header."""
r = api.get("/v1/legacy-endpoint")
assert r.status_code == 200 # Still works
# Should include deprecation warning
assert "Deprecation" in r.headers or "Sunset" in r.headers or \
"X-Deprecated" in r.headers
def test_deprecated_endpoint_still_functional(api):
"""Deprecated endpoints must still work until officially removed."""
r = api.get("/v1/legacy-endpoint")
assert r.status_code == 200
assert len(r.json()["items"]) > 0 # Still returns data