@@ -39,30 +39,37 @@ def mocked_catalog(
3939@pytest .mark .acceptance_test (
4040 "For https://github.com/ITISFoundation/osparc-simcore/pull/6579"
4141)
42- @pytest .mark .parametrize ("is_trash_service_running" , [False , True ])
42+ @pytest .mark .parametrize ("force" , [False , True ])
43+ @pytest .mark .parametrize ("is_project_running" , [False , True ])
4344async def test_trash_projects (
4445 client : TestClient ,
4546 logged_user : UserInfoDict ,
4647 user_project : ProjectDict ,
4748 mocked_catalog : None ,
4849 director_v2_service_mock : aioresponses ,
4950 mocker : MockerFixture ,
50- is_trash_service_running : bool ,
51+ force : bool ,
52+ is_project_running : bool ,
5153):
5254 assert client .app
5355
5456 # this test should have no errors stopping services
55- mocker .patch (
57+ mock_remove_dynamic_services = mocker .patch (
5658 "simcore_service_webserver.projects._trash_api.projects_api.remove_project_dynamic_services" ,
5759 autospec = True ,
5860 )
59- mocker .patch (
60- "simcore_service_webserver.projects._trash_api.director_v2_api.delete_pipeline " ,
61+ mock_stop_pipeline = mocker .patch (
62+ "simcore_service_webserver.projects._trash_api.director_v2_api.stop_pipeline " ,
6163 autospec = True ,
6264 )
6365 mocker .patch (
6466 "simcore_service_webserver.projects._trash_api.director_v2_api.is_pipeline_running" ,
65- return_value = is_trash_service_running ,
67+ return_value = is_project_running ,
68+ autospec = True ,
69+ )
70+ mocker .patch (
71+ "simcore_service_webserver.projects._trash_api.director_v2_api.list_dynamic_services" ,
72+ return_value = [mocker .MagicMock ()] if is_project_running else [],
6673 autospec = True ,
6774 )
6875
@@ -91,15 +98,17 @@ async def test_trash_projects(
9198
9299 # TRASH
93100 trashing_at = arrow .utcnow ().datetime
94- resp = await client .post (f"/v0/projects/{ project_uuid } :trash" )
101+ resp = await client .post (
102+ f"/v0/projects/{ project_uuid } :trash" , params = {"force" : f"{ force } " }
103+ )
95104 _ , error = await assert_status (
96105 resp ,
97106 status .HTTP_409_CONFLICT
98- if is_trash_service_running
107+ if ( is_project_running and not force )
99108 else status .HTTP_204_NO_CONTENT ,
100109 )
101110
102- could_not_trash = is_trash_service_running
111+ could_not_trash = is_project_running and not force
103112
104113 if could_not_trash :
105114 assert error ["status" ] == status .HTTP_409_CONFLICT
@@ -140,3 +149,7 @@ async def test_trash_projects(
140149
141150 assert got .uuid == project_uuid
142151 assert got .trashed_at is None
152+
153+ if is_project_running and force :
154+ mock_remove_dynamic_services .assert_any_await ()
155+ mock_stop_pipeline .assert_any_await ()
0 commit comments