From fb2ed153dc84ac97bf3e346968f8f610ff7d3608 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Fri, 15 Nov 2024 09:52:49 +0100 Subject: [PATCH] fix deprecated --- .../tests/test_projects_state.py | 2 +- .../tests/unit/with_dbs/03/test_trash.py | 56 +++++++++---------- .../04/folders/test_folders__full_search.py | 2 +- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/packages/models-library/tests/test_projects_state.py b/packages/models-library/tests/test_projects_state.py index a5e7f5ce7ea..08493f9f3b1 100644 --- a/packages/models-library/tests/test_projects_state.py +++ b/packages/models-library/tests/test_projects_state.py @@ -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( diff --git a/services/web/server/tests/unit/with_dbs/03/test_trash.py b/services/web/server/tests/unit/with_dbs/03/test_trash.py index 7d6c701c522..16a5f9dc147 100644 --- a/services/web/server/tests/unit/with_dbs/03/test_trash.py +++ b/services/web/server/tests/unit/with_dbs/03/test_trash.py @@ -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] @@ -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 @@ -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: @@ -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: @@ -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 @@ -187,7 +187,7 @@ 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) # --------------------------------------------------------------------- @@ -195,7 +195,7 @@ async def test_trash_single_folder(client: TestClient, logged_user: UserInfoDict 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -271,7 +271,7 @@ 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( @@ -279,7 +279,7 @@ async def test_trash_folder_with_content( 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( @@ -290,13 +290,13 @@ 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 @@ -304,7 +304,7 @@ async def test_trash_folder_with_content( "/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 @@ -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 @@ -327,7 +327,7 @@ 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( @@ -335,23 +335,23 @@ async def test_trash_folder_with_content( 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 @@ -361,7 +361,7 @@ 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( @@ -369,7 +369,7 @@ 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( @@ -377,21 +377,21 @@ async def test_trash_folder_with_content( 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 diff --git a/services/web/server/tests/unit/with_dbs/04/folders/test_folders__full_search.py b/services/web/server/tests/unit/with_dbs/04/folders/test_folders__full_search.py index 74126da042f..e9bde5d9ec5 100644 --- a/services/web/server/tests/unit/with_dbs/04/folders/test_folders__full_search.py +++ b/services/web/server/tests/unit/with_dbs/04/folders/test_folders__full_search.py @@ -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()