Files
group_fqcd_jr/tests/unit/service/test_promotion_image_service.py
T

42 lines
1.2 KiB
Python

from pathlib import Path
import pytest
from app.service.promotion_image_service import PromotionImageService
def test_background_prompt_forbids_content_reconstruction() -> None:
prompt = PromotionImageService._build_prompt(
style_code="balanced_allocation",
background_theme="data_lines",
fund_type="混合型",
)
assert "不生成任何文字、数字、字母" in prompt
assert "Logo" in prompt
@pytest.mark.asyncio
async def test_disabled_image_service_returns_none(monkeypatch: pytest.MonkeyPatch) -> None:
class Settings:
promotion_image_enabled = False
promotion_image_base_url = "https://dashscope.aliyuncs.com"
promotion_image_model = "wan2.2-t2i-flash"
promotion_image_timeout_seconds = 90
promotion_image_poll_interval_seconds = 2
monkeypatch.setattr(
"app.service.promotion_image_service.get_settings",
lambda: Settings(),
)
service = PromotionImageService()
result = await service.generate_background(
output_path=Path("unused.png"),
style_code="balanced_allocation",
background_theme="data_lines",
fund_type="混合型",
)
assert result is None