Skip to content

Commit bb29577

Browse files
fix
1 parent 6ee0d4b commit bb29577

File tree

2 files changed

+36
-38
lines changed

2 files changed

+36
-38
lines changed

services/web/server/src/simcore_service_webserver/projects/_controller/projects_rest_schemas.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class ProjectFilters(Filters):
136136

137137
class ProjectsListExtraQueryParams(RequestParameters):
138138
project_type: Annotated[ProjectTypeAPI, Field(alias="type")] = ProjectTypeAPI.all
139-
template_type: Annotated[ProjectTemplateType | None, Field(...)] = None
139+
template_type: ProjectTemplateType | None = None
140140
show_hidden: Annotated[
141141
bool, Field(description="includes projects marked as hidden in the listing")
142142
] = False
@@ -173,14 +173,12 @@ def _search_check_empty_string(cls, v):
173173
)(null_or_none_str_to_none_validator)
174174

175175
@model_validator(mode="after")
176-
def check_template_type_compatibility(self):
176+
def _check_template_type_compatibility(self):
177177
if (
178178
self.project_type in [ProjectTypeAPI.all, ProjectTypeAPI.user]
179179
and self.template_type is not None
180180
):
181-
msg = (
182-
"When project type is `all` or `user` the template_type should be None"
183-
)
181+
msg = f"When {self.project_type=} is `all` or `user` the {self.template_type=} should be None"
184182
raise ValueError(msg)
185183
return self
186184

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

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
def standard_user_role() -> tuple[str, tuple[UserRole, ExpectedResponse]]:
3939
all_roles = standard_role_response()
4040

41-
return (all_roles[0], [pytest.param(*all_roles[1][2], id="standard user role")])
41+
return (all_roles[0], [pytest.param(*all_roles[1][2], id="standard_user_role")])
4242

4343

4444
def standard_and_tester_user_roles() -> tuple[str, tuple[UserRole, ExpectedResponse]]:
@@ -47,7 +47,7 @@ def standard_and_tester_user_roles() -> tuple[str, tuple[UserRole, ExpectedRespo
4747
return (
4848
all_roles[0],
4949
[
50-
pytest.param(*all_roles[1][2], id="standard user role"),
50+
pytest.param(*all_roles[1][2], id="standard_user_role"),
5151
pytest.param(*all_roles[1][3], id="tester_user_role"),
5252
],
5353
)
@@ -118,7 +118,7 @@ async def test_list_projects_with_search_parameter(
118118
fake_project: ProjectDict,
119119
tests_data_dir: Path,
120120
osparc_product_name: str,
121-
project_db_cleaner,
121+
project_db_cleaner: None,
122122
mock_catalog_api_get_services_for_user_in_product,
123123
):
124124
projects_info = [
@@ -173,7 +173,7 @@ async def test_list_projects_with_search_parameter(
173173
resp = await client.get(f"{base_url}")
174174
data = await resp.json()
175175

176-
assert resp.status == 200
176+
assert resp.status == status.HTTP_200_OK
177177
_assert_response_data(data, 5, 0, 5, "/v0/projects?offset=0&limit=20", 5)
178178

179179
# Now we will test with empty search parameter
@@ -184,7 +184,7 @@ async def test_list_projects_with_search_parameter(
184184
resp = await client.get(f"{url}")
185185
data = await resp.json()
186186

187-
assert resp.status == 200
187+
assert resp.status == status.HTTP_200_OK
188188
_assert_response_data(data, 5, 0, 5, "/v0/projects?search=&offset=0&limit=20", 5)
189189

190190
# Now we will test upper/lower case search
@@ -195,7 +195,7 @@ async def test_list_projects_with_search_parameter(
195195
resp = await client.get(f"{url}")
196196
data = await resp.json()
197197

198-
assert resp.status == 200
198+
assert resp.status == status.HTTP_200_OK
199199
_assert_response_data(
200200
data, 1, 0, 1, "/v0/projects?search=nAmE+5&offset=0&limit=20", 1
201201
)
@@ -211,7 +211,7 @@ async def test_list_projects_with_search_parameter(
211211
resp = await client.get(f"{url}")
212212
data = await resp.json()
213213

214-
assert resp.status == 200
214+
assert resp.status == status.HTTP_200_OK
215215
_assert_response_data(
216216
data,
217217
1,
@@ -229,7 +229,7 @@ async def test_list_projects_with_search_parameter(
229229
resp = await client.get(f"{url}")
230230
data = await resp.json()
231231

232-
assert resp.status == 200
232+
assert resp.status == status.HTTP_200_OK
233233
_assert_response_data(
234234
data, 1, 0, 1, "/v0/projects?search=2-fe1b-11ed-b038-cdb1&offset=0&limit=20", 1
235235
)
@@ -248,7 +248,7 @@ async def test_list_projects_with_search_parameter(
248248
resp = await client.get(f"{url}")
249249
data = await resp.json()
250250

251-
assert resp.status == 200
251+
assert resp.status == status.HTTP_200_OK
252252
_assert_response_data(
253253
data,
254254
5,
@@ -266,7 +266,7 @@ async def test_list_projects_with_search_parameter(
266266
resp = await client.get(f"{url}")
267267
data = await resp.json()
268268

269-
assert resp.status == 200
269+
assert resp.status == status.HTTP_200_OK
270270
_assert_response_data(data, 2, 0, 2, "/v0/projects?search=oda&offset=0&limit=20", 2)
271271

272272
# Now we will test search that returns nothing
@@ -277,7 +277,7 @@ async def test_list_projects_with_search_parameter(
277277
resp = await client.get(f"{url}")
278278
data = await resp.json()
279279

280-
assert resp.status == 200
280+
assert resp.status == status.HTTP_200_OK
281281
_assert_response_data(
282282
data, 0, 0, 0, "/v0/projects?search=does+not+exists&offset=0&limit=20", 0
283283
)
@@ -290,7 +290,7 @@ async def test_list_projects_with_search_parameter(
290290
resp = await client.get(f"{url}")
291291
data = await resp.json()
292292

293-
assert resp.status == 200
293+
assert resp.status == status.HTTP_200_OK
294294
_assert_response_data(data, 2, 0, 1, "/v0/projects?search=oda&offset=0&limit=1", 1)
295295
assert data["_meta"]["limit"] == 1
296296
assert data["_links"]["next"].endswith("/v0/projects?search=oda&offset=1&limit=1")
@@ -308,8 +308,8 @@ async def test_list_projects_with_order_by_parameter(
308308
fake_project: ProjectDict,
309309
tests_data_dir: Path,
310310
osparc_product_name: str,
311-
project_db_cleaner,
312-
mock_catalog_api_get_services_for_user_in_product,
311+
project_db_cleaner: None,
312+
mock_catalog_api_get_services_for_user_in_product: None,
313313
):
314314
projects_info = [
315315
_ProjectInfo(
@@ -367,7 +367,7 @@ async def test_list_projects_with_order_by_parameter(
367367
)
368368
resp = await client.get(f"{url}")
369369
data = await resp.json()
370-
assert resp.status == 200
370+
assert resp.status == status.HTTP_200_OK
371371
assert [item["uuid"][0] for item in data["data"]] == _alphabetically_ordered_list
372372

373373
# Order by uuid descending
@@ -377,7 +377,7 @@ async def test_list_projects_with_order_by_parameter(
377377
)
378378
resp = await client.get(f"{url}")
379379
data = await resp.json()
380-
assert resp.status == 200
380+
assert resp.status == status.HTTP_200_OK
381381
assert [item["uuid"][0] for item in data["data"]] == _alphabetically_ordered_list[
382382
::-1
383383
]
@@ -389,7 +389,7 @@ async def test_list_projects_with_order_by_parameter(
389389
)
390390
resp = await client.get(f"{url}")
391391
data = await resp.json()
392-
assert resp.status == 200
392+
assert resp.status == status.HTTP_200_OK
393393
assert [item["name"][0] for item in data["data"]] == _alphabetically_ordered_list
394394

395395
# Order by description ascending
@@ -399,7 +399,7 @@ async def test_list_projects_with_order_by_parameter(
399399
)
400400
resp = await client.get(f"{url}")
401401
data = await resp.json()
402-
assert resp.status == 200
402+
assert resp.status == status.HTTP_200_OK
403403
assert [
404404
item["description"][0] for item in data["data"]
405405
] == _alphabetically_ordered_list
@@ -448,9 +448,9 @@ async def test_list_projects_for_specific_folder_id(
448448
fake_project: ProjectDict,
449449
tests_data_dir: Path,
450450
osparc_product_name: str,
451-
project_db_cleaner,
452-
mock_catalog_api_get_services_for_user_in_product,
453-
setup_folders_db,
451+
project_db_cleaner: None,
452+
mock_catalog_api_get_services_for_user_in_product: None,
453+
setup_folders_db: FolderID,
454454
):
455455
projects_info = [
456456
_ProjectInfo(
@@ -494,7 +494,7 @@ async def test_list_projects_for_specific_folder_id(
494494
resp = await client.get(f"{base_url}")
495495
data = await resp.json()
496496

497-
assert resp.status == 200
497+
assert resp.status == status.HTTP_200_OK
498498
_assert_response_data(data, 3, 0, 3, "/v0/projects?offset=0&limit=20", 3)
499499

500500
# Now we will test listing of the root directory with provided folder id query
@@ -504,7 +504,7 @@ async def test_list_projects_for_specific_folder_id(
504504
resp = await client.get(f"{url}")
505505
data = await resp.json()
506506

507-
assert resp.status == 200
507+
assert resp.status == status.HTTP_200_OK
508508
_assert_response_data(
509509
data, 3, 0, 3, "/v0/projects?folder_id=null&offset=0&limit=20", 3
510510
)
@@ -517,7 +517,7 @@ async def test_list_projects_for_specific_folder_id(
517517
resp = await client.get(f"{url}")
518518
data = await resp.json()
519519

520-
assert resp.status == 200
520+
assert resp.status == status.HTTP_200_OK
521521
_assert_response_data(
522522
data, 1, 0, 1, f"/v0/projects?folder_id={setup_folders_db}&offset=0&limit=20", 1
523523
)
@@ -531,7 +531,7 @@ async def test_list_and_patch_projects_with_template_type(
531531
fake_project: ProjectDict,
532532
tests_data_dir: Path,
533533
osparc_product_name: str,
534-
project_db_cleaner,
534+
project_db_cleaner: None,
535535
mock_catalog_api_get_services_for_user_in_product,
536536
):
537537
projects_type = [
@@ -562,7 +562,7 @@ async def test_list_and_patch_projects_with_template_type(
562562
resp = await client.get(f"{url}")
563563
data = await resp.json()
564564

565-
assert resp.status == 200
565+
assert resp.status == status.HTTP_200_OK
566566
_assert_response_data(data, 3, 0, 3, "/v0/projects?type=user&offset=0&limit=20", 3)
567567

568568
# Now we will test listing with type=all
@@ -572,7 +572,7 @@ async def test_list_and_patch_projects_with_template_type(
572572
resp = await client.get(f"{url}")
573573
data = await resp.json()
574574

575-
assert resp.status == 200
575+
assert resp.status == status.HTTP_200_OK
576576
_assert_response_data(data, 5, 0, 5, "/v0/projects?type=all&offset=0&limit=20", 5)
577577

578578
# Now we will test listing with type=template
@@ -582,7 +582,7 @@ async def test_list_and_patch_projects_with_template_type(
582582
resp = await client.get(f"{url}")
583583
data = await resp.json()
584584

585-
assert resp.status == 200
585+
assert resp.status == status.HTTP_200_OK
586586
_assert_response_data(
587587
data, 2, 0, 2, "/v0/projects?type=template&offset=0&limit=20", 2
588588
)
@@ -594,7 +594,7 @@ async def test_list_and_patch_projects_with_template_type(
594594
resp = await client.get(f"{url}")
595595
data = await resp.json()
596596

597-
assert resp.status == 200
597+
assert resp.status == status.HTTP_200_OK
598598
_assert_response_data(
599599
data, 3, 0, 3, "/v0/projects?type=user&template_type=null&offset=0&limit=20", 3
600600
)
@@ -613,7 +613,7 @@ async def test_list_and_patch_projects_with_template_type(
613613
resp = await client.get(f"{url}")
614614
data = await resp.json()
615615

616-
assert resp.status == 200
616+
assert resp.status == status.HTTP_200_OK
617617
_assert_response_data(
618618
data,
619619
2,
@@ -648,7 +648,7 @@ async def test_list_and_patch_projects_with_template_type(
648648
resp = await client.get(f"{url}")
649649
data = await resp.json()
650650

651-
assert resp.status == 200
651+
assert resp.status == status.HTTP_200_OK
652652
_assert_response_data(
653653
data,
654654
3,
@@ -665,7 +665,7 @@ async def test_list_and_patch_projects_with_template_type(
665665
resp = await client.get(f"{url}")
666666
data = await resp.json()
667667

668-
assert resp.status == 200
668+
assert resp.status == status.HTTP_200_OK
669669
_assert_response_data(
670670
data,
671671
1,
@@ -682,7 +682,7 @@ async def test_list_and_patch_projects_with_template_type(
682682
resp = await client.get(f"{url}")
683683
data = await resp.json()
684684

685-
assert resp.status == 200
685+
assert resp.status == status.HTTP_200_OK
686686
_assert_response_data(
687687
data,
688688
1,

0 commit comments

Comments
 (0)