feat: Refactor delete_multiple_flows endpoint to use DELETE method (#2029)
* feat: Refactor delete_multiple_flows endpoint to use DELETE method
The code changes modify the `delete_multiple_flows` endpoint in the `flows.py` file. The endpoint was previously using the `POST` method, but it has been refactored to use the `DELETE` method instead. This change aligns with RESTful API conventions and improves the clarity and consistency of the codebase.
Note: The commit message has been generated based on the provided code changes and recent commits.
* Refactor delete_multiple_flows endpoint to use DELETE method
* Refactor delete_multiple_flows endpoint to use DELETE method
* ♻️ (index.ts): refactor deleteBatch function to use data field instead of params for batch deletion
---------
Co-authored-by: cristhianzl <cristhian.lousa@gmail.com>
This commit is contained in:
parent
491e3698f6
commit
7bfc1a55c8
4 changed files with 80 additions and 41 deletions
|
|
@ -1,5 +1,3 @@
|
|||
import os
|
||||
from typing import Optional, List
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
import orjson
|
||||
|
|
@ -13,7 +11,6 @@ from langflow.services.database.models.base import orjson_dumps
|
|||
from langflow.services.database.models.flow import Flow, FlowCreate, FlowUpdate
|
||||
from langflow.services.database.utils import session_getter
|
||||
from langflow.services.deps import get_db_service
|
||||
from langflow.services.settings.base import Settings
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
|
@ -113,6 +110,21 @@ def test_delete_flow(client: TestClient, json_flow: str, active_user, logged_in_
|
|||
assert response.json()["message"] == "Flow deleted successfully"
|
||||
|
||||
|
||||
def test_delete_flows(client: TestClient, json_flow: str, active_user, logged_in_headers):
|
||||
# Create ten flows
|
||||
number_of_flows = 10
|
||||
flows = [FlowCreate(name=f"Flow {i}", description="description", data={}) for i in range(number_of_flows)]
|
||||
flow_ids = []
|
||||
for flow in flows:
|
||||
response = client.post("api/v1/flows/", json=flow.model_dump(), headers=logged_in_headers)
|
||||
assert response.status_code == 201
|
||||
flow_ids.append(response.json()["id"])
|
||||
|
||||
response = client.request("DELETE", "api/v1/flows/", headers=logged_in_headers, json=flow_ids)
|
||||
assert response.status_code == 200, response.content
|
||||
assert response.json().get("deleted") == number_of_flows
|
||||
|
||||
|
||||
def test_create_flows(client: TestClient, session: Session, json_flow: str, logged_in_headers):
|
||||
flow = orjson.loads(json_flow)
|
||||
data = flow["data"]
|
||||
|
|
@ -263,5 +275,3 @@ def test_load_flows(client: TestClient, load_flows_dir):
|
|||
response = client.get("api/v1/flows/c54f9130-f2fa-4a3e-b22a-3856d946351b")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["name"] == "BasicExample"
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue