mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 04:09:06 +00:00
fix: resolve session management issues in tests and WebSocket endpoints
- Add missing db_session parameter to test_pipeline_main_file.py tests - Fix WebSocket endpoint missing session dependency injection - Update test fixtures to pass session as first argument to pipeline.process() - Add required imports (Depends, AsyncSession, get_session) to transcripts_websocket.py Note: 2 WebRTC tests still failing due to known asyncio event loop issues with SQLAlchemy
This commit is contained in:
@@ -4,8 +4,10 @@ Transcripts websocket API
|
||||
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter, HTTPException, WebSocket, WebSocketDisconnect
|
||||
from fastapi import APIRouter, Depends, HTTPException, WebSocket, WebSocketDisconnect
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from reflector.db import get_session
|
||||
from reflector.db.transcripts import transcripts_controller
|
||||
from reflector.ws_manager import get_ws_manager
|
||||
|
||||
@@ -21,6 +23,7 @@ async def transcript_get_websocket_events(transcript_id: str):
|
||||
async def transcript_events_websocket(
|
||||
transcript_id: str,
|
||||
websocket: WebSocket,
|
||||
session: AsyncSession = Depends(get_session),
|
||||
# user: Annotated[Optional[auth.UserInfo], Depends(auth.current_user_optional)],
|
||||
):
|
||||
# user_id = user["sub"] if user else None
|
||||
|
||||
@@ -297,6 +297,7 @@ async def mock_summary_processor():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pipeline_main_file_process(
|
||||
db_session,
|
||||
tmpdir,
|
||||
mock_transcript_in_db,
|
||||
dummy_file_transcript,
|
||||
@@ -377,7 +378,7 @@ async def test_pipeline_main_file_process(
|
||||
mock_av.side_effect = [mock_container, mock_decode_container]
|
||||
|
||||
# Run the pipeline
|
||||
await pipeline.process(upload_path)
|
||||
await pipeline.process(db_session, upload_path)
|
||||
|
||||
# Verify audio extraction and writing
|
||||
assert mock_audio_file_writer.push.called
|
||||
@@ -422,6 +423,7 @@ async def test_pipeline_main_file_process(
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pipeline_main_file_with_video(
|
||||
db_session,
|
||||
tmpdir,
|
||||
mock_transcript_in_db,
|
||||
dummy_file_transcript,
|
||||
@@ -468,7 +470,7 @@ async def test_pipeline_main_file_with_video(
|
||||
mock_av.side_effect = [mock_container, mock_decode_container]
|
||||
|
||||
# Run the pipeline
|
||||
await pipeline.process(upload_path)
|
||||
await pipeline.process(db_session, upload_path)
|
||||
|
||||
# Verify audio extraction from video
|
||||
assert mock_audio_file_writer.push.called
|
||||
@@ -486,6 +488,7 @@ async def test_pipeline_main_file_with_video(
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pipeline_main_file_no_diarization(
|
||||
db_session,
|
||||
tmpdir,
|
||||
mock_transcript_in_db,
|
||||
dummy_file_transcript,
|
||||
@@ -533,7 +536,7 @@ async def test_pipeline_main_file_no_diarization(
|
||||
mock_av.side_effect = [mock_container, mock_decode_container]
|
||||
|
||||
# Run the pipeline
|
||||
await pipeline.process(upload_path)
|
||||
await pipeline.process(db_session, upload_path)
|
||||
|
||||
# Verify the pipeline completed without diarization
|
||||
assert mock_storage._put_file.called
|
||||
@@ -547,6 +550,7 @@ async def test_pipeline_main_file_no_diarization(
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_task_pipeline_file_process(
|
||||
db_session,
|
||||
tmpdir,
|
||||
mock_transcript_in_db,
|
||||
dummy_file_transcript,
|
||||
@@ -593,7 +597,7 @@ async def test_task_pipeline_file_process(
|
||||
from reflector.pipelines.main_file_pipeline import PipelineMainFile
|
||||
|
||||
pipeline = PipelineMainFile(transcript_id=mock_transcript_in_db.id)
|
||||
await pipeline.process(upload_path)
|
||||
await pipeline.process(db_session, upload_path)
|
||||
|
||||
# Verify the pipeline was executed through the task
|
||||
assert mock_audio_file_writer.push.called
|
||||
@@ -633,6 +637,7 @@ async def test_pipeline_file_process_no_transcript():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pipeline_file_process_no_audio_file(
|
||||
db_session,
|
||||
mock_transcript_in_db,
|
||||
):
|
||||
"""
|
||||
@@ -650,4 +655,4 @@ async def test_pipeline_file_process_no_audio_file(
|
||||
|
||||
# This should fail when trying to open the file with av
|
||||
with pytest.raises(Exception):
|
||||
await pipeline.process(non_existent_path)
|
||||
await pipeline.process(db_session, non_existent_path)
|
||||
|
||||
Reference in New Issue
Block a user