🐛 fix(conftest.py): import missing Flow model in tests/conftest.py to fix NameError

✨ feat(conftest.py): add fixture 'flow' to create a test flow in tests/conftest.py
🐛 fix(test_endpoints.py): import missing get_settings_manager function in tests/test_endpoints.py to fix NameError
✨ feat(test_endpoints.py): add test case 'test_process_flow_without_autologin' to test flow processing without auto login
🐛 fix(test_endpoints.py): fix incorrect endpoint URL in test case 'test_process_flow_without_autologin' in tests/test_endpoints.py
✨ feat(test_endpoints.py): add test case 'test_process_flow_fails_autologin_off' to test flow processing failure when auto login is off
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-26 17:38:21 -03:00
commit ed06c3b4d9
2 changed files with 68 additions and 14 deletions

View file

@ -6,6 +6,7 @@ from langflow.api.v1.flows import get_session
from langflow.graph.graph.base import Graph
from langflow.services.auth.utils import get_password_hash
from langflow.services.database.models.flow.flow import Flow
from langflow.services.database.models.user.user import User, UserCreate
import pytest
from fastapi.testclient import TestClient
@ -192,3 +193,18 @@ def logged_in_headers(client, active_user):
tokens = response.json()
a_token = tokens["access_token"]
return {"Authorization": f"Bearer {a_token}"}
@pytest.fixture
def flow(client, json_flow: str, session, active_user):
from langflow.services.database.models.flow.flow import FlowCreate
loaded_json = json.loads(json_flow)
flow_data = FlowCreate(
name="test_flow", data=loaded_json.get("data"), user_id=active_user.id
)
flow = Flow(**flow_data.dict())
session.add(flow)
session.commit()
return flow