Merge pull request #335 from Monadical-SAS/sara/UI-improvements

Sara/UI improvements & fix transcript deletion
This commit is contained in:
2024-05-28 12:28:50 +02:00
committed by GitHub
12 changed files with 431 additions and 102 deletions

View File

@@ -1,4 +1,6 @@
import json
import os
import shutil
from contextlib import asynccontextmanager
from datetime import datetime
from pathlib import Path
@@ -188,7 +190,8 @@ class Transcript(BaseModel):
return [participant.model_dump(mode=mode) for participant in self.participants]
def unlink(self):
self.data_path.unlink(missing_ok=True)
if os.path.exists(self.data_path) and os.path.isdir(self.data_path):
shutil.rmtree(self.data_path)
@property
def data_path(self):

View File

@@ -118,3 +118,16 @@ async def test_transcript_audio_download_range_with_seek(
assert response.status_code == 206
assert response.headers["content-type"] == content_type
assert response.headers["content-range"].startswith("bytes 100-")
@pytest.mark.asyncio
async def test_transcript_delete_with_audio(fake_transcript):
from reflector.app import app
ac = AsyncClient(app=app, base_url="http://test/v1")
response = await ac.delete(f"/transcripts/{fake_transcript.id}")
assert response.status_code == 200
assert response.json()["status"] == "ok"
response = await ac.get(f"/transcripts/{fake_transcript.id}")
assert response.status_code == 404