generated from kgod/ai-review-template
自内部仓库剥离深度优化与 RAG 知识库后的交付版本: - Builder 对话式简历生成(FSM + 意图路由 LLM 兜底增强) - 条目级轻度优化:事实覆盖门禁 + STAR/bullet 修复链,功能/简介/成果与技术栈同级保护 - 简历导入:DOCX/PDF 解析、结构归一、手机号脱敏 - PostgreSQL 运行时 + Alembic 迁移链 Co-Authored-By: Claude <noreply@anthropic.com>
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
"""Production docs gate: /docs, /redoc, /openapi.json 404 unless RESUME_AGENT_API_DOCS opts in."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
from app.asgi import application
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _docs_flag_cleared(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.delenv("RESUME_AGENT_API_DOCS", raising=False)
|
|
|
|
|
|
def test_api_docs_are_not_served_by_default() -> None:
|
|
client = TestClient(application)
|
|
assert client.get("/docs").status_code == 404
|
|
assert client.get("/redoc").status_code == 404
|
|
assert client.get("/openapi.json").status_code == 404
|
|
|
|
|
|
def test_app_routes_still_work_through_the_gate() -> None:
|
|
client = TestClient(application)
|
|
assert client.get("/health").status_code == 200
|
|
|
|
|
|
def test_api_docs_can_be_enabled_explicitly(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setenv("RESUME_AGENT_API_DOCS", "1")
|
|
client = TestClient(application)
|
|
assert client.get("/openapi.json").status_code == 200
|