Skip to content

Commit fe365d7

Browse files
committed
updates test
1 parent 6470fbd commit fe365d7

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

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

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async def test_trash_projects(
4747
url = client.app.router["list_projects"].url_for()
4848
assert f"{url}" == "/v0/projects"
4949

50-
# list projects -> non trashed
50+
# LIST NOT trashed
5151
resp = await client.get("/v0/projects")
5252
await assert_status(resp, status.HTTP_200_OK)
5353

@@ -57,57 +57,45 @@ async def test_trash_projects(
5757
got = page.data[0]
5858
assert got.uuid == project_uuid
5959
assert got.trashed_at is None
60-
# TODO: assert got.trashed_by is None
6160

61+
# LIST trashed
6262
resp = await client.get("/v0/projects", params={"filters": '{"trashed": true}'})
6363
await assert_status(resp, status.HTTP_200_OK)
6464

6565
page = Page[ProjectListItem].parse_obj(await resp.json())
6666
assert page.meta.total == 0
6767

68-
# trash project ------------
68+
# TRASH
6969
trashing_at = arrow.utcnow().datetime
70-
resp = await client.get(f"/v0/projects/{project_uuid}:trash")
71-
data, _ = await assert_status(resp, status.HTTP_200_OK)
70+
resp = await client.post(f"/v0/projects/{project_uuid}:trash")
71+
await assert_status(resp, status.HTTP_204_NO_CONTENT)
7272

73+
# GET
74+
resp = await client.get(f"/v0/projects/{project_uuid}")
75+
data, _ = await assert_status(resp, status.HTTP_200_OK)
7376
got = ProjectGet.parse_obj(data)
7477
assert got.uuid == project_uuid
7578

7679
assert got.trashed_at
7780
assert trashing_at < got.trashed_at
7881
assert got.trashed_at < arrow.utcnow().datetime
79-
# TODO: assert got.trashed_by == logged_user["name"]
80-
81-
# get trashed project
82-
expected = got.copy()
83-
84-
resp = await client.get(f"/v0/projects/{project_uuid}")
85-
data, _ = await assert_status(resp, status.HTTP_200_OK)
86-
got = ProjectGet.parse_obj(data)
87-
assert got == expected
8882

89-
# list trashed projects
83+
# LIST trashed
9084
resp = await client.get("/v0/projects", params={"filters": '{"trashed": true}'})
9185
await assert_status(resp, status.HTTP_200_OK)
9286

9387
page = Page[ProjectListItem].parse_obj(await resp.json())
9488
assert page.meta.total == 1
9589
assert page.data[0].uuid == project_uuid
9690

97-
# untrash project
91+
# UNTRASH
9892
resp = await client.post(f"/v0/projects/{project_uuid}:untrash")
99-
data, _ = await assert_status(resp, status.HTTP_200_OK)
93+
data, _ = await assert_status(resp, status.HTTP_204_NO_CONTENT)
10094

95+
# GET
96+
resp = await client.get(f"/v0/projects/{project_uuid}")
97+
data, _ = await assert_status(resp, status.HTTP_200_OK)
10198
got = ProjectGet.parse_obj(data)
10299

103100
assert got.uuid == project_uuid
104101
assert got.trashed_at is None
105-
# TODO: assert got.trashed_by is None
106-
107-
# get untrashed project
108-
expected = got.copy()
109-
110-
resp = await client.get(f"/v0/projects/{project_uuid}")
111-
data, _ = await assert_status(resp, status.HTTP_200_OK)
112-
got = ProjectGet.parse_obj(data)
113-
assert got == expected

0 commit comments

Comments
 (0)