Skip to content

Commit

Permalink
fix urls
Browse files Browse the repository at this point in the history
  • Loading branch information
giancarloromeo committed Oct 31, 2024
1 parent dba3ce2 commit 9001bd5
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 75 deletions.
24 changes: 12 additions & 12 deletions services/web/server/tests/unit/with_dbs/01/folders/test_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def test_folders_full_workflow(
url = client.app.router["get_folder"].url_for(
folder_id=f"{added_folder['folderId']}"
)
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert FolderGet.model_validate(data)
assert data["folderId"] == added_folder["folderId"]
Expand Down Expand Up @@ -157,7 +157,7 @@ async def test_sub_folders_full_workflow(
# list user specific folder
base_url = client.app.router["list_folders"].url_for()
url = base_url.with_query({"folder_id": f"{subfolder_folder['folderId']}"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 0

Expand All @@ -175,7 +175,7 @@ async def test_sub_folders_full_workflow(
# list user subfolder folders
base_url = client.app.router["list_folders"].url_for()
url = base_url.with_query({"folder_id": f"{subfolder_folder['folderId']}"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["name"] == "My sub sub folder"
Expand Down Expand Up @@ -211,7 +211,7 @@ async def test_sub_folders_full_workflow(
# list user root folders
base_url = client.app.router["list_folders"].url_for()
url = base_url.with_query({"folder_id": "null"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 2

Expand Down Expand Up @@ -298,7 +298,7 @@ async def test_project_listing_inside_of_private_folder(
# list project in user private folder
base_url = client.app.router["list_projects"].url_for()
url = base_url.with_query({"folder_id": f"{original_user_folder['folderId']}"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["uuid"] == user_project["uuid"]
Expand All @@ -310,7 +310,7 @@ async def test_project_listing_inside_of_private_folder(
# Try to list folder that user doesn't have access to
base_url = client.app.router["list_projects"].url_for()
url = base_url.with_query({"folder_id": f"{original_user_folder['folderId']}"})
resp = await client.get(url)
resp = await client.get(f"{url}")
_, errors = await assert_status(
resp,
status.HTTP_403_FORBIDDEN,
Expand All @@ -330,7 +330,7 @@ async def test_project_listing_inside_of_private_folder(
# list new user root folder
base_url = client.app.router["list_projects"].url_for()
url = base_url.with_query({"folder_id": "null"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["uuid"] == user_project["uuid"]
Expand All @@ -353,7 +353,7 @@ async def test_project_listing_inside_of_private_folder(
# list new user specific folder
base_url = client.app.router["list_projects"].url_for()
url = base_url.with_query({"folder_id": f"{new_user_folder['folderId']}"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["uuid"] == user_project["uuid"]
Expand Down Expand Up @@ -448,14 +448,14 @@ async def test_folders_deletion(
# list subfolder projects
base_url = client.app.router["list_projects"].url_for()
url = base_url.with_query({"folder_id": f"{subfolder_2['folderId']}"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["uuid"] == user_project["uuid"]

# list root projects
base_url = client.app.router["list_projects"].url_for()
resp = await client.get(base_url)
resp = await client.get(f"{base_url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 0

Expand All @@ -474,13 +474,13 @@ async def test_folders_deletion(
await assert_status(resp, status.HTTP_204_NO_CONTENT)

fire_and_forget_tasks = client.app[APP_FIRE_AND_FORGET_TASKS_KEY]
t: asyncio.Task = list(fire_and_forget_tasks)[0]
t: asyncio.Task = next(iter(fire_and_forget_tasks))
assert t.get_name().startswith("fire_and_forget_task_delete_project_task_")
await t
assert len(client.app[APP_FIRE_AND_FORGET_TASKS_KEY]) == 0

# list root projects (The project should have been deleted)
base_url = client.app.router["list_projects"].url_for()
resp = await client.get(base_url)
resp = await client.get(f"{base_url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 0
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def test_workspaces_workflow(
url = client.app.router["get_workspace"].url_for(
workspace_id=f"{added_workspace['workspaceId']}"
)
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["name"] == "My first workspace"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def test_workspaces_full_workflow_with_folders_and_projects(
# List project in workspace
base_url = client.app.router["list_projects"].url_for()
url = base_url.with_query({"workspace_id": f"{added_workspace['workspaceId']}"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["uuid"] == project["uuid"]
Expand All @@ -88,7 +88,7 @@ async def test_workspaces_full_workflow_with_folders_and_projects(

# Get project in workspace
base_url = client.app.router["get_project"].url_for(project_id=project["uuid"])
resp = await client.get(base_url)
resp = await client.get(f"{base_url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert data["uuid"] == project["uuid"]
assert data["workspaceId"] == added_workspace["workspaceId"]
Expand All @@ -110,7 +110,7 @@ async def test_workspaces_full_workflow_with_folders_and_projects(
url = base_url.with_query(
{"workspace_id": f"{added_workspace['workspaceId']}", "folder_id": "null"}
)
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["folderId"] == first_folder["folderId"]
Expand All @@ -131,7 +131,7 @@ async def test_workspaces_full_workflow_with_folders_and_projects(
"folder_id": f"{first_folder['folderId']}",
}
)
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["uuid"] == project["uuid"]
Expand All @@ -142,7 +142,7 @@ async def test_workspaces_full_workflow_with_folders_and_projects(
# Try to list folder that user doesn't have access to
base_url = client.app.router["list_projects"].url_for()
url = base_url.with_query({"workspace_id": f"{added_workspace['workspaceId']}"})
resp = await client.get(url)
resp = await client.get(f"{url}")
_, errors = await assert_status(
resp,
status.HTTP_403_FORBIDDEN,
Expand All @@ -164,7 +164,7 @@ async def test_workspaces_full_workflow_with_folders_and_projects(
url = base_url.with_query(
{"workspace_id": f"{added_workspace['workspaceId']}", "folder_id": "null"}
)
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1

Expand All @@ -176,7 +176,7 @@ async def test_workspaces_full_workflow_with_folders_and_projects(
"folder_id": "none",
}
)
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 0

Expand All @@ -188,7 +188,7 @@ async def test_workspaces_full_workflow_with_folders_and_projects(
"folder_id": f"{first_folder['folderId']}",
}
)
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["uuid"] == project["uuid"]
Expand Down Expand Up @@ -230,7 +230,7 @@ async def test_workspaces_full_workflow_with_folders_and_projects(
url = base_url.with_query(
{"workspace_id": f"{added_workspace['workspaceId']}", "folder_id": "null"}
)
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 2

Expand Down Expand Up @@ -299,7 +299,7 @@ async def test_workspaces_delete_folders(
# List project in workspace
base_url = client.app.router["list_projects"].url_for()
url = base_url.with_query({"workspace_id": f"{added_workspace['workspaceId']}"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 2

Expand Down Expand Up @@ -362,6 +362,7 @@ async def test_workspaces_delete_folders(
# List project in workspace (The projects should have been deleted)
base_url = client.app.router["list_projects"].url_for()
url = base_url.with_query({"workspace_id": f"{added_workspace['workspaceId']}"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 0

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def test_workspaces__list_projects_full_search(
# List project with full search
base_url = client.app.router["list_projects_full_search"].url_for()
url = base_url.with_query({"text": "solution"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["uuid"] == project_1["uuid"]
Expand All @@ -104,7 +104,7 @@ async def test_workspaces__list_projects_full_search(
# List project with full search
base_url = client.app.router["list_projects_full_search"].url_for()
url = base_url.with_query({"text": "Orion"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["uuid"] == project_2["uuid"]
Expand Down Expand Up @@ -137,7 +137,7 @@ async def test_workspaces__list_projects_full_search(
# List project with full search
base_url = client.app.router["list_projects_full_search"].url_for()
url = base_url.with_query({"text": "Skyline"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["uuid"] == project_3["uuid"]
Expand All @@ -147,7 +147,7 @@ async def test_workspaces__list_projects_full_search(
# List project with full search (it should return data across all workspaces/folders)
base_url = client.app.router["list_projects_full_search"].url_for()
url = base_url.with_query({"text": "solution"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
sorted_data = sorted(data, key=lambda x: x["uuid"])
assert len(sorted_data) == 3
Expand Down Expand Up @@ -190,7 +190,7 @@ async def test__list_projects_full_search_with_query_parameters(
# Full search with text
base_url = client.app.router["list_projects_full_search"].url_for()
url = base_url.with_query({"text": "Orion"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["uuid"] == project["uuid"]
Expand All @@ -203,15 +203,15 @@ async def test__list_projects_full_search_with_query_parameters(
"order_by": json.dumps({"field": "uuid", "direction": "desc"}),
}
)
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["uuid"] == project["uuid"]

# Full search with tag_ids
base_url = client.app.router["list_projects_full_search"].url_for()
url = base_url.with_query({"text": "Orion", "tag_ids": "1,2"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 0

Expand All @@ -232,7 +232,7 @@ async def test__list_projects_full_search_with_query_parameters(
# Full search with tag_ids
base_url = client.app.router["list_projects_full_search"].url_for()
url = base_url.with_query({"text": "Orion", "tag_ids": f"{added_tag['id']}"})
resp = await client.get(url)
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert len(data) == 1
assert data[0]["uuid"] == project["uuid"]
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def test_moving_between_workspaces_user_role_permissions(
base_url = client.app.router["replace_project_workspace"].url_for(
project_id=fake_project["uuid"], workspace_id="null"
)
resp = await client.put(base_url)
resp = await client.put(f"{base_url}")
await assert_status(resp, expected.no_content)


Expand Down Expand Up @@ -98,33 +98,33 @@ async def test_moving_between_private_and_shared_workspaces(

# Get project in workspace
base_url = client.app.router["get_project"].url_for(project_id=project["uuid"])
resp = await client.get(base_url)
resp = await client.get(f"{base_url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert data["workspaceId"] == added_workspace["workspaceId"] # <-- Workspace ID

# Move project from workspace to your private workspace
base_url = client.app.router["replace_project_workspace"].url_for(
project_id=project["uuid"], workspace_id="null"
)
resp = await client.put(base_url)
resp = await client.put(f"{base_url}")
await assert_status(resp, status.HTTP_204_NO_CONTENT)

# Get project in workspace
base_url = client.app.router["get_project"].url_for(project_id=project["uuid"])
resp = await client.get(base_url)
resp = await client.get(f"{base_url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert data["workspaceId"] is None # <-- Workspace ID is None

# Move project from your private workspace to shared workspace
base_url = client.app.router["replace_project_workspace"].url_for(
project_id=project["uuid"], workspace_id=f"{added_workspace['workspaceId']}"
)
resp = await client.put(base_url)
resp = await client.put(f"{base_url}")
await assert_status(resp, status.HTTP_204_NO_CONTENT)

# Get project in workspace
base_url = client.app.router["get_project"].url_for(project_id=project["uuid"])
resp = await client.get(base_url)
resp = await client.get(f"{base_url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert data["workspaceId"] == added_workspace["workspaceId"] # <-- Workspace ID

Expand Down Expand Up @@ -177,20 +177,20 @@ async def test_moving_between_shared_and_shared_workspaces(

# Get project in workspace
base_url = client.app.router["get_project"].url_for(project_id=project["uuid"])
resp = await client.get(base_url)
resp = await client.get(f"{base_url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert data["workspaceId"] == added_workspace["workspaceId"] # <-- Workspace ID

# Move project from workspace to your private workspace
base_url = client.app.router["replace_project_workspace"].url_for(
project_id=project["uuid"], workspace_id=f"{second_workspace['workspaceId']}"
)
resp = await client.put(base_url)
resp = await client.put(f"{base_url}")
await assert_status(resp, status.HTTP_204_NO_CONTENT)

# Get project in workspace
base_url = client.app.router["get_project"].url_for(project_id=project["uuid"])
resp = await client.get(base_url)
resp = await client.get(f"{base_url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert data["workspaceId"] == second_workspace["workspaceId"] # <-- Workspace ID

Expand Down Expand Up @@ -257,20 +257,20 @@ async def test_moving_between_workspaces_check_removed_from_folder(

# Get project in workspace
base_url = client.app.router["get_project"].url_for(project_id=project["uuid"])
resp = await client.get(base_url)
resp = await client.get(f"{base_url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert data["workspaceId"] == added_workspace["workspaceId"] # <-- Workspace ID

# Move project from workspace to your private workspace
base_url = client.app.router["replace_project_workspace"].url_for(
project_id=project["uuid"], workspace_id="none"
)
resp = await client.put(base_url)
resp = await client.put(f"{base_url}")
await assert_status(resp, status.HTTP_204_NO_CONTENT)

# Get project in workspace
base_url = client.app.router["get_project"].url_for(project_id=project["uuid"])
resp = await client.get(base_url)
resp = await client.get(f"{base_url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert data["workspaceId"] is None # <-- Workspace ID is None

Expand Down
2 changes: 1 addition & 1 deletion services/web/server/tests/unit/with_dbs/02/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ async def _assert_it(
) -> dict:
# GET /v0/projects/{project_id} with a project owned by user
url = client.app.router["get_project"].url_for(project_id=project["uuid"])
resp = await client.get(url)
resp = await client.get(f"{url}")
data, error = await assert_status(resp, expected)

if not error:
Expand Down
Loading

0 comments on commit 9001bd5

Please sign in to comment.