Formatting
This commit is contained in:
parent
fd7da8720f
commit
39434eadc4
58 changed files with 630 additions and 1027 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import pytest
|
||||
|
||||
from langflow.services.database.models.api_key import ApiKeyCreate
|
||||
|
||||
|
||||
|
|
@ -21,7 +22,6 @@ def test_get_api_keys(client, logged_in_headers, api_key):
|
|||
assert any("test-api-key" in api_key["name"] for api_key in data["api_keys"])
|
||||
# assert all api keys in data["api_keys"] are masked
|
||||
assert all("**" in api_key["api_key"] for api_key in data["api_keys"])
|
||||
# Add more assertions as needed based on the expected data structure and content
|
||||
|
||||
|
||||
def test_create_api_key(client, logged_in_headers):
|
||||
|
|
|
|||
|
|
@ -38,9 +38,7 @@ def test_create_or_update_starter_projects(client):
|
|||
num_projects = len(load_starter_projects())
|
||||
|
||||
# Get the number of projects in the database
|
||||
num_db_projects = session.exec(
|
||||
select(func.count(Flow.id)).where(Flow.folder == STARTER_FOLDER_NAME)
|
||||
).one()
|
||||
num_db_projects = session.exec(select(func.count(Flow.id)).where(Flow.folder == STARTER_FOLDER_NAME)).one()
|
||||
|
||||
# Check that the number of projects in the database is the same as the number of projects returned by load_starter_projects
|
||||
assert num_db_projects == num_projects
|
||||
|
|
@ -56,21 +54,16 @@ async def test_starter_project_can_run_successfully(client):
|
|||
num_projects = len(load_starter_projects())
|
||||
|
||||
# Get the number of projects in the database
|
||||
num_db_projects = session.exec(
|
||||
select(func.count(Flow.id)).where(Flow.folder == STARTER_FOLDER_NAME)
|
||||
).one()
|
||||
num_db_projects = session.exec(select(func.count(Flow.id)).where(Flow.folder == STARTER_FOLDER_NAME)).one()
|
||||
|
||||
# Check that the number of projects in the database is the same as the number of projects returned by load_starter_projects
|
||||
assert num_db_projects == num_projects
|
||||
|
||||
# Get all the starter projects
|
||||
projects = session.exec(
|
||||
select(Flow).where(Flow.folder == STARTER_FOLDER_NAME)
|
||||
).all()
|
||||
projects = session.exec(select(Flow).where(Flow.folder == STARTER_FOLDER_NAME)).all()
|
||||
|
||||
graphs: list[Graph] = [
|
||||
(project.name, Graph.from_payload(project.data, flow_id=project.id))
|
||||
for project in projects
|
||||
(project.name, Graph.from_payload(project.data, flow_id=project.id)) for project in projects
|
||||
]
|
||||
assert len(graphs) == len(projects)
|
||||
for name, graph in graphs:
|
||||
|
|
|
|||
|
|
@ -268,13 +268,9 @@ async def test_load_langchain_object_with_cached_session(client, basic_graph_dat
|
|||
# Provide a non-existent session_id
|
||||
session_service = get_session_service()
|
||||
session_id1 = "non-existent-session-id"
|
||||
graph1, artifacts1 = await session_service.load_session(
|
||||
session_id1, basic_graph_data
|
||||
)
|
||||
graph1, artifacts1 = await session_service.load_session(session_id1, basic_graph_data)
|
||||
# Use the new session_id to get the langchain_object again
|
||||
graph2, artifacts2 = await session_service.load_session(
|
||||
session_id1, basic_graph_data
|
||||
)
|
||||
graph2, artifacts2 = await session_service.load_session(session_id1, basic_graph_data)
|
||||
|
||||
assert graph1 == graph2
|
||||
assert artifacts1 == artifacts2
|
||||
|
|
@ -286,15 +282,11 @@ async def test_load_langchain_object_with_no_cached_session(client, basic_graph_
|
|||
session_service = get_session_service()
|
||||
session_id1 = "non-existent-session-id"
|
||||
session_id = session_service.build_key(session_id1, basic_graph_data)
|
||||
graph1, artifacts1 = await session_service.load_session(
|
||||
session_id, basic_graph_data
|
||||
)
|
||||
graph1, artifacts1 = await session_service.load_session(session_id, basic_graph_data)
|
||||
# Clear the cache
|
||||
session_service.clear_session(session_id)
|
||||
# Use the new session_id to get the langchain_object again
|
||||
graph2, artifacts2 = await session_service.load_session(
|
||||
session_id, basic_graph_data
|
||||
)
|
||||
graph2, artifacts2 = await session_service.load_session(session_id, basic_graph_data)
|
||||
|
||||
assert id(graph1) != id(graph2)
|
||||
# Since the cache was cleared, objects should be different
|
||||
|
|
@ -305,12 +297,8 @@ async def test_load_langchain_object_without_session_id(client, basic_graph_data
|
|||
# Provide a non-existent session_id
|
||||
session_service = get_session_service()
|
||||
session_id1 = None
|
||||
graph1, artifacts1 = await session_service.load_session(
|
||||
session_id1, basic_graph_data
|
||||
)
|
||||
graph1, artifacts1 = await session_service.load_session(session_id1, basic_graph_data)
|
||||
# Use the new session_id to get the langchain_object again
|
||||
graph2, artifacts2 = await session_service.load_session(
|
||||
session_id1, basic_graph_data
|
||||
)
|
||||
graph2, artifacts2 = await session_service.load_session(session_id1, basic_graph_data)
|
||||
|
||||
assert graph1 == graph2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue