@@ -365,3 +365,98 @@ async def test_workspaces_delete_folders(
365365 resp = await client .get (url )
366366 data , _ = await assert_status (resp , status .HTTP_200_OK )
367367 assert len (data ) == 0
368+
369+
370+ @pytest .mark .parametrize ("user_role,expected" , [(UserRole .USER , status .HTTP_200_OK )])
371+ async def test_listing_folders_and_projects_in_workspace__multiple_workspaces_created (
372+ client : TestClient ,
373+ logged_user : UserInfoDict ,
374+ user_project : ProjectDict ,
375+ expected : HTTPStatus ,
376+ mock_catalog_api_get_services_for_user_in_product : MockerFixture ,
377+ fake_project : ProjectDict ,
378+ workspaces_clean_db : None ,
379+ ):
380+ assert client .app
381+
382+ # create a new workspace
383+ url = client .app .router ["create_workspace" ].url_for ()
384+ resp = await client .post (
385+ url .path ,
386+ json = {
387+ "name" : "My first workspace" ,
388+ "description" : "Custom description" ,
389+ "thumbnail" : None ,
390+ },
391+ )
392+ added_workspace_1 , _ = await assert_status (resp , status .HTTP_201_CREATED )
393+
394+ # Create project in workspace
395+ project_data = deepcopy (fake_project )
396+ project_data ["workspace_id" ] = f"{ added_workspace_1 ['workspaceId' ]} "
397+ project = await create_project (
398+ client .app ,
399+ project_data ,
400+ user_id = logged_user ["id" ],
401+ product_name = "osparc" ,
402+ )
403+
404+ # Create folder in workspace
405+ url = client .app .router ["create_folder" ].url_for ()
406+ resp = await client .post (
407+ url .path ,
408+ json = {
409+ "name" : "Original user folder" ,
410+ "workspaceId" : f"{ added_workspace_1 ['workspaceId' ]} " ,
411+ },
412+ )
413+ first_folder , _ = await assert_status (resp , status .HTTP_201_CREATED )
414+
415+ # create a new workspace
416+ url = client .app .router ["create_workspace" ].url_for ()
417+ resp = await client .post (
418+ url .path ,
419+ json = {
420+ "name" : "My first workspace" ,
421+ "description" : "Custom description" ,
422+ "thumbnail" : None ,
423+ },
424+ )
425+ added_workspace_2 , _ = await assert_status (resp , status .HTTP_201_CREATED )
426+
427+ # Create project in workspace
428+ project_data = deepcopy (fake_project )
429+ project_data ["workspace_id" ] = f"{ added_workspace_2 ['workspaceId' ]} "
430+ project = await create_project (
431+ client .app ,
432+ project_data ,
433+ user_id = logged_user ["id" ],
434+ product_name = "osparc" ,
435+ )
436+
437+ # Create folder in workspace
438+ url = client .app .router ["create_folder" ].url_for ()
439+ resp = await client .post (
440+ url .path ,
441+ json = {
442+ "name" : "Original user folder" ,
443+ "workspaceId" : f"{ added_workspace_2 ['workspaceId' ]} " ,
444+ },
445+ )
446+ first_folder , _ = await assert_status (resp , status .HTTP_201_CREATED )
447+
448+ # List projects in workspace 1
449+ base_url = client .app .router ["list_projects" ].url_for ()
450+ url = base_url .with_query ({"workspace_id" : f"{ added_workspace_1 ['workspaceId' ]} " })
451+ resp = await client .get (url )
452+ data , _ = await assert_status (resp , status .HTTP_200_OK )
453+ assert len (data ) == 1
454+
455+ # List folders in workspace 1
456+ base_url = client .app .router ["list_folders" ].url_for ()
457+ url = base_url .with_query (
458+ {"workspace_id" : f"{ added_workspace_1 ['workspaceId' ]} " , "folder_id" : "null" }
459+ )
460+ resp = await client .get (url )
461+ data , _ = await assert_status (resp , status .HTTP_200_OK )
462+ assert len (data ) == 1
0 commit comments