From 44e1c152ec9d1915e5c55d378659dd0aaedfd431 Mon Sep 17 00:00:00 2001 From: Pedro Crespo-Valero <32402063+pcrespov@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:33:28 +0100 Subject: [PATCH] cleanup --- .../with_dbs/04/workspaces/test_workspaces.py | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces.py b/services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces.py index c45d2b43783d..7de666c2511d 100644 --- a/services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces.py +++ b/services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces.py @@ -50,7 +50,7 @@ async def test_workspaces_user_role_permissions( assert client.app url = client.app.router["list_workspaces"].url_for() - resp = await client.get(url.path) + resp = await client.get(f"{url}") await assert_status(resp, expected.ok) @@ -65,78 +65,75 @@ async def test_workspaces_workflow( # list user workspaces url = client.app.router["list_workspaces"].url_for() - resp = await client.get(url.path) + resp = await client.get(f"{url}") data, _ = await assert_status(resp, status.HTTP_200_OK) assert data == [] # create a new workspace url = client.app.router["create_workspace"].url_for() resp = await client.post( - url.path, + f"{url}", json={ "name": "My first workspace", "description": "Custom description", "thumbnail": None, }, ) - added_workspace, _ = await assert_status(resp, status.HTTP_201_CREATED) - assert WorkspaceGet.parse_obj(added_workspace) + data, _ = await assert_status(resp, status.HTTP_201_CREATED) + added_workspace = WorkspaceGet.parse_obj(data) # list user workspaces url = client.app.router["list_workspaces"].url_for() - resp = await client.get(url.path) + resp = await client.get(f"{url}") data, _, meta, links = await assert_status( resp, status.HTTP_200_OK, include_meta=True, include_links=True ) assert len(data) == 1 - assert data[0]["workspaceId"] == added_workspace["workspaceId"] - assert data[0]["name"] == "My first workspace" - assert data[0]["description"] == "Custom description" + assert data[0] == added_workspace.dict() assert meta["count"] == 1 assert links # get a user workspace url = client.app.router["get_workspace"].url_for( - workspace_id=f"{added_workspace['workspaceId']}" + workspace_id=f"{added_workspace.workspace_id}" ) - resp = await client.get(url) + resp = await client.get(f"{url}") data, _ = await assert_status(resp, status.HTTP_200_OK) - assert data["workspaceId"] == added_workspace["workspaceId"] + assert data["workspaceId"] == added_workspace.workspace_id assert data["name"] == "My first workspace" assert data["description"] == "Custom description" # update a workspace url = client.app.router["replace_workspace"].url_for( - workspace_id=f"{added_workspace['workspaceId']}" + workspace_id=f"{added_workspace.workspace_id}" ) resp = await client.put( - url.path, + f"{url}", json={ "name": "My Second workspace", "description": "", }, ) data, _ = await assert_status(resp, status.HTTP_200_OK) - assert WorkspaceGet.parse_obj(data) + second_workspace = WorkspaceGet.parse_obj(data) # list user workspaces url = client.app.router["list_workspaces"].url_for() - resp = await client.get(url.path) + resp = await client.get(f"{url}") data, _ = await assert_status(resp, status.HTTP_200_OK) assert len(data) == 1 - assert data[0]["name"] == "My Second workspace" - assert data[0]["description"] == "" + assert data[0] == second_workspace.dict() # delete a workspace url = client.app.router["delete_workspace"].url_for( - workspace_id=f"{added_workspace['workspaceId']}" + workspace_id=f"{added_workspace.workspace_id}" ) - resp = await client.delete(url.path) + resp = await client.delete(f"{url}") data, _ = await assert_status(resp, status.HTTP_204_NO_CONTENT) # list user workspaces url = client.app.router["list_workspaces"].url_for() - resp = await client.get(url.path) + resp = await client.get(f"{url}") data, _ = await assert_status(resp, status.HTTP_200_OK) assert data == [] @@ -151,3 +148,4 @@ async def test_project_workspace_movement_full_workflow( assert client.app # NOTE: MD: not yet implemented + # SEE https://github.com/ITISFoundation/osparc-simcore/issues/6778