test: add unit tests for routes (#4249)

This commit is contained in:
Ítalo Johnny 2024-10-28 17:06:05 -03:00 • committed by GitHub
commit fadb20115d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 623 additions and 272 deletions

View file

@ -2,14 +2,14 @@ from uuid import uuid4
import pytest
from fastapi import status
from fastapi.testclient import TestClient
from httpx import AsyncClient
from langflow.graph.schema import RunOutputs
from langflow.initial_setup.setup import load_starter_projects
from langflow.load import run_flow_from_json
@pytest.mark.api_key_required
async def test_run_flow_with_caching_success(client: TestClient, starter_project, created_api_key):
async def test_run_flow_with_caching_success(client: AsyncClient, starter_project, created_api_key):
flow_id = starter_project["id"]
headers = {"x-api-key": created_api_key.api_key}
payload = {
@ -27,7 +27,7 @@ async def test_run_flow_with_caching_success(client: TestClient, starter_project
@pytest.mark.api_key_required
async def test_run_flow_with_caching_invalid_flow_id(client: TestClient, created_api_key):
async def test_run_flow_with_caching_invalid_flow_id(client: AsyncClient, created_api_key):
invalid_flow_id = uuid4()
headers = {"x-api-key": created_api_key.api_key}
payload = {"input_value": "", "input_type": "text", "output_type": "text", "tweaks": {}, "stream": False}
@ -39,7 +39,7 @@ async def test_run_flow_with_caching_invalid_flow_id(client: TestClient, created
@pytest.mark.api_key_required
async def test_run_flow_with_caching_invalid_input_format(client: TestClient, starter_project, created_api_key):
async def test_run_flow_with_caching_invalid_input_format(client: AsyncClient, starter_project, created_api_key):
flow_id = starter_project["id"]
headers = {"x-api-key": created_api_key.api_key}
payload = {"input_value": {"key": "value"}, "input_type": "text", "output_type": "text", "tweaks": {}}