Skip to content

Commit a54c876

Browse files
committed
fix tests
1 parent ad6e4d6 commit a54c876

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

services/web/server/src/simcore_service_webserver/projects/_projects_db.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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

173173
async def patch_project(

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
]

0 commit comments

Comments
 (0)