1212from models_library .api_schemas_webserver .projects_access_rights import (
1313 ProjectShareAccepted ,
1414)
15+ from pytest_mock import MockType
1516from pytest_mock .plugin import MockerFixture
1617from pytest_simcore .helpers .assert_checks import assert_status
1718from pytest_simcore .helpers .webserver_login import NewUser , UserInfoDict
2122
2223
2324@pytest .fixture
24- def mock_catalog_api_get_services_for_user_in_product (mocker : MockerFixture ):
25- mocker .patch (
25+ def mock_catalog_api_get_services_for_user_in_product (
26+ mocker : MockerFixture ,
27+ ) -> MockType :
28+ return mocker .patch (
2629 "simcore_service_webserver.projects._controller.projects_rest.catalog_service.get_services_for_user_in_product" ,
2730 spec = True ,
2831 return_value = [],
2932 )
3033
3134
3235@pytest .fixture
33- def mock_project_uses_available_services (mocker : MockerFixture ):
34- mocker .patch (
36+ def mock_project_uses_available_services (mocker : MockerFixture ) -> MockType :
37+ return mocker .patch (
3538 "simcore_service_webserver.projects._controller.projects_rest.project_uses_available_services" ,
3639 spec = True ,
3740 return_value = True ,
@@ -47,8 +50,8 @@ async def test_projects_groups_full_workflow( # noqa: PLR0915
4750 logged_user : UserInfoDict ,
4851 user_project : ProjectDict ,
4952 expected : HTTPStatus ,
50- mock_catalog_api_get_services_for_user_in_product ,
51- mock_project_uses_available_services ,
53+ mock_catalog_api_get_services_for_user_in_product : MockType ,
54+ mock_project_uses_available_services : MockType ,
5255):
5356 assert client .app
5457 # check the default project permissions
@@ -261,8 +264,8 @@ async def test_share_project(
261264 client : TestClient ,
262265 logged_user : UserInfoDict ,
263266 user_project : ProjectDict ,
264- mock_catalog_api_get_services_for_user_in_product ,
265- mock_project_uses_available_services ,
267+ mock_catalog_api_get_services_for_user_in_product : MockType ,
268+ mock_project_uses_available_services : MockType ,
266269):
267270 assert client .app
268271
@@ -297,3 +300,19 @@ async def test_share_project(
297300 assert data [0 ]["read" ] is True
298301 assert data [0 ]["write" ] is True
299302 assert data [0 ]["delete" ] is True
303+
304+ # check an invalid
305+ url = client .app .router ["share_project" ].url_for (
306+ project_id = f"{ user_project ['uuid' ]} "
307+ )
308+ resp = await client .post (
309+ f"{ url } " ,
310+ json = {
311+ "shareeEmail" :
"[email protected] " ,
312+ # invalid access rights combination
313+ "read" : True ,
314+ "write" : False ,
315+ "delete" : True ,
316+ },
317+ )
318+ await assert_status (resp , status .HTTP_422_UNPROCESSABLE_ENTITY )
0 commit comments