social_media_auto_publisher/test_models_direct.py
2025-11-12 00:28:07 +08:00

62 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
直接模型测试绕过__init__.py
"""
import sys
import os
# 直接导入绕过__init__.py
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'core'))
from models_fixed import PlatformType, ImageNote, VideoContent, AccountInfo
def test_models():
print('✅ 修复后的模型导入成功!')
print(f'✅ 平台类型: {PlatformType.XIAOHONGSHU}')
print(f'✅ 平台类型: {PlatformType.DOUYIN}')
# 测试创建实例
note = ImageNote(
title='测试笔记',
description='测试描述',
images=['test1.jpg', 'test2.jpg'],
tags=['测试', '笔记']
)
print(f'✅ 图文笔记创建成功: {note.title}, {len(note.images)}张图片')
print(f' 标签: {note.tags}')
print(f' 可见性: {note.visibility}')
video = VideoContent(
title='测试视频',
description='测试视频描述',
video_path='test.mp4',
tags=['测试', '视频']
)
print(f'✅ 视频内容创建成功: {video.title}')
print(f' 视频路径: {video.video_path}')
print(f' 标签: {video.tags}')
# 测试账号信息
account = AccountInfo(
platform=PlatformType.XIAOHONGSHU,
username='test_user',
cookie_file='test_user.json'
)
print(f'✅ 账号信息创建成功: {account.platform.value}/{account.username}')
print(f' Cookie文件: {account.cookie_file}')
# 测试内容验证
print(f'✅ 图文笔记标题清理: "{note.title}"')
print(f'✅ 视频内容描述清理: "{video.description}"')
return True
if __name__ == "__main__":
try:
test_models()
print('🎉 所有模型测试通过!数据类问题已修复!')
except Exception as e:
print(f'❌ 测试失败: {e}')
import traceback
traceback.print_exc()