Skip to content

Commit 1340862

Browse files
committed
fixes bug introduced in workspaces
1 parent 0a7b242 commit 1340862

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

services/web/server/src/simcore_service_webserver/workspaces/_workspaces_repository.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ async def get_workspace_for_user(
191191
) -> UserWorkspaceWithAccessRights:
192192
select_query = _create_base_select_query(
193193
caller_user_id=user_id, product_name=product_name
194-
)
194+
).where(workspaces.c.workspace_id == workspace_id)
195195

196196
async with pass_or_acquire_connection(get_asyncpg_engine(app), connection) as conn:
197-
result = await conn.stream(select_query)
198-
row = await result.first()
197+
result = await conn.execute(select_query)
198+
row = result.one_or_none()
199199
if row is None:
200200
raise WorkspaceAccessForbiddenError(
201201
reason=f"User {user_id} does not have access to the workspace {workspace_id}. Or workspace does not exist.",

services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces__folders_and_projects_crud.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ async def test_listing_folders_and_projects_in_workspace__multiple_workspaces_cr
416416
)
417417
added_workspace_1, _ = await assert_status(resp, status.HTTP_201_CREATED)
418418

419-
# Create project in workspace
419+
# Create PROJECT in workspace
420420
project_data = deepcopy(fake_project)
421421
project_data["workspace_id"] = f"{added_workspace_1['workspaceId']}"
422422
await create_project(
@@ -426,7 +426,7 @@ async def test_listing_folders_and_projects_in_workspace__multiple_workspaces_cr
426426
product_name="osparc",
427427
)
428428

429-
# Create folder in workspace
429+
# Create FOLDER in workspace
430430
url = client.app.router["create_folder"].url_for()
431431
resp = await client.post(
432432
f"{url}",
@@ -437,7 +437,7 @@ async def test_listing_folders_and_projects_in_workspace__multiple_workspaces_cr
437437
)
438438
first_folder, _ = await assert_status(resp, status.HTTP_201_CREATED)
439439

440-
# create a new workspace
440+
# create a new WORKSPACE
441441
url = client.app.router["create_workspace"].url_for()
442442
resp = await client.post(
443443
f"{url}",
@@ -448,8 +448,9 @@ async def test_listing_folders_and_projects_in_workspace__multiple_workspaces_cr
448448
},
449449
)
450450
added_workspace_2, _ = await assert_status(resp, status.HTTP_201_CREATED)
451+
assert added_workspace_2["workspaceId"] != added_workspace_1["workspaceId"]
451452

452-
# Create project in workspace
453+
# Create PROJECT in workspace
453454
project_data = deepcopy(fake_project)
454455
project_data["workspace_id"] = f"{added_workspace_2['workspaceId']}"
455456
await create_project(
@@ -459,7 +460,7 @@ async def test_listing_folders_and_projects_in_workspace__multiple_workspaces_cr
459460
product_name="osparc",
460461
)
461462

462-
# Create folder in workspace
463+
# Create FOLDER in workspace
463464
url = client.app.router["create_folder"].url_for()
464465
resp = await client.post(
465466
f"{url}",
@@ -470,7 +471,7 @@ async def test_listing_folders_and_projects_in_workspace__multiple_workspaces_cr
470471
)
471472
first_folder, _ = await assert_status(resp, status.HTTP_201_CREATED)
472473

473-
# List projects in workspace 1
474+
# List PROJECTS in workspace 1
474475
url = (
475476
client.app.router["list_projects"]
476477
.url_for()
@@ -480,7 +481,7 @@ async def test_listing_folders_and_projects_in_workspace__multiple_workspaces_cr
480481
data, _ = await assert_status(resp, status.HTTP_200_OK)
481482
assert len(data) == 1
482483

483-
# List folders in workspace 1
484+
# List FOLDERS in workspace 1
484485
url = (
485486
client.app.router["list_folders"]
486487
.url_for()

0 commit comments

Comments
 (0)