83616ae4a3
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 49s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 1m11s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m42s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m44s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 4m16s
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
PR Automation / Auto Approve on CI Green (pull_request) Has been cancelled
P0: 删除 scripts 表 title_text/title_category/title_config 三列 - migration 078_drop_script_title_fields 批量删列 - schemas/script.py: ScriptResponse/Create/Update 精简到 title/content/segments/tags - services/script_service.py: 移除 get_title_config_for_script 和三字段参数 - routes/scripts.py: _to_response 不再映射三字段,create/update 不传三字段 - models.py: ScriptModel 移除三列;保留 TemplateModel/GenerationTaskModel/AiAvatarRenderJob 的 title_config(渲染层配置) P1: 废弃 /api/v1/titles/* - 所有子路径统一返回 HTTP 410 Gone + Deprecation/Sunset header - 前端应直接调 GET /api/v1/scripts 取文案列表,用 title 作为标题 P1: 清理旧定价档位 - 新会员体系统一为 free/monthly/quarterly/yearly(#1951/#1955) - schemas/subscription.py: MembershipType 替代旧 PlanType,BillingCycle 新增 QUARTERLY - routes/subscription.py: _PLAN_NAMES 新映射;payment-callback 接受 quarterly(90天);旧档位 plan 值拒绝 - routes/_helpers.py: get_user_plan() 归一化 standard/basic→monthly、pro/premium/enterprise→quarterly - packages/domain/quota.py: QUOTA_TIERS 改为 free/monthly/quarterly/yearly;保留 basic/standard/premium/pro/enterprise 别名兼容历史数据 - 单元测试 15527 passed
118 lines
4.7 KiB
Python
118 lines
4.7 KiB
Python
"""#1894 方向修正 — 集成测试.
|
|
|
|
覆盖:
|
|
- ScriptModel 不再有 title_text/title_category/title_config 列
|
|
- ScriptService 不再接受/暴露这三个字段
|
|
- /api/v1/titles/* 所有方法返回 410 Gone
|
|
- /api/v1/scripts 响应不含这三个字段
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
import uuid
|
|
from datetime import UTC, datetime, timezone
|
|
from pathlib import Path
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
_APPS_API = str(Path(__file__).resolve().parents[2] / "apps" / "api")
|
|
if _APPS_API not in sys.path:
|
|
sys.path.insert(0, _APPS_API)
|
|
os.environ.setdefault("JWT_SECRET_KEY", "dev-secret-key-for-testing")
|
|
|
|
from main import app # noqa: E402
|
|
|
|
|
|
def _make_mock_auth_user(user_id="user-001"):
|
|
return MagicMock(user=MagicMock(id=user_id))
|
|
|
|
|
|
# ── TestScriptModelNoTitleFields ─────────────────────────────────────────
|
|
|
|
|
|
class TestScriptModelNoTitleFields:
|
|
"""验证 ScriptModel 已删除 title_text/title_category/title_config 列."""
|
|
|
|
def test_model_has_no_title_text(self):
|
|
from packages.adapters.sqlalchemy_impl.models import ScriptModel
|
|
assert not hasattr(ScriptModel, "title_text") or "title_text" not in {c.name for c in ScriptModel.__table__.columns}
|
|
|
|
def test_model_has_no_title_category(self):
|
|
from packages.adapters.sqlalchemy_impl.models import ScriptModel
|
|
assert "title_category" not in {c.name for c in ScriptModel.__table__.columns}
|
|
|
|
def test_model_has_no_title_config(self):
|
|
from packages.adapters.sqlalchemy_impl.models import ScriptModel
|
|
assert "title_config" not in {c.name for c in ScriptModel.__table__.columns}
|
|
|
|
def test_model_retains_core_fields(self):
|
|
from packages.adapters.sqlalchemy_impl.models import ScriptModel
|
|
cols = {c.name for c in ScriptModel.__table__.columns}
|
|
for expected in ("id", "user_id", "title", "content", "segments", "tags", "created_at", "updated_at"):
|
|
assert expected in cols, f"ScriptModel 缺字段 {expected}"
|
|
|
|
|
|
# ── TestScriptServiceSignature ──────────────────────────────────────────
|
|
|
|
|
|
class TestScriptServiceSignature:
|
|
"""验证 ScriptService 的 create/update 不接受已删除字段."""
|
|
|
|
def test_create_script_rejects_title_fields(self):
|
|
"""Python 层:传入旧字段应抛 TypeError(被移除了)."""
|
|
from app.services.script_service import ScriptService
|
|
import inspect
|
|
|
|
sig = inspect.signature(ScriptService.create_script)
|
|
for name in ("title_text", "title_category", "title_config"):
|
|
assert name not in sig.parameters, f"create_script 仍接受参数 {name}"
|
|
|
|
def test_update_script_rejects_title_fields(self):
|
|
from app.services.script_service import ScriptService
|
|
import inspect
|
|
|
|
sig = inspect.signature(ScriptService.update_script)
|
|
for name in ("title_text", "title_category", "title_config"):
|
|
assert name not in sig.parameters, f"update_script 仍接受参数 {name}"
|
|
|
|
def test_get_title_config_removed(self):
|
|
from app.services.script_service import ScriptService
|
|
assert not hasattr(ScriptService, "get_title_config_for_script"), "get_title_config_for_script 应已删除"
|
|
|
|
|
|
# ── TestTitlesApiGone ───────────────────────────────────────────────────
|
|
|
|
|
|
class TestTitlesApiGone:
|
|
"""验证 /api/v1/titles 所有方法返回 410 Gone."""
|
|
|
|
def setup_method(self):
|
|
from app.auth import get_current_user
|
|
self._mock_user = _make_mock_auth_user()
|
|
app.dependency_overrides[get_current_user] = lambda: self._mock_user
|
|
self.client = TestClient(app)
|
|
|
|
def teardown_method(self):
|
|
app.dependency_overrides.clear()
|
|
|
|
@pytest.mark.parametrize("method,path", [
|
|
("get", "/api/v1/titles"),
|
|
("post", "/api/v1/titles"),
|
|
("get", "/api/v1/titles/some-id"),
|
|
("put", "/api/v1/titles/some-id"),
|
|
("delete", "/api/v1/titles/some-id"),
|
|
("patch", "/api/v1/titles/some-id"),
|
|
("get", "/api/v1/titles/any/nested/path"),
|
|
])
|
|
def test_titles_routes_return_410(self, method, path):
|
|
resp = getattr(self.client, method)(path)
|
|
assert resp.status_code == 410, f"{method.upper()} {path} 应返回 410,实际 {resp.status_code}: {resp.text}"
|
|
data = resp.json()
|
|
assert "error" in data or "message" in data or "GONE" in resp.text
|
|
# Deprecation header
|
|
assert resp.headers.get("Deprecation") == "true"
|