test_video_item.py 814 B

1234567891011121314151617181920212223242526272829
  1. import asyncio
  2. import time
  3. from core.models.video_item import VideoItem # 你的 Pydantic 模型路径
  4. from pprint import pprint
  5. async def main():
  6. fake_video_data = {
  7. "user_id": "uid456",
  8. "user_name": "测试用户",
  9. "out_video_id": "out789",
  10. "out_user_id": "out_user",
  11. "video_url": "http://example.com/video.mp4",
  12. "cover_url": "http://example.com/cover.jpg",
  13. "video_title": " 测试 视频 标题!!!",
  14. "publish_time_stamp": int(time.time()) - 86400, # 昨天
  15. "strategy": "recommend",
  16. "platform": "test_platform"
  17. }
  18. item = VideoItem(**fake_video_data)
  19. result = await item.produce_item()
  20. print("✅ 校验通过的最终结构:")
  21. pprint(result)
  22. if __name__ == "__main__":
  23. asyncio.run(main())