mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 04:09:06 +00:00
fix: add missing session parameters to controller method calls
- Add db_session parameter to all RoomController.add() and update() calls in test_room_ics_api.py - Fix TranscriptController.upsert_topic() calls to include session parameter in conftest.py fixture - Fix TranscriptController.upsert_participant() and delete_participant() calls to include session parameter in API views - Remove invalid setup_database fixture references, use pytest-async-sqlalchemy's database fixture instead - Update CalendarEventController.upsert() calls to include session parameter These changes ensure all controller methods receive the required session parameter as part of the SQLAlchemy 2.0 migration pattern where sessions are explicitly managed.
This commit is contained in:
@@ -77,7 +77,7 @@ async def transcript_add_participant(
|
||||
)
|
||||
|
||||
obj = await transcripts_controller.upsert_participant(
|
||||
transcript, TranscriptParticipant(**participant.dict())
|
||||
session, transcript, TranscriptParticipant(**participant.dict())
|
||||
)
|
||||
return Participant.model_validate(obj)
|
||||
|
||||
@@ -136,7 +136,7 @@ async def transcript_update_participant(
|
||||
fields = participant.dict(exclude_unset=True)
|
||||
obj = obj.copy(update=fields)
|
||||
|
||||
await transcripts_controller.upsert_participant(transcript, obj)
|
||||
await transcripts_controller.upsert_participant(session, transcript, obj)
|
||||
return Participant.model_validate(obj)
|
||||
|
||||
|
||||
@@ -151,5 +151,5 @@ async def transcript_delete_participant(
|
||||
transcript = await transcripts_controller.get_by_id_for_http(
|
||||
session, transcript_id, user_id=user_id
|
||||
)
|
||||
await transcripts_controller.delete_participant(transcript, participant_id)
|
||||
await transcripts_controller.delete_participant(session, transcript, participant_id)
|
||||
return DeletionStatus(status="ok")
|
||||
|
||||
@@ -82,7 +82,9 @@ async def transcript_assign_speaker(
|
||||
# if the participant does not have a speaker, create one
|
||||
if participant.speaker is None:
|
||||
participant.speaker = transcript.find_empty_speaker()
|
||||
await transcripts_controller.upsert_participant(transcript, participant)
|
||||
await transcripts_controller.upsert_participant(
|
||||
session, transcript, participant
|
||||
)
|
||||
|
||||
speaker = participant.speaker
|
||||
|
||||
|
||||
@@ -402,6 +402,7 @@ async def fake_transcript_with_topics(tmpdir, client, db_session):
|
||||
|
||||
# create some topics
|
||||
await transcripts_controller.upsert_topic(
|
||||
db_session,
|
||||
transcript,
|
||||
TranscriptTopic(
|
||||
title="Topic 1",
|
||||
@@ -415,6 +416,7 @@ async def fake_transcript_with_topics(tmpdir, client, db_session):
|
||||
),
|
||||
)
|
||||
await transcripts_controller.upsert_topic(
|
||||
db_session,
|
||||
transcript,
|
||||
TranscriptTopic(
|
||||
title="Topic 2",
|
||||
|
||||
@@ -89,9 +89,10 @@ async def test_update_room_ics_configuration(authenticated_client):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_trigger_ics_sync(authenticated_client):
|
||||
async def test_trigger_ics_sync(authenticated_client, db_session):
|
||||
client = authenticated_client
|
||||
room = await rooms_controller.add(
|
||||
db_session,
|
||||
name="sync-api-room",
|
||||
user_id="test-user",
|
||||
zulip_auto_post=False,
|
||||
@@ -133,8 +134,9 @@ async def test_trigger_ics_sync(authenticated_client):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_trigger_ics_sync_unauthorized(client):
|
||||
async def test_trigger_ics_sync_unauthorized(client, db_session):
|
||||
room = await rooms_controller.add(
|
||||
db_session,
|
||||
name="sync-unauth-room",
|
||||
user_id="owner-123",
|
||||
zulip_auto_post=False,
|
||||
@@ -155,9 +157,10 @@ async def test_trigger_ics_sync_unauthorized(client):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_trigger_ics_sync_not_configured(authenticated_client):
|
||||
async def test_trigger_ics_sync_not_configured(authenticated_client, db_session):
|
||||
client = authenticated_client
|
||||
room = await rooms_controller.add(
|
||||
db_session,
|
||||
name="sync-not-configured",
|
||||
user_id="test-user",
|
||||
zulip_auto_post=False,
|
||||
@@ -177,9 +180,10 @@ async def test_trigger_ics_sync_not_configured(authenticated_client):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_ics_status(authenticated_client):
|
||||
async def test_get_ics_status(authenticated_client, db_session):
|
||||
client = authenticated_client
|
||||
room = await rooms_controller.add(
|
||||
db_session,
|
||||
name="status-room",
|
||||
user_id="test-user",
|
||||
zulip_auto_post=False,
|
||||
@@ -197,6 +201,7 @@ async def test_get_ics_status(authenticated_client):
|
||||
|
||||
now = datetime.now(timezone.utc)
|
||||
await rooms_controller.update(
|
||||
db_session,
|
||||
room,
|
||||
{"ics_last_sync": now, "ics_last_etag": "test-etag"},
|
||||
)
|
||||
@@ -210,8 +215,9 @@ async def test_get_ics_status(authenticated_client):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_ics_status_unauthorized(client):
|
||||
async def test_get_ics_status_unauthorized(client, db_session):
|
||||
room = await rooms_controller.add(
|
||||
db_session,
|
||||
name="status-unauth",
|
||||
user_id="owner-456",
|
||||
zulip_auto_post=False,
|
||||
@@ -232,9 +238,10 @@ async def test_get_ics_status_unauthorized(client):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_room_meetings(authenticated_client):
|
||||
async def test_list_room_meetings(authenticated_client, db_session):
|
||||
client = authenticated_client
|
||||
room = await rooms_controller.add(
|
||||
db_session,
|
||||
name="meetings-room",
|
||||
user_id="test-user",
|
||||
zulip_auto_post=False,
|
||||
@@ -255,7 +262,7 @@ async def test_list_room_meetings(authenticated_client):
|
||||
start_time=now - timedelta(hours=2),
|
||||
end_time=now - timedelta(hours=1),
|
||||
)
|
||||
await calendar_events_controller.upsert(event1)
|
||||
await calendar_events_controller.upsert(db_session, event1)
|
||||
|
||||
event2 = CalendarEvent(
|
||||
room_id=room.id,
|
||||
@@ -266,7 +273,7 @@ async def test_list_room_meetings(authenticated_client):
|
||||
end_time=now + timedelta(hours=2),
|
||||
attendees=[{"email": "test@example.com"}],
|
||||
)
|
||||
await calendar_events_controller.upsert(event2)
|
||||
await calendar_events_controller.upsert(db_session, event2)
|
||||
|
||||
response = await client.get(f"/rooms/{room.name}/meetings")
|
||||
assert response.status_code == 200
|
||||
@@ -279,8 +286,9 @@ async def test_list_room_meetings(authenticated_client):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_room_meetings_non_owner(client):
|
||||
async def test_list_room_meetings_non_owner(client, db_session):
|
||||
room = await rooms_controller.add(
|
||||
db_session,
|
||||
name="meetings-privacy",
|
||||
user_id="owner-789",
|
||||
zulip_auto_post=False,
|
||||
@@ -302,7 +310,7 @@ async def test_list_room_meetings_non_owner(client):
|
||||
end_time=datetime.now(timezone.utc) + timedelta(hours=2),
|
||||
attendees=[{"email": "private@example.com"}],
|
||||
)
|
||||
await calendar_events_controller.upsert(event)
|
||||
await calendar_events_controller.upsert(db_session, event)
|
||||
|
||||
response = await client.get(f"/rooms/{room.name}/meetings")
|
||||
assert response.status_code == 200
|
||||
@@ -314,9 +322,10 @@ async def test_list_room_meetings_non_owner(client):
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_upcoming_meetings(authenticated_client):
|
||||
async def test_list_upcoming_meetings(authenticated_client, db_session):
|
||||
client = authenticated_client
|
||||
room = await rooms_controller.add(
|
||||
db_session,
|
||||
name="upcoming-room",
|
||||
user_id="test-user",
|
||||
zulip_auto_post=False,
|
||||
@@ -338,7 +347,7 @@ async def test_list_upcoming_meetings(authenticated_client):
|
||||
start_time=now - timedelta(hours=1),
|
||||
end_time=now - timedelta(minutes=30),
|
||||
)
|
||||
await calendar_events_controller.upsert(past_event)
|
||||
await calendar_events_controller.upsert(db_session, past_event)
|
||||
|
||||
soon_event = CalendarEvent(
|
||||
room_id=room.id,
|
||||
@@ -347,7 +356,7 @@ async def test_list_upcoming_meetings(authenticated_client):
|
||||
start_time=now + timedelta(minutes=15),
|
||||
end_time=now + timedelta(minutes=45),
|
||||
)
|
||||
await calendar_events_controller.upsert(soon_event)
|
||||
await calendar_events_controller.upsert(db_session, soon_event)
|
||||
|
||||
later_event = CalendarEvent(
|
||||
room_id=room.id,
|
||||
@@ -356,7 +365,7 @@ async def test_list_upcoming_meetings(authenticated_client):
|
||||
start_time=now + timedelta(hours=2),
|
||||
end_time=now + timedelta(hours=3),
|
||||
)
|
||||
await calendar_events_controller.upsert(later_event)
|
||||
await calendar_events_controller.upsert(db_session, later_event)
|
||||
|
||||
response = await client.get(f"/rooms/{room.name}/meetings/upcoming")
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -23,7 +23,6 @@ async def client(app_lifespan):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("setup_database")
|
||||
@pytest.mark.usefixtures("celery_session_app")
|
||||
@pytest.mark.usefixtures("celery_session_worker")
|
||||
@pytest.mark.asyncio
|
||||
|
||||
@@ -49,7 +49,7 @@ class ThreadedUvicorn:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def appserver(tmpdir, setup_database, celery_session_app, celery_session_worker):
|
||||
def appserver(tmpdir, database, celery_session_app, celery_session_worker):
|
||||
import threading
|
||||
|
||||
from reflector.app import app
|
||||
@@ -111,7 +111,6 @@ def appserver(tmpdir, setup_database, celery_session_app, celery_session_worker)
|
||||
settings.DATA_DIR = DATA_DIR
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("setup_database")
|
||||
@pytest.mark.usefixtures("celery_session_app")
|
||||
@pytest.mark.usefixtures("celery_session_worker")
|
||||
@pytest.mark.asyncio
|
||||
@@ -276,7 +275,6 @@ async def test_transcript_rtc_and_websocket(
|
||||
assert audio_resp.headers["Content-Type"] == "audio/mpeg"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("setup_database")
|
||||
@pytest.mark.usefixtures("celery_session_app")
|
||||
@pytest.mark.usefixtures("celery_session_worker")
|
||||
@pytest.mark.asyncio
|
||||
|
||||
@@ -4,7 +4,6 @@ import time
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("setup_database")
|
||||
@pytest.mark.usefixtures("celery_session_app")
|
||||
@pytest.mark.usefixtures("celery_session_worker")
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user