40 lines
1.8 KiB
Python
40 lines
1.8 KiB
Python
import base64
|
|
import unittest
|
|
|
|
import httpx
|
|
from loguru import logger
|
|
from BowongModalFunctions.models.requests.models import FFMPEGSubtitleOverlayRequest
|
|
|
|
|
|
class PydanticModelTestCase(unittest.TestCase):
|
|
|
|
def test_nakama_login(self):
|
|
nakama_endpoint = 'http://43.143.58.201:7350'
|
|
email = "ybj.yege@gmail.com"
|
|
password = "Bowong7777"
|
|
basic_auth_str = base64.b64encode(f"{email}:{password}".encode('utf8')).decode('utf8')
|
|
logger.info(basic_auth_str)
|
|
with httpx.Client() as client:
|
|
login_response = client.post(url=f"{nakama_endpoint}/v2/account/authenticate/email?create=false",
|
|
headers={
|
|
"Authorization": f"Basic {basic_auth_str}",
|
|
},
|
|
json={"email": "ybj.yege@gmail.com", "password": "Bowong7777"}
|
|
)
|
|
login_response.raise_for_status()
|
|
session_json = login_response.json()
|
|
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()
|