Skip to content

Commit 90a73e1

Browse files
committed
drafts test
1 parent ca0238e commit 90a73e1

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

services/web/server/src/simcore_service_webserver/garbage_collector/_tasks_trash.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
CleanupContextFunc = Callable[[web.Application], AsyncIterator[None]]
2020

2121

22+
# TODO: update to new style? like vip task. and add setup there?
23+
2224
_PERIODIC_TASK_NAME = f"{__name__}"
2325
_APP_TASK_KEY = f"{_PERIODIC_TASK_NAME}.task"
2426

services/web/server/tests/unit/with_dbs/03/test_trash.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from simcore_service_webserver.db.models import UserRole
2929
from simcore_service_webserver.projects._groups_api import ProjectGroupGet
3030
from simcore_service_webserver.projects.models import ProjectDict
31+
from tenacity import AsyncRetrying, stop_after_attempt, wait_fixed
3132
from yarl import URL
3233

3334

@@ -789,3 +790,54 @@ async def test_trash_project_in_subfolder(
789790
page = Page[ProjectGet].model_validate(await resp.json())
790791
assert page.meta.total == 1
791792
assert page.data[0].uuid == project_uuid
793+
794+
795+
async def test_trash_project_explitictly_and_empty_trash_bin(
796+
client: TestClient,
797+
logged_user: UserInfoDict,
798+
user_project: ProjectDict,
799+
mocked_catalog: None,
800+
mocked_dynamic_services_interface: dict[str, MagicMock],
801+
):
802+
assert client.app
803+
804+
project_uuid = UUID(user_project["uuid"])
805+
806+
# TRASH project
807+
trashing_at = arrow.utcnow().datetime
808+
resp = await client.post(
809+
f"/v0/projects/{project_uuid}:trash", params={"force": "true"}
810+
)
811+
await assert_status(resp, status.HTTP_204_NO_CONTENT)
812+
813+
# LIST trashed projects
814+
resp = await client.get("/v0/projects", params={"filters": '{"trashed": true}'})
815+
await assert_status(resp, status.HTTP_200_OK)
816+
817+
page = Page[ProjectListItem].model_validate(await resp.json())
818+
assert page.meta.total == 1
819+
assert page.data[0].uuid == project_uuid
820+
821+
# GET trashed project
822+
resp = await client.get(f"/v0/projects/{project_uuid}")
823+
data, _ = await assert_status(resp, status.HTTP_200_OK)
824+
got = ProjectGet.model_validate(data)
825+
assert got.uuid == project_uuid
826+
assert got.trashed_at is not None
827+
assert trashing_at < got.trashed_at < arrow.utcnow().datetime
828+
829+
# force EMPTY trash
830+
resp = await client.delete("/v0/trash")
831+
await assert_status(resp, status.HTTP_204_NO_CONTENT)
832+
833+
async for attempt in AsyncRetrying(
834+
stop=stop_after_attempt(3), wait=wait_fixed(1), reraise=True
835+
):
836+
with attempt:
837+
# LIST trashed projects again
838+
resp = await client.get(
839+
"/v0/projects", params={"filters": '{"trashed": true}'}
840+
)
841+
await assert_status(resp, status.HTTP_200_OK)
842+
page = Page[ProjectListItem].model_validate(await resp.json())
843+
assert page.meta.total == 0

0 commit comments

Comments
 (0)