🐛 fix(flows.py): remove unused imports and fix function call to read_flows
🐛 fix(test_database.py): fix function call to Flow.model_validate 🐛 fix(test_llms_template.py): fix values in test cases 🔥 chore(test_store.py): remove unused test file and test case
This commit is contained in:
parent
62e470b03b
commit
c6dfb90bcf
4 changed files with 9 additions and 68 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue