feat: new tests for endpoints
This commit is contained in:
parent
d93ecee876
commit
287ef0d4e4
3 changed files with 36 additions and 2 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from pathlib import Path
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
def pytest_configure():
|
||||
|
|
@ -9,3 +10,14 @@ def pytest_configure():
|
|||
pytest.COMPLEX_EXAMPLE_PATH = (
|
||||
Path(__file__).parent.absolute() / "data" / "complex_example.json"
|
||||
)
|
||||
|
||||
|
||||
# Create client fixture for FastAPI
|
||||
@pytest.fixture(scope="module")
|
||||
def client():
|
||||
from langflow.main import create_app
|
||||
|
||||
app = create_app()
|
||||
|
||||
with TestClient(app) as client:
|
||||
yield client
|
||||
|
|
|
|||
22
tests/test_endpoints.py
Normal file
22
tests/test_endpoints.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# # build router
|
||||
# router = APIRouter()
|
||||
|
||||
|
||||
# @router.get("/all")
|
||||
# def get_all():
|
||||
# return build_langchain_types_dict()
|
||||
|
||||
|
||||
# Buil test for /all endpoint
|
||||
from langflow.utils.constants import CUSTOM_TOOLS
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
|
||||
def test_get_all(client: TestClient):
|
||||
response = client.get("/all")
|
||||
assert response.status_code == 200
|
||||
json_response = response.json()
|
||||
# We need to test the custom nodes
|
||||
assert "ZeroShotPrompt" in json_response["prompts"]
|
||||
# All CUSTOM_TOOLS(dict) should be in the response
|
||||
assert all(tool in json_response["tools"] for tool in CUSTOM_TOOLS.keys())
|
||||
|
|
@ -262,7 +262,7 @@ def test_build():
|
|||
# # and use the output of that build as the value for the param
|
||||
# # if the value is not a node, then we use the value as the param
|
||||
# # and continue
|
||||
# # Another aspect is that the module_type is the class that we need to import
|
||||
# # Another aspect is that the node_type is the class that we need to import
|
||||
# # and instantiate with these built params
|
||||
|
||||
# # Build each node in the params dict
|
||||
|
|
@ -273,7 +273,7 @@ def test_build():
|
|||
# # Get the class from LANGCHAIN_TYPES_DICT
|
||||
# # and instantiate it with the params
|
||||
# # and return the instance
|
||||
# return LANGCHAIN_TYPES_DICT[self.module_type](**self.params)
|
||||
# return LANGCHAIN_TYPES_DICT[self.node_type](**self.params)
|
||||
graph = get_graph()
|
||||
assert isinstance(graph, Graph)
|
||||
# Now we test the build method
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue