mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
* docs: transient docs * chore: cleanup * webvtt WIP * webvtt field * chore: webvtt tests comments * chore: remove useless tests * feat: search TASK.md * feat: full text search by title/webvtt * chore: search api task * feat: search api * feat: search API * chore: rm task md * chore: roll back unnecessary validators * chore: pr review WIP * chore: pr review WIP * chore: pr review * chore: top imports * feat: better lint + ci * feat: better lint + ci * feat: better lint + ci * feat: better lint + ci * chore: lint * chore: lint * fix: db datetime definitions * fix: flush() params * fix: update transcript mutability expectation / test * fix: update transcript mutability expectation / test * chore: auto review * chore: new controller extraction * chore: new controller extraction * chore: cleanup * chore: review WIP * chore: pr WIP * chore: remove ci lint * chore: openapi regeneration * chore: openapi regeneration * chore: postgres test doc * fix: .dockerignore for arm binaries * fix: .dockerignore for arm binaries * fix: cap test loops * fix: cap test loops * fix: cap test loops * fix: get_transcript_topics * chore: remove flow.md docs and claude guidance * chore: remove claude.md db doc * chore: remove claude.md db doc * chore: remove claude.md db doc * chore: remove claude.md db doc
87 lines
2.7 KiB
Python
87 lines
2.7 KiB
Python
import asyncio
|
|
import time
|
|
|
|
import pytest
|
|
from httpx import AsyncClient
|
|
|
|
|
|
@pytest.mark.usefixtures("setup_database")
|
|
@pytest.mark.usefixtures("celery_session_app")
|
|
@pytest.mark.usefixtures("celery_session_worker")
|
|
@pytest.mark.asyncio
|
|
async def test_transcript_process(
|
|
tmpdir,
|
|
dummy_llm,
|
|
dummy_processors,
|
|
dummy_diarization,
|
|
dummy_storage,
|
|
):
|
|
from reflector.app import app
|
|
|
|
ac = AsyncClient(app=app, base_url="http://test/v1")
|
|
|
|
# create a transcript
|
|
response = await ac.post("/transcripts", json={"name": "test"})
|
|
assert response.status_code == 200
|
|
assert response.json()["status"] == "idle"
|
|
tid = response.json()["id"]
|
|
|
|
# upload mp3
|
|
response = await ac.post(
|
|
f"/transcripts/{tid}/record/upload?chunk_number=0&total_chunks=1",
|
|
files={
|
|
"chunk": (
|
|
"test_short.wav",
|
|
open("tests/records/test_short.wav", "rb"),
|
|
"audio/mpeg",
|
|
),
|
|
},
|
|
)
|
|
assert response.status_code == 200
|
|
assert response.json()["status"] == "ok"
|
|
|
|
# wait for processing to finish (max 10 minutes)
|
|
timeout_seconds = 600 # 10 minutes
|
|
start_time = time.monotonic()
|
|
while (time.monotonic() - start_time) < timeout_seconds:
|
|
# fetch the transcript and check if it is ended
|
|
resp = await ac.get(f"/transcripts/{tid}")
|
|
assert resp.status_code == 200
|
|
if resp.json()["status"] in ("ended", "error"):
|
|
break
|
|
await asyncio.sleep(1)
|
|
else:
|
|
pytest.fail(f"Initial processing timed out after {timeout_seconds} seconds")
|
|
|
|
# restart the processing
|
|
response = await ac.post(
|
|
f"/transcripts/{tid}/process",
|
|
)
|
|
assert response.status_code == 200
|
|
assert response.json()["status"] == "ok"
|
|
|
|
# wait for processing to finish (max 10 minutes)
|
|
timeout_seconds = 600 # 10 minutes
|
|
start_time = time.monotonic()
|
|
while (time.monotonic() - start_time) < timeout_seconds:
|
|
# fetch the transcript and check if it is ended
|
|
resp = await ac.get(f"/transcripts/{tid}")
|
|
assert resp.status_code == 200
|
|
if resp.json()["status"] in ("ended", "error"):
|
|
break
|
|
await asyncio.sleep(1)
|
|
else:
|
|
pytest.fail(f"Restart processing timed out after {timeout_seconds} seconds")
|
|
|
|
# check the transcript is ended
|
|
transcript = resp.json()
|
|
assert transcript["status"] == "ended"
|
|
assert transcript["short_summary"] == "LLM SHORT SUMMARY"
|
|
assert transcript["title"] == "Llm Title"
|
|
|
|
# check topics and transcript
|
|
response = await ac.get(f"/transcripts/{tid}/topics")
|
|
assert response.status_code == 200
|
|
assert len(response.json()) == 1
|
|
assert "want to share" in response.json()[0]["transcript"]
|