72 lines
2.0 KiB
Python
72 lines
2.0 KiB
Python
import uuid
|
|
from datetime import datetime, timezone
|
|
|
|
import pytest_asyncio
|
|
|
|
from app.models.content import Content
|
|
from app.models.diagnosis_record import DiagnosisRecord
|
|
from app.models.attribution_record import AttributionRecord
|
|
|
|
from .auth import _to_uuid
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def test_content(async_session, test_brand):
|
|
content = Content(
|
|
id=uuid.uuid4(),
|
|
brand_id=_to_uuid(test_brand.id),
|
|
title="测试内容标题",
|
|
body="这是一段测试内容,用于验证内容管线功能。",
|
|
platform="wechat",
|
|
status="draft",
|
|
content_type="article",
|
|
)
|
|
async_session.add(content)
|
|
await async_session.commit()
|
|
await async_session.refresh(content)
|
|
return content
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def test_diagnosis_record(async_session, test_brand):
|
|
record = DiagnosisRecord(
|
|
id=uuid.uuid4(),
|
|
brand_id=_to_uuid(test_brand.id),
|
|
overall_score=45.0,
|
|
mention_rate=30.0,
|
|
recommendation_rank=50.0,
|
|
sentiment_score=60.0,
|
|
citation_quality=40.0,
|
|
competitive_position=35.0,
|
|
status="completed",
|
|
)
|
|
async_session.add(record)
|
|
await async_session.commit()
|
|
await async_session.refresh(record)
|
|
return record
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def test_attribution_record(async_session, test_brand, test_diagnosis_record):
|
|
record = AttributionRecord(
|
|
id=uuid.uuid4(),
|
|
brand_id=_to_uuid(test_brand.id),
|
|
diagnosis_id=str(test_diagnosis_record.id),
|
|
attribution_window_days=28,
|
|
before_scores={
|
|
"mention_rate": 30.0,
|
|
"recommendation_rank": 50.0,
|
|
"sentiment_score": 60.0,
|
|
"citation_quality": 40.0,
|
|
"competitive_position": 35.0,
|
|
},
|
|
after_scores=None,
|
|
status="tracking",
|
|
start_at=datetime.now(timezone.utc),
|
|
window_end_at=datetime(2026, 6, 30, tzinfo=timezone.utc),
|
|
)
|
|
async_session.add(record)
|
|
await async_session.commit()
|
|
await async_session.refresh(record)
|
|
return record
|