File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed
src/simcore_service_webserver/projects Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -123,12 +123,12 @@ async def get_trashed_by_primary_gid(
123123 projects_uuid : ProjectID ,
124124) -> GroupID | None :
125125 query = _select_trashed_by_primary_gid_query ().where (
126- projects .c .uuid == projects_uuid
126+ projects .c .uuid == f" { projects_uuid } "
127127 )
128128
129129 async with pass_or_acquire_connection (get_asyncpg_engine (app ), connection ) as conn :
130130 result = await conn .execute (query )
131- row = result .first ()
131+ row = result .one_or_none ()
132132 return row .trashed_by_primary_gid if row else None
133133
134134
@@ -167,7 +167,7 @@ async def batch_get_trashed_by_primary_gid(
167167 result = await conn .stream (query )
168168 rows = {row .uuid : row .trashed_by_primary_gid async for row in result }
169169
170- return [rows .get (uuid ) for uuid in projects_uuids_str ]
170+ return [rows .get (project_uuid ) for project_uuid in projects_uuids_str ]
171171
172172
173173async def patch_project (
Original file line number Diff line number Diff line change @@ -162,3 +162,31 @@ async def test_get_trashed_by_primary_gid(
162162 )
163163
164164 assert trashed_by_primary_gid == logged_user ["primary_gid" ]
165+
166+
167+ async def test_batch_get_trashed_by_primary_gid (
168+ client : TestClient ,
169+ logged_user : UserInfoDict ,
170+ trashed_project : ProjectDBGet ,
171+ ):
172+ assert client .app
173+
174+ non_existent_project_uuid = UUID ("00000000-0000-0000-0000-000000000000" )
175+
176+ # Batch get trashed by primary gid
177+ trashed_by_primary_gid = (
178+ await projects_service_repository .batch_get_trashed_by_primary_gid (
179+ client .app ,
180+ projects_uuids = [
181+ trashed_project .uuid ,
182+ non_existent_project_uuid , # invalid
183+ trashed_project .uuid , # repeated
184+ ],
185+ )
186+ )
187+
188+ assert trashed_by_primary_gid == [
189+ logged_user ["primary_gid" ],
190+ None ,
191+ logged_user ["primary_gid" ],
192+ ]
You can’t perform that action at this time.
0 commit comments