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:
2025-09-25 12:52:30 -06:00
parent 9b3da4b2c8
commit 8fcfac80fa
2 changed files with 14 additions and 6 deletions

View File

@@ -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)