fix FastAPI模型FFMPEGSubtitleOverlayRequest解析后没有返回Self以及可选参数没有给default值

This commit is contained in:
shuohigh@gmail.com
2025-06-24 13:53:40 +08:00
parent d37da25a82
commit 39044f22dc
5 changed files with 26 additions and 19 deletions

View File

@@ -3,6 +3,7 @@ import unittest
import httpx
from loguru import logger
from BowongModalFunctions.models.web_model import FFMPEGSubtitleOverlayRequest
class PydanticModelTestCase(unittest.TestCase):
@@ -25,6 +26,14 @@ class PydanticModelTestCase(unittest.TestCase):
logger.info(f"Login response: {session_json}")
self.assertEqual(True, True)
def test_subtitle_apply(self):
subtitle_apply_input = """
{\"media\": \"s3://ap-northeast-2/modal-media-cache/test/bgm_nosie_reduce/outputs/fc-01JYG6NVQ1AEJMARECGN8FXDYH/output.mp4\",\n \"subtitle\": \"s3://ap-northeast-2/modal-media-cache/upload/2d5e2674-2c03-4a83-a589-3dce96003470/1183fed3-770d-4ded-a314-ef47c37d84d7.ass\",\n \"fonts\": [\n \"s3://ap-northeast-2/modal-media-cache/upload/test/fonts/荆南俊俊体.ttf\"\n ]}
"""
request = FFMPEGSubtitleOverlayRequest.model_validate_json(subtitle_apply_input)
logger.info(f"request = {request.model_dump_json(indent=2, exclude_none=True)}")
if __name__ == '__main__':
unittest.main()