feat: Add MCP Server Settings to projects, rename Folder to Project (#7741)
Co-authored-by: Lucas Oliveira <lucas.edu.oli@hotmail.com> Co-authored-by: deon-sanchez <deon.sanchez@datastax.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Co-authored-by: Eric Hare <ericrhare@gmail.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org> Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com> Co-authored-by: phact <estevezsebastian@gmail.com>
This commit is contained in:
parent
1360e56f28
commit
c80cb3f35e
95 changed files with 4434 additions and 804 deletions
89
src/backend/tests/unit/api/v1/test_projects.py
Normal file
89
src/backend/tests/unit/api/v1/test_projects.py
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
import pytest
|
||||
from fastapi import status
|
||||
from httpx import AsyncClient
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def basic_case():
|
||||
return {
|
||||
"name": "New Project",
|
||||
"description": "",
|
||||
"flows_list": [],
|
||||
"components_list": [],
|
||||
}
|
||||
|
||||
|
||||
async def test_create_project(client: AsyncClient, logged_in_headers, basic_case):
|
||||
response = await client.post("api/v1/projects/", json=basic_case, headers=logged_in_headers)
|
||||
result = response.json()
|
||||
|
||||
assert response.status_code == status.HTTP_201_CREATED
|
||||
assert isinstance(result, dict), "The result must be a dictionary"
|
||||
assert "name" in result, "The dictionary must contain a key called 'name'"
|
||||
assert "description" in result, "The dictionary must contain a key called 'description'"
|
||||
assert "id" in result, "The dictionary must contain a key called 'id'"
|
||||
assert "parent_id" in result, "The dictionary must contain a key called 'parent_id'"
|
||||
|
||||
|
||||
async def test_read_projects(client: AsyncClient, logged_in_headers):
|
||||
response = await client.get("api/v1/projects/", headers=logged_in_headers)
|
||||
result = response.json()
|
||||
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert isinstance(result, list), "The result must be a list"
|
||||
assert len(result) > 0, "The list must not be empty"
|
||||
|
||||
|
||||
async def test_read_project(client: AsyncClient, logged_in_headers, basic_case):
|
||||
# Create a project first
|
||||
response_ = await client.post("api/v1/projects/", json=basic_case, headers=logged_in_headers)
|
||||
id_ = response_.json()["id"]
|
||||
|
||||
# Get the project
|
||||
response = await client.get(f"api/v1/projects/{id_}", headers=logged_in_headers)
|
||||
result = response.json()
|
||||
|
||||
# The response structure may be different depending on whether pagination is enabled
|
||||
if isinstance(result, dict) and "folder" in result:
|
||||
# Handle paginated project response
|
||||
folder_data = result["folder"]
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert isinstance(folder_data, dict), "The folder data must be a dictionary"
|
||||
assert "name" in folder_data, "The dictionary must contain a key called 'name'"
|
||||
assert "description" in folder_data, "The dictionary must contain a key called 'description'"
|
||||
assert "id" in folder_data, "The dictionary must contain a key called 'id'"
|
||||
elif isinstance(result, dict) and "project" in result:
|
||||
# Handle paginated project response
|
||||
project_data = result["project"]
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert isinstance(project_data, dict), "The project data must be a dictionary"
|
||||
assert "name" in project_data, "The dictionary must contain a key called 'name'"
|
||||
assert "description" in project_data, "The dictionary must contain a key called 'description'"
|
||||
assert "id" in project_data, "The dictionary must contain a key called 'id'"
|
||||
else:
|
||||
# Handle direct project response
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert isinstance(result, dict), "The result must be a dictionary"
|
||||
assert "name" in result, "The dictionary must contain a key called 'name'"
|
||||
assert "description" in result, "The dictionary must contain a key called 'description'"
|
||||
assert "id" in result, "The dictionary must contain a key called 'id'"
|
||||
|
||||
|
||||
async def test_update_project(client: AsyncClient, logged_in_headers, basic_case):
|
||||
update_case = basic_case.copy()
|
||||
update_case["name"] = "Updated Project"
|
||||
|
||||
# Create a project first
|
||||
response_ = await client.post("api/v1/projects/", json=basic_case, headers=logged_in_headers)
|
||||
id_ = response_.json()["id"]
|
||||
|
||||
# Update the project
|
||||
response = await client.patch(f"api/v1/projects/{id_}", json=update_case, headers=logged_in_headers)
|
||||
result = response.json()
|
||||
|
||||
assert response.status_code == status.HTTP_200_OK
|
||||
assert isinstance(result, dict), "The result must be a dictionary"
|
||||
assert "name" in result, "The dictionary must contain a key called 'name'"
|
||||
assert "description" in result, "The dictionary must contain a key called 'description'"
|
||||
assert "id" in result, "The dictionary must contain a key called 'id'"
|
||||
assert "parent_id" in result, "The dictionary must contain a key called 'parent_id'"
|
||||
Loading…
Add table
Add a link
Reference in a new issue