配置 SSOT(TOML + .env) 统一错误契约 Auth 与事务边界 Redis / Celery 可靠性:业务 Redis(DB/0)与 Celery broker/backend(DB/1)显式拆分;连接池、sync client 可观测性(OpenTelemetry + LGTM)
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""Content 静态页 HTTP smoke:legal 与官网主页。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import pytest
|
||
from fastapi import FastAPI
|
||
from httpx import ASGITransport, AsyncClient
|
||
|
||
from app.features.content.router import router as content_router
|
||
from tests.conftest import install_test_error_handlers
|
||
|
||
|
||
@pytest.fixture
|
||
def content_app() -> FastAPI:
|
||
app = install_test_error_handlers(FastAPI())
|
||
app.include_router(content_router)
|
||
return app
|
||
|
||
|
||
@pytest.mark.asyncio
|
||
@pytest.mark.parametrize(
|
||
"path,expected_fragment",
|
||
[
|
||
("/api/legal/terms", "用户协议"),
|
||
("/api/legal/privacy", "隐私"),
|
||
("/", "岁月留书"),
|
||
],
|
||
)
|
||
async def test_content_static_pages_return_html(
|
||
content_app: FastAPI, path: str, expected_fragment: str
|
||
) -> None:
|
||
transport = ASGITransport(app=content_app)
|
||
async with AsyncClient(transport=transport, base_url="http://test") as client:
|
||
r = await client.get(path)
|
||
assert r.status_code == 200
|
||
assert r.headers.get("content-type", "").startswith("text/html")
|
||
assert expected_fragment in r.text
|