d706a76205
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
29 lines
847 B
Python
29 lines
847 B
Python
"""AI封面生成 积分扣点单元测试 (#1895 P2 step 2.7)"""
|
|
|
|
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 TestGenerationCoverPoints:
|
|
def test_ai_cover_cost(self):
|
|
from packages.domain.points_rules import calculate_points_cost
|
|
|
|
assert calculate_points_cost("ai_cover", is_member=False) == 2
|
|
assert calculate_points_cost("ai_cover", is_member=True, member_type="yearly") >= 0
|
|
|
|
def test_decorator_attached(self):
|
|
from app.api.routes.generation_cover import generate_cover
|
|
|
|
assert hasattr(generate_cover, "__wrapped__"), "missing @points_gate"
|