people-reading/backend/tests/test_reading_analyzers.py
2026-05-12 17:05:32 +08:00

37 lines
1.2 KiB
Python

import pytest
from app.services.analyzer_common import DISCLAIMER
from app.services.bazi_analyzer import BaziAnalyzer
from app.services.bazi_calculator import BaziCalculator
from app.services.face_analyzer import FaceAnalyzer
@pytest.mark.asyncio
async def test_face_mock_report_has_required_shape(monkeypatch):
monkeypatch.setattr("app.services.analyzer_common.settings.openai_api_key", None)
report = await FaceAnalyzer().analyze(b"fake", "image/jpeg")
assert report["quality_check"]["can_analyze"] is True
assert len(report["dimensions"]) >= 6
assert report["disclaimer"] == DISCLAIMER
@pytest.mark.asyncio
async def test_bazi_mock_report_has_required_shape(monkeypatch):
monkeypatch.setattr("app.services.analyzer_common.settings.openai_api_key", None)
chart = BaziCalculator().calculate(
{
"calendar_type": "solar",
"birth_date": "1992-08-18",
"birth_time": "09:30",
"time_unknown": False,
"birth_place": "广东深圳",
}
)
report = await BaziAnalyzer().analyze(chart)
assert chart["pillars"]["year"]
assert report["quality_check"]["can_analyze"] is True
assert len(report["dimensions"]) >= 6
assert report["disclaimer"] == DISCLAIMER