Skip to content

Commit 92af830

Browse files
Fix test_open_project_more_than_limitation_of_max_studies_open_per_user by adding websocket connections
- Add _connect_websocket calls before _open_project calls - Convert status codes to HTTPStatus enum values for type compatibility - Follows the same pattern as other successful tests in the file
1 parent 8ba5ce7 commit 92af830

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

services/web/server/tests/unit/with_dbs/02/test_projects_states_handlers.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ async def test_open_project_more_than_limitation_of_max_studies_open_per_user(
848848
client: TestClient,
849849
logged_user,
850850
client_session_id_factory: Callable,
851+
socketio_client_factory: Callable,
851852
user_project: ProjectDict,
852853
shared_project: ProjectDict,
853854
expected: ExpectedResponse,
@@ -857,19 +858,35 @@ async def test_open_project_more_than_limitation_of_max_studies_open_per_user(
857858
mocked_notifications_plugin: dict[str, mock.Mock],
858859
):
859860
client_id_1 = client_session_id_factory()
861+
await _connect_websocket(
862+
socketio_client_factory,
863+
user_role != UserRole.ANONYMOUS,
864+
client,
865+
client_id_1,
866+
)
860867
await _open_project(
861868
client,
862869
client_id_1,
863870
user_project,
864-
expected.ok if user_role != UserRole.GUEST else status.HTTP_200_OK,
871+
HTTPStatus(expected.ok) if user_role != UserRole.GUEST else HTTPStatus.OK,
865872
)
866873

867874
client_id_2 = client_session_id_factory()
875+
await _connect_websocket(
876+
socketio_client_factory,
877+
user_role != UserRole.ANONYMOUS,
878+
client,
879+
client_id_2,
880+
)
868881
await _open_project(
869882
client,
870883
client_id_2,
871884
shared_project,
872-
expected.conflict if user_role != UserRole.GUEST else status.HTTP_409_CONFLICT,
885+
(
886+
HTTPStatus(expected.conflict)
887+
if user_role != UserRole.GUEST
888+
else HTTPStatus.CONFLICT
889+
),
873890
)
874891

875892

0 commit comments

Comments
 (0)