|
14 | 14 | import pytest |
15 | 15 | from aiohttp.test_utils import TestClient |
16 | 16 | from aioresponses import aioresponses |
| 17 | +from models_library.api_schemas_webserver.folders_v2 import FolderGet |
17 | 18 | from models_library.api_schemas_webserver.projects import ProjectGet, ProjectListItem |
18 | 19 | from models_library.rest_pagination import Page |
19 | 20 | from pytest_mock import MockerFixture |
@@ -174,3 +175,41 @@ async def test_trash_projects( # noqa: PLR0915 |
174 | 175 | await asyncio.sleep(0.1) |
175 | 176 | mock_stop_pipeline.assert_awaited() |
176 | 177 | mock_remove_dynamic_services.assert_awaited() |
| 178 | + |
| 179 | + |
| 180 | +@pytest.mark.acceptance_test( |
| 181 | + "For https://github.com/ITISFoundation/osparc-simcore/pull/6642" |
| 182 | +) |
| 183 | +@pytest.mark.parametrize("is_project_running", [False, True]) |
| 184 | +@pytest.mark.parametrize("force", [False, True]) |
| 185 | +async def test_trash_folder( |
| 186 | + client: TestClient, logged_user: UserInfoDict, is_project_running: bool, force: bool |
| 187 | +): |
| 188 | + folder_id = ... |
| 189 | + |
| 190 | + # LIST NOT trashed |
| 191 | + resp = await client.get("/v0/folders") |
| 192 | + await assert_status(resp, status.HTTP_200_OK) |
| 193 | + |
| 194 | + page = Page[FolderGet].parse_obj(await resp.json()) |
| 195 | + assert page.meta.total == 1 |
| 196 | + |
| 197 | + got = page.data[0] |
| 198 | + assert got.folder_id == folder_id |
| 199 | + assert got.trashed_at is None |
| 200 | + |
| 201 | + # LIST trashed |
| 202 | + resp = await client.get("/v0/folders", params={"filters": '{"trashed": true}'}) |
| 203 | + await assert_status(resp, status.HTTP_200_OK) |
| 204 | + |
| 205 | + # TRASH |
| 206 | + trashing_at = arrow.utcnow().datetime |
| 207 | + resp = await client.post( |
| 208 | + f"/v0/folders/{folder_id}:trash", params={"force": f"{force}"} |
| 209 | + ) |
| 210 | + _, error = await assert_status( |
| 211 | + resp, |
| 212 | + status.HTTP_409_CONFLICT |
| 213 | + if (is_project_running and not force) |
| 214 | + else status.HTTP_204_NO_CONTENT, |
| 215 | + ) |
0 commit comments