83 lines
2.0 KiB
Python
83 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
完全独立的模型测试
|
|
"""
|
|
|
|
from dataclasses import dataclass, field
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
from typing import List, Optional, Dict, Any
|
|
from pathlib import Path
|
|
|
|
# 定义枚举
|
|
class PlatformType(Enum):
|
|
XIAOHONGSHU = "xiaohongshu"
|
|
DOUYIN = "douyin"
|
|
|
|
# 定义基础内容类
|
|
@dataclass
|
|
class BaseContent:
|
|
title: str
|
|
description: str
|
|
tags: List[str] = field(default_factory=list)
|
|
visibility: str = "public"
|
|
|
|
# 定义图文笔记
|
|
@dataclass
|
|
class ImageNote(BaseContent):
|
|
images: List[str] = field(default_factory=list)
|
|
cover_image: Optional[str] = None
|
|
|
|
# 定义视频内容
|
|
@dataclass
|
|
class VideoContent(BaseContent):
|
|
video_path: str
|
|
cover_image: Optional[str] = None
|
|
|
|
# 定义账号信息
|
|
@dataclass
|
|
class AccountInfo:
|
|
platform: PlatformType
|
|
username: str
|
|
cookie_file: str
|
|
is_active: bool = True
|
|
|
|
def test_models():
|
|
print('🚀 开始独立模型测试')
|
|
print('=' * 50)
|
|
|
|
# 测试枚举
|
|
print(f'✅ 平台枚举: {PlatformType.XIAOHONGSHU.value}')
|
|
|
|
# 测试图文笔记
|
|
note = ImageNote(
|
|
title="测试笔记标题",
|
|
description="测试笔记描述",
|
|
images=["img1.jpg", "img2.jpg"],
|
|
tags=["测试", "笔记"]
|
|
)
|
|
print(f'✅ 图文笔记: {note.title}, {len(note.images)}张图片')
|
|
|
|
# 测试视频内容
|
|
video = VideoContent(
|
|
title="测试视频标题",
|
|
description="测试视频描述",
|
|
video_path="test.mp4",
|
|
tags=["测试", "视频"]
|
|
)
|
|
print(f'✅ 视频内容: {video.title}, 路径: {video.video_path}')
|
|
|
|
# 测试账号信息
|
|
account = AccountInfo(
|
|
platform=PlatformType.XIAOHONGSHU,
|
|
username="test_user",
|
|
cookie_file="test_user.json"
|
|
)
|
|
print(f'✅ 账号信息: {account.platform.value}/{account.username}')
|
|
|
|
print('=' * 50)
|
|
print('🎉 独立模型测试成功!数据类设计正确!')
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
test_models() |