8b69a6e18b
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (push) Successful in 2s
CI/CD Pipeline / Check push changed paths (push) Successful in 12s
CI/CD Pipeline / Build Staging API Image (push) Successful in 15s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 37s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 1m4s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 49s
CI/CD Pipeline / Frontend Unit Tests (push) Failing after 2m34s
CI/CD Pipeline / Validate - Style (push) Successful in 4m26s
CI/CD Pipeline / Validate - Python (mypy + alembic) (push) Successful in 4m32s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 2m42s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 3m19s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 3m29s
CI/CD Pipeline / Unit Tests (push) Successful in 9m55s
CI/CD Pipeline / Validate - Security (push) Successful in 11m28s
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Integration Tests (push) Failing after 15m20s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 12h25m7s
CI/CD Pipeline / Retag skipped Staging API Image (push) Failing after 12h34m51s
CI/CD Pipeline / PR Build API Image (push) Failing after 12h36m7s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 12h35m21s
CI/CD Pipeline / PR Build Web Image (push) Failing after 12h35m21s
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Failing after 12h34m6s
CI/CD Pipeline / Retag skipped Staging Web Image (push) Failing after 12h34m6s
CI/CD Pipeline / CI Gate (push) Failing after 12h20m24s
CI/CD Pipeline / Build Production Web Image (push) Failing after 12h24m22s
CI/CD Pipeline / Canary Release to Production (push) Failing after 12h24m20s
CI/CD Pipeline / Deploy Production (push) Failing after 12h24m20s
CI/CD Pipeline / Build Production API Image (push) Failing after 12h24m22s
CI/CD Pipeline / Frontend Lint (push) Failing after 12h35m22s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 12h35m53s
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
"""AI数字人渲染 积分扣点单元测试 (#1895 P2 step 2.6)"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
import packages.middleware.points_gate as _pg_module
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _enable(monkeypatch):
|
|
monkeypatch.setattr(_pg_module, "_points_gate_enabled", lambda: True)
|
|
yield
|
|
|
|
|
|
class TestAiAvatarRenderPoints:
|
|
def test_ai_digital_human_per_unit(self):
|
|
from packages.domain.points_rules import calculate_points_cost
|
|
|
|
cost = calculate_points_cost("ai_digital_human", is_member=False, duration_minutes=1)
|
|
assert cost >= 15
|
|
|
|
def test_decorator_attached(self):
|
|
from app.api.routes.ai_avatar_render import create_render_job
|
|
|
|
assert hasattr(create_render_job, "__wrapped__"), "missing @points_gate"
|
|
|
|
def test_insufficient_raises_402(self):
|
|
from app.api.routes.ai_avatar_render import create_render_job
|
|
from app.schemas.ai_avatar_render import CreateAiAvatarRenderRequest
|
|
from fastapi import HTTPException
|
|
|
|
db = MagicMock()
|
|
cu = MagicMock()
|
|
cu.user.id = "u1"
|
|
cu.user.is_member = False
|
|
cu.user.member_type = None
|
|
svc = MagicMock()
|
|
body = CreateAiAvatarRenderRequest(lipsync_job_id="lip1")
|
|
with patch("packages.domain.points_service.PointsService") as MS:
|
|
msvc = MagicMock()
|
|
msvc.deduct_points.return_value = {"success": False, "balance": 0}
|
|
MS.return_value = msvc
|
|
with pytest.raises(HTTPException) as ei:
|
|
create_render_job(body=body, current_user=cu, svc=svc, db=db)
|
|
assert ei.value.status_code == 402
|