Skip to content

Commit

Permalink
Merge branch 'master' into enh/multiselect-data
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Dec 12, 2024
2 parents 0881037 + 065bd8f commit ae06040
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 19 deletions.
3 changes: 1 addition & 2 deletions scripts/maintenance/migrate_project/src/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pathlib import Path
from typing import Optional

import typer
from db import (
Expand All @@ -15,7 +14,7 @@
def main(config: Path = typer.Option(..., exists=True)):
assert config.exists() # nosec
settings = Settings.load_from_file(config)
typer.echo(f"Detected settings:\n{settings.json(indent=2)}\n")
typer.echo(f"Detected settings:\n{settings.model_dump_json(indent=2)}\n")

r_clone_config_path = assemble_config_file(
# source
Expand Down
4 changes: 3 additions & 1 deletion scripts/maintenance/migrate_project/src/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,7 @@ class Config:
if __name__ == "__main__":
# produces an empty configuration to be saved as starting point
print(
Settings.model_validate(Settings.Config.schema_extra["example"]).json(indent=2)
Settings.model_validate(
Settings.Config.schema_extra["example"]
).model_dump_json(indent=2)
)
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ async def update(
"""
Batch/single patch of folder/s
"""
# NOTE: exclude unset can also be done using a pydantic model and dict(exclude_unset=True)
# NOTE: exclude unset can also be done using a pydantic model and model_dump(exclude_unset=True)
updated = as_dict_exclude_unset(
name=name,
parent_folder_id=parent_folder_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async def update(
) -> LicensedItemDB:
# NOTE: at least 'touch' if updated_values is empty
_updates = {
**updates.dict(exclude_unset=True),
**updates.model_dump(exclude_unset=True),
"modified": func.now(),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async def update_project_to_folder(
"""
Batch/single patch of project to folders
"""
# NOTE: exclude unset can also be done using a pydantic model and dict(exclude_unset=True)
# NOTE: exclude unset can also be done using a pydantic model and model_dump(exclude_unset=True)
updated = as_dict_exclude_unset(
user_id=user_id,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ async def update_workspace(
) -> WorkspaceDB:
# NOTE: at least 'touch' if updated_values is empty
_updates = {
**updates.dict(exclude_unset=True),
**updates.model_dump(exclude_unset=True),
"modified": func.now(),
}

Expand Down
18 changes: 9 additions & 9 deletions services/web/server/tests/unit/with_dbs/03/test_trash.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ async def workspace(
# CREATE a workspace
resp = await client.post("/v0/workspaces", json={"name": "My first workspace"})
data, _ = await assert_status(resp, status.HTTP_201_CREATED)
workspace = WorkspaceGet.parse_obj(data)
workspace = WorkspaceGet.model_validate(data)

yield workspace

Expand All @@ -433,15 +433,15 @@ async def test_trash_empty_workspace(
resp = await client.get("/v0/workspaces")
await assert_status(resp, status.HTTP_200_OK)

page = Page[WorkspaceGet].parse_obj(await resp.json())
page = Page[WorkspaceGet].model_validate(await resp.json())
assert page.meta.total == 1
assert page.data[0] == workspace

# LIST trashed
resp = await client.get("/v0/workspaces", params={"filters": '{"trashed": true}'})
await assert_status(resp, status.HTTP_200_OK)

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

# -------------
Expand All @@ -457,16 +457,16 @@ async def test_trash_empty_workspace(
resp = await client.get("/v0/workspaces")
await assert_status(resp, status.HTTP_200_OK)

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

# LIST trashed
resp = await client.get("/v0/workspaces", params={"filters": '{"trashed": true}'})
await assert_status(resp, status.HTTP_200_OK)

page = Page[WorkspaceGet].parse_obj(await resp.json())
page = Page[WorkspaceGet].model_validate(await resp.json())
assert page.meta.total == 1
assert page.data[0].dict(exclude=_exclude_attrs) == workspace.dict(
assert page.data[0].model_dump(exclude=_exclude_attrs) == workspace.model_dump(
exclude=_exclude_attrs
)
assert page.data[0].trashed_at is not None
Expand All @@ -483,9 +483,9 @@ async def test_trash_empty_workspace(
resp = await client.get("/v0/workspaces")
await assert_status(resp, status.HTTP_200_OK)

page = Page[WorkspaceGet].parse_obj(await resp.json())
page = Page[WorkspaceGet].model_validate(await resp.json())
assert page.meta.total == 1
assert page.data[0].dict(exclude=_exclude_attrs) == workspace.dict(
assert page.data[0].model_dump(exclude=_exclude_attrs) == workspace.model_dump(
exclude=_exclude_attrs
)

Expand All @@ -496,5 +496,5 @@ async def test_trash_empty_workspace(
resp = await client.get("/v0/workspaces", params={"filters": '{"trashed": true}'})
await assert_status(resp, status.HTTP_200_OK)

page = Page[WorkspaceGet].parse_obj(await resp.json())
page = Page[WorkspaceGet].model_validate(await resp.json())
assert page.meta.total == 0
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def test_workspaces_workflow(
resp, status.HTTP_200_OK, include_meta=True, include_links=True
)
assert len(data) == 1
assert WorkspaceGet.parse_obj(data[0]) == added_workspace
assert WorkspaceGet.model_validate(data[0]) == added_workspace
assert meta["count"] == 1
assert links

Expand Down Expand Up @@ -126,7 +126,7 @@ async def test_workspaces_workflow(
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert WorkspaceGet.parse_obj(data[0]) == replaced_workspace
assert WorkspaceGet.model_validate(data[0]) == replaced_workspace

# DELETE a workspace
url = client.app.router["delete_workspace"].url_for(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ async def test_workspaces_delete_folders(
},
)
data, _ = await assert_status(resp, status.HTTP_201_CREATED)
added_workspace = WorkspaceGet.parse_obj(data)
added_workspace = WorkspaceGet.model_validate(data)

# Create project in workspace
project_data = deepcopy(fake_project)
Expand Down

0 comments on commit ae06040

Please sign in to comment.