feature: create multitasking
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
"""
|
||||
Tests for captions endpoints.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
|
||||
class TestGetVideoEndpoint:
|
||||
"""Tests for POST /api/captions/get_video/."""
|
||||
|
||||
async def test_get_video_success(self, auth_client: AsyncClient):
|
||||
"""Test caption burn-in endpoint returns result."""
|
||||
mock_transcription = {
|
||||
"segments": [
|
||||
{
|
||||
"text": "Hello world",
|
||||
"semantic_tags": [],
|
||||
"structure_tags": [],
|
||||
"time": {"start": 0.0, "end": 2.0},
|
||||
"lines": [
|
||||
{
|
||||
"text": "Hello world",
|
||||
"semantic_tags": [],
|
||||
"structure_tags": [],
|
||||
"time": {"start": 0.0, "end": 2.0},
|
||||
"words": [],
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
with patch(
|
||||
"cpv3.modules.captions.router.generate_captions",
|
||||
new_callable=AsyncMock,
|
||||
return_value="uploads/output/captioned_video.mp4",
|
||||
):
|
||||
response = await auth_client.post(
|
||||
"/api/captions/get_video/",
|
||||
json={
|
||||
"folder": "output",
|
||||
"video_s3_path": "uploads/source_video.mp4",
|
||||
"transcription": mock_transcription,
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert "result" in data
|
||||
assert data["result"] == "uploads/output/captioned_video.mp4"
|
||||
|
||||
async def test_get_video_unauthenticated(self, async_client: AsyncClient):
|
||||
"""Test caption burn-in without auth returns 401."""
|
||||
response = await async_client.post(
|
||||
"/api/captions/get_video/",
|
||||
json={
|
||||
"folder": "output",
|
||||
"video_s3_path": "test.mp4",
|
||||
"transcription": {"segments": []},
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 401
|
||||
|
||||
async def test_get_video_missing_fields(self, auth_client: AsyncClient):
|
||||
"""Test caption burn-in with missing required fields returns 422."""
|
||||
response = await auth_client.post(
|
||||
"/api/captions/get_video/",
|
||||
json={
|
||||
"folder": "output",
|
||||
# missing video_s3_path and transcription
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 422
|
||||
Reference in New Issue
Block a user