diff --git a/src/backend/langflow/api/v1/flows.py b/src/backend/langflow/api/v1/flows.py index c3f894732..5e4dde4e0 100644 --- a/src/backend/langflow/api/v1/flows.py +++ b/src/backend/langflow/api/v1/flows.py @@ -1,6 +1,10 @@ from typing import List from uuid import UUID + +import orjson +from fastapi import APIRouter, Depends, File, HTTPException, UploadFile from fastapi.encoders import jsonable_encoder +from sqlmodel import Session from langflow.api.utils import remove_api_keys from langflow.api.v1.schemas import FlowListCreate, FlowListRead @@ -12,13 +16,7 @@ from langflow.services.database.models.flow import ( FlowUpdate, ) from langflow.services.database.models.user.user import User -from langflow.services.deps import get_session -from langflow.services.deps import get_settings_service -import orjson -from sqlmodel import Session -from fastapi import APIRouter, Depends, HTTPException - -from fastapi import File, UploadFile +from langflow.services.deps import get_session, get_settings_service # build router router = APIRouter(prefix="/flows", tags=["Flows"]) @@ -163,5 +161,5 @@ async def download_file( current_user: User = Depends(get_current_active_user), ): """Download all flows as a file.""" - flows = read_flows(session=session, current_user=current_user) + flows = read_flows(current_user=current_user) return FlowListRead(flows=flows) diff --git a/tests/test_database.py b/tests/test_database.py index abbe20c81..369e2a0f6 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -182,7 +182,7 @@ def test_download_file( with session_getter(db_manager) as session: for flow in flow_list.flows: flow.user_id = active_user.id - db_flow = Flow.from_orm(flow) + db_flow = Flow.model_validate(flow) session.add(db_flow) session.commit() # Make request to endpoint diff --git a/tests/test_llms_template.py b/tests/test_llms_template.py index 78131cb05..e66c8c650 100644 --- a/tests/test_llms_template.py +++ b/tests/test_llms_template.py @@ -243,7 +243,7 @@ def test_openai(client: TestClient, logged_in_headers): "placeholder": "", "show": False, "multiline": False, - "value": 6, + "value": 2, "password": False, "name": "max_retries", "type": "int", @@ -385,7 +385,7 @@ def test_chat_open_ai(client: TestClient, logged_in_headers): "placeholder": "", "show": False, "multiline": False, - "value": 6, + "value": 2, "password": False, "name": "max_retries", "type": "int", diff --git a/tests/test_store.py b/tests/test_store.py deleted file mode 100644 index d139537fa..000000000 --- a/tests/test_store.py +++ /dev/null @@ -1,57 +0,0 @@ -# FILEPATH: /Users/ogabrielluiz/Projects/langflow2/tests/test_store_service.py - -from datetime import datetime -from unittest.mock import Mock, patch - -from langflow.services.deps import get_store_service - - -@patch("langflow.services.store.service.httpx") -def test_search_components(mock_httpx: Mock, client): - # Mock the response from the HTTP GET request - from langflow.services.store.schema import CreateComponentResponse - - mock_response = Mock() - mock_response.json.return_value = { - "data": [ - { - "id": "1", - "name": "Test Component 1", - "description": "This is a test component.", - "tags": ["test"], - "status": "published", - "date_updated": datetime.now().isoformat(), - "is_component": False, - }, - { - "id": "2", - "name": "Test Component 2", - "description": "This is another test component.", - "tags": ["test"], - "status": "published", - "date_updated": datetime.now().isoformat(), - "is_component": True, - }, - ] - } - mock_httpx.get.return_value = mock_response - - # Create an instance of the StoreService class and call the search method - store_service = get_store_service() - components = store_service.search(api_key=None, query="test", limit=5) - - # Assert that the HTTP GET request was made with the correct parameters - mock_httpx.get.assert_called_once_with( - store_service.components_url, - headers={}, - params={ - "filter[name][_like]": "test", - "page": 1, - "limit": 5, - "sort": "count(liked_by)", - }, - ) - - # Assert that the search method returns a list of ComponentResponse objects - assert len(components) == 2 - assert all(isinstance(component, CreateComponentResponse) for component in components)