mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-05-18 12:19:18 -05:00
999f5c6319
Document the dual HTTP surface everywhere integrators look: OpenAPI intro and servers, ARCHITECTURE, REST_API, API_VERSIONING (deprecated vs internal routes, shared modules), and CONTRIBUTING (v1-first rule). Session JSON routes in app/routes/api.py that overlap REST v1 now return X-API-Deprecated and a Link header with rel successor-version, implemented via app/utils/api_deprecation.py. Extract shared global search into app/services/global_search_service.py for both GET /api/search and GET /api/v1/search while preserving legacy short-query 200 empty responses and v1 400 validation. Refactor legacy POST /api/timer/start, /api/timer/stop, and the start path of /api/timer/resume to use TimeTrackingService; keep existing socketio emits for the web UI. Add tests/test_api_deprecation_headers.py and adjust search partial-failure tests to patch Project.query on the service module.
37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
"""Session /api routes that overlap v1 should expose deprecation headers."""
|
|
|
|
import pytest
|
|
|
|
pytestmark = [pytest.mark.api, pytest.mark.integration]
|
|
|
|
|
|
def test_legacy_health_deprecation_header(client):
|
|
r = client.get("/api/health")
|
|
assert r.status_code == 200
|
|
assert r.headers.get("X-API-Deprecated") == "true"
|
|
assert "successor-version" in (r.headers.get("Link") or "")
|
|
assert "/api/v1/health" in (r.headers.get("Link") or "")
|
|
|
|
|
|
def test_legacy_search_deprecation_header(authenticated_client, project):
|
|
r = authenticated_client.get("/api/search", query_string={"q": project.name[:3]})
|
|
assert r.status_code == 200
|
|
assert r.headers.get("X-API-Deprecated") == "true"
|
|
link = r.headers.get("Link") or ""
|
|
assert "successor-version" in link
|
|
assert "/api/v1/search" in link
|
|
|
|
|
|
def test_legacy_timer_status_deprecation_header(authenticated_client):
|
|
r = authenticated_client.get("/api/timer/status")
|
|
assert r.status_code == 200
|
|
assert r.headers.get("X-API-Deprecated") == "true"
|
|
assert "/api/v1/timer/status" in (r.headers.get("Link") or "")
|
|
|
|
|
|
def test_legacy_projects_list_deprecation_header(authenticated_client):
|
|
r = authenticated_client.get("/api/projects")
|
|
assert r.status_code == 200
|
|
assert r.headers.get("X-API-Deprecated") == "true"
|
|
assert "/api/v1/projects" in (r.headers.get("Link") or "")
|