1515import sqlalchemy as sa
1616from aiohttp .test_utils import TestClient
1717from faker import Faker
18+ from models_library .api_schemas_webserver .socketio import SocketIORoomStr
1819from models_library .progress_bar import ProgressReport
1920from models_library .projects import ProjectID
2021from models_library .projects_nodes_io import NodeID
5455from simcore_service_webserver .rest .plugin import setup_rest
5556from simcore_service_webserver .security .plugin import setup_security
5657from simcore_service_webserver .session .plugin import setup_session
58+ from simcore_service_webserver .socketio ._utils import get_socket_server
5759from simcore_service_webserver .socketio .messages import (
5860 SOCKET_IO_EVENT ,
5961 SOCKET_IO_LOG_EVENT ,
7375 "redis" ,
7476]
7577
76- pytest_simcore_ops_services_selection = []
78+ pytest_simcore_ops_services_selection = ["redis-commander" ]
7779
7880_STABLE_DELAY_S = 2
7981
@@ -113,7 +115,7 @@ async def _assert_handler_called_with_json(
113115 handler : mock .Mock , expected_call : dict [str , Any ]
114116) -> None :
115117 async for attempt in AsyncRetrying (
116- wait = wait_fixed (0.1 ),
118+ wait = wait_fixed (0.2 ),
117119 stop = stop_after_delay (10 ),
118120 retry = retry_if_exception_type (AssertionError ),
119121 reraise = True ,
@@ -186,13 +188,13 @@ def user_project_id(user_project: ProjectDict) -> ProjectID:
186188
187189@pytest .fixture
188190def user_id (logged_user : UserInfoDict ) -> UserID :
189- return UserID ( logged_user ["id" ])
191+ return logged_user ["id" ]
190192
191193
192194@pytest .fixture
193195def sender_user_id (user_id : UserID , sender_same_user_id : bool , faker : Faker ) -> UserID :
194196 if sender_same_user_id is False :
195- return UserID ( faker .pyint (min_value = user_id + 1 ) )
197+ return faker .pyint (min_value = user_id + 1 )
196198 return user_id
197199
198200
@@ -333,8 +335,10 @@ async def test_progress_non_computational_workflow(
333335
334336 """
335337 socket_io_conn , * _ = await create_socketio_connection (None , client )
338+ # the project must be opened here
336339
337340 mock_progress_handler = mocker .MagicMock ()
341+
338342 socket_io_conn .on (
339343 WebSocketNodeProgress .get_event_type (), handler = mock_progress_handler
340344 )
@@ -343,6 +347,10 @@ async def test_progress_non_computational_workflow(
343347 assert client .app
344348 await project_logs .subscribe (client .app , user_project_id )
345349
350+ # this simulates the user openning the project
351+ await get_socket_server (client .app ).enter_room (
352+ socket_io_conn .get_sid (), SocketIORoomStr .from_project_id (user_project_id )
353+ )
346354 progress_message = ProgressRabbitMessageNode (
347355 user_id = sender_user_id ,
348356 project_id = user_project_id ,
@@ -352,7 +360,7 @@ async def test_progress_non_computational_workflow(
352360 )
353361 await rabbitmq_publisher .publish (progress_message .channel_name , progress_message )
354362
355- call_expected = sender_same_user_id and subscribe_to_logs
363+ call_expected = subscribe_to_logs
356364 if call_expected :
357365 expected_call = WebSocketNodeProgress .from_rabbit_message (
358366 progress_message
@@ -399,6 +407,10 @@ async def test_progress_computational_workflow(
399407 if subscribe_to_logs :
400408 assert client .app
401409 await project_logs .subscribe (client .app , user_project_id )
410+ # this simulates the user openning the project
411+ await get_socket_server (client .app ).enter_room (
412+ socket_io_conn .get_sid (), SocketIORoomStr .from_project_id (user_project_id )
413+ )
402414 progress_message = ProgressRabbitMessageNode (
403415 user_id = sender_user_id ,
404416 project_id = user_project_id ,
0 commit comments