Skip to content

Commit

Permalink
fix deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
giancarloromeo committed Nov 15, 2024
1 parent 9494bd3 commit fb2ed15
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion packages/models-library/tests/test_projects_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_project_locked_with_missing_owner_raises():


def test_project_locked_with_missing_owner_ok_during_maintaining():
ProjectLocked.parse_obj({"value": True, "status": ProjectStatus.MAINTAINING})
ProjectLocked.model_validate({"value": True, "status": ProjectStatus.MAINTAINING})


@pytest.mark.parametrize(
Expand Down
56 changes: 28 additions & 28 deletions services/web/server/tests/unit/with_dbs/03/test_trash.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async def test_trash_projects( # noqa: PLR0915
resp = await client.get("/v0/projects")
await assert_status(resp, status.HTTP_200_OK)

page = Page[ProjectListItem].parse_obj(await resp.json())
page = Page[ProjectListItem].model_validate(await resp.json())
assert page.meta.total == 1

got = page.data[0]
Expand All @@ -114,7 +114,7 @@ async def test_trash_projects( # noqa: PLR0915
resp = await client.get("/v0/projects", params={"filters": '{"trashed": true}'})
await assert_status(resp, status.HTTP_200_OK)

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

# TRASH
Expand All @@ -138,7 +138,7 @@ async def test_trash_projects( # noqa: PLR0915
# GET
resp = await client.get(f"/v0/projects/{project_uuid}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
got = ProjectGet.parse_obj(data)
got = ProjectGet.model_validate(data)
assert got.uuid == project_uuid

if could_not_trash:
Expand All @@ -152,7 +152,7 @@ async def test_trash_projects( # noqa: PLR0915
resp = await client.get("/v0/projects", params={"filters": '{"trashed": true}'})
await assert_status(resp, status.HTTP_200_OK)

page = Page[ProjectListItem].parse_obj(await resp.json())
page = Page[ProjectListItem].model_validate(await resp.json())
if could_not_trash:
assert page.meta.total == 0
else:
Expand All @@ -166,7 +166,7 @@ async def test_trash_projects( # noqa: PLR0915
# GET
resp = await client.get(f"/v0/projects/{project_uuid}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
got = ProjectGet.parse_obj(data)
got = ProjectGet.model_validate(data)

assert got.uuid == project_uuid
assert got.trashed_at is None
Expand All @@ -187,15 +187,15 @@ async def test_trash_single_folder(client: TestClient, logged_user: UserInfoDict
# CREATE a folder
resp = await client.post("/v0/folders", json={"name": "My first folder"})
data, _ = await assert_status(resp, status.HTTP_201_CREATED)
folder = FolderGet.parse_obj(data)
folder = FolderGet.model_validate(data)

# ---------------------------------------------------------------------

# LIST NOT trashed
resp = await client.get("/v0/folders")
await assert_status(resp, status.HTTP_200_OK)

page = Page[FolderGet].parse_obj(await resp.json())
page = Page[FolderGet].model_validate(await resp.json())
assert page.meta.total == 1

assert page.data[0] == folder
Expand All @@ -204,7 +204,7 @@ async def test_trash_single_folder(client: TestClient, logged_user: UserInfoDict
resp = await client.get("/v0/folders", params={"filters": '{"trashed": true}'})
await assert_status(resp, status.HTTP_200_OK)

page = Page[FolderGet].parse_obj(await resp.json())
page = Page[FolderGet].model_validate(await resp.json())
assert page.meta.total == 0

# TRASH
Expand All @@ -222,7 +222,7 @@ async def test_trash_single_folder(client: TestClient, logged_user: UserInfoDict
# GET
resp = await client.get(f"/v0/folders/{folder.folder_id}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
got = FolderGet.parse_obj(data)
got = FolderGet.model_validate(data)
assert got.folder_id == folder.folder_id

assert got.trashed_at
Expand All @@ -233,7 +233,7 @@ async def test_trash_single_folder(client: TestClient, logged_user: UserInfoDict
resp = await client.get("/v0/folders", params={"filters": '{"trashed": true}'})
await assert_status(resp, status.HTTP_200_OK)

page = Page[FolderGet].parse_obj(await resp.json())
page = Page[FolderGet].model_validate(await resp.json())

assert page.meta.total == 1
assert page.data[0].folder_id == folder.folder_id
Expand All @@ -249,7 +249,7 @@ async def test_trash_single_folder(client: TestClient, logged_user: UserInfoDict
# GET
resp = await client.get(f"/v0/folders/{folder.folder_id}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
got = FolderGet.parse_obj(data)
got = FolderGet.model_validate(data)

assert got.folder_id == folder.folder_id
assert got.trashed_at is None
Expand All @@ -271,15 +271,15 @@ async def test_trash_folder_with_content(
# CREATE a folder
resp = await client.post("/v0/folders", json={"name": "My first folder"})
data, _ = await assert_status(resp, status.HTTP_201_CREATED)
folder = FolderGet.parse_obj(data)
folder = FolderGet.model_validate(data)

# CREATE a SUB-folder
resp = await client.post(
"/v0/folders",
json={"name": "My subfolder 1", "parentFolderId": folder.folder_id},
)
data, _ = await assert_status(resp, status.HTTP_201_CREATED)
subfolder = FolderGet.parse_obj(data)
subfolder = FolderGet.model_validate(data)

# MOVE project to SUB-folder
resp = await client.put(
Expand All @@ -290,21 +290,21 @@ async def test_trash_folder_with_content(
# CHECK created
resp = await client.get("/v0/folders")
await assert_status(resp, status.HTTP_200_OK)
page = Page[FolderGet].parse_obj(await resp.json())
page = Page[FolderGet].model_validate(await resp.json())
assert page.meta.total == 1
assert page.data[0] == folder

resp = await client.get("/v0/folders", params={"folder_id": f"{folder.folder_id}"})
await assert_status(resp, status.HTTP_200_OK)
page = Page[FolderGet].parse_obj(await resp.json())
page = Page[FolderGet].model_validate(await resp.json())
assert page.meta.total == 1
assert page.data[0] == subfolder

resp = await client.get(
"/v0/projects", params={"folder_id": f"{subfolder.folder_id}"}
)
await assert_status(resp, status.HTTP_200_OK)
page = Page[ProjectListItem].parse_obj(await resp.json())
page = Page[ProjectListItem].model_validate(await resp.json())
assert page.meta.total == 1
assert page.data[0].uuid == project_uuid
assert page.data[0].folder_id == subfolder.folder_id
Expand All @@ -318,7 +318,7 @@ async def test_trash_folder_with_content(
# ONLY folder listed in trash. The rest is not listed anymore!
resp = await client.get("/v0/folders", params={"filters": '{"trashed": true}'})
await assert_status(resp, status.HTTP_200_OK)
page = Page[FolderGet].parse_obj(await resp.json())
page = Page[FolderGet].model_validate(await resp.json())
assert page.meta.total == 1
assert page.data[0].folder_id == folder.folder_id

Expand All @@ -327,31 +327,31 @@ async def test_trash_folder_with_content(
params={"filters": '{"trashed": true}', "folder_id": f"{folder.folder_id}"},
)
await assert_status(resp, status.HTTP_200_OK)
page = Page[FolderGet].parse_obj(await resp.json())
page = Page[FolderGet].model_validate(await resp.json())
assert page.meta.total == 0

resp = await client.get(
"/v0/projects",
params={"filters": '{"trashed": true}', "folder_id": f"{subfolder.folder_id}"},
)
await assert_status(resp, status.HTTP_200_OK)
page = Page[ProjectListItem].parse_obj(await resp.json())
page = Page[ProjectListItem].model_validate(await resp.json())
assert page.meta.total == 0

# CHECK marked as trashed
resp = await client.get(f"/v0/folders/{folder.folder_id}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
got = FolderGet.parse_obj(data)
got = FolderGet.model_validate(data)
assert got.trashed_at is not None

resp = await client.get(f"/v0/folders/{subfolder.folder_id}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
got = FolderGet.parse_obj(data)
got = FolderGet.model_validate(data)
assert got.trashed_at is not None

resp = await client.get(f"/v0/projects/{project_uuid}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
got = ProjectGet.parse_obj(data)
got = ProjectGet.model_validate(data)
assert got.trashed_at is not None

# UNTRASH folder
Expand All @@ -361,37 +361,37 @@ async def test_trash_folder_with_content(
# NO folders listed in trash.
resp = await client.get("/v0/folders", params={"filters": '{"trashed": true}'})
await assert_status(resp, status.HTTP_200_OK)
page = Page[FolderGet].parse_obj(await resp.json())
page = Page[FolderGet].model_validate(await resp.json())
assert page.meta.total == 0

resp = await client.get(
"/v0/folders",
params={"filters": '{"trashed": true}', "folder_id": f"{folder.folder_id}"},
)
await assert_status(resp, status.HTTP_200_OK)
page = Page[FolderGet].parse_obj(await resp.json())
page = Page[FolderGet].model_validate(await resp.json())
assert page.meta.total == 0

resp = await client.get(
"/v0/projects",
params={"filters": '{"trashed": true}', "folder_id": f"{subfolder.folder_id}"},
)
await assert_status(resp, status.HTTP_200_OK)
page = Page[ProjectListItem].parse_obj(await resp.json())
page = Page[ProjectListItem].model_validate(await resp.json())
assert page.meta.total == 0

# CHECK marked as trashed
resp = await client.get(f"/v0/folders/{folder.folder_id}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
got = FolderGet.parse_obj(data)
got = FolderGet.model_validate(data)
assert got.trashed_at is None

resp = await client.get(f"/v0/folders/{subfolder.folder_id}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
got = FolderGet.parse_obj(data)
got = FolderGet.model_validate(data)
assert got.trashed_at is None

resp = await client.get(f"/v0/projects/{project_uuid}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
got = ProjectGet.parse_obj(data)
got = ProjectGet.model_validate(data)
assert got.trashed_at is None
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def test_folders_full_search(
},
)
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert FolderGet.parse_obj(data)
assert FolderGet.model_validate(data)

# list full folder search
url = client.app.router["list_folders_full_search"].url_for()
Expand Down

0 comments on commit fb2ed15

Please sign in to comment.