Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add fixtures for client in test files to speed them up #3490

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions src/backend/tests/unit/test_cache.py

This file was deleted.

6 changes: 6 additions & 0 deletions src/backend/tests/unit/test_data_class.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import pytest
from langchain_core.documents import Document

from langflow.schema import Data


@pytest.fixture
def client():
pass


def test_data_initialization():
record = Data(text_key="msg", data={"msg": "Hello, World!", "extra": "value"})
assert record.msg == "Hello, World!"
Expand Down
6 changes: 6 additions & 0 deletions src/backend/tests/unit/test_experimental_components.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from langflow.components import prototypes
import pytest


@pytest.fixture
def client():
pass


def test_python_function_component():
Expand Down
5 changes: 5 additions & 0 deletions src/backend/tests/unit/test_frontend_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
from langflow.template.template.base import Template


@pytest.fixture
def client():
pass


@pytest.fixture
def sample_template_field() -> Input:
return Input(name="test_field", field_type="str")
Expand Down
7 changes: 7 additions & 0 deletions src/backend/tests/unit/test_helper_components.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from langflow.components import helpers
from langflow.custom.utils import build_custom_component_template
from langflow.schema import Data
import pytest


@pytest.fixture
def client():
pass


# def test_update_data_component():
# # Arrange
Expand Down
8 changes: 5 additions & 3 deletions src/backend/tests/unit/test_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
from langflow.load import load_flow_from_json


@pytest.mark.noclient
@pytest.fixture
def client():
pass


def test_load_flow_from_json():
"""Test loading a flow from a json file"""
loaded = load_flow_from_json(pytest.BASIC_EXAMPLE_PATH)
assert loaded is not None
assert isinstance(loaded, Graph)


@pytest.mark.noclient
def test_load_flow_from_json_with_tweaks():
"""Test loading a flow from a json file and applying tweaks"""
tweaks = {"dndnode_82": {"model_name": "gpt-3.5-turbo-16k-0613"}}
Expand All @@ -22,7 +25,6 @@ def test_load_flow_from_json_with_tweaks():
assert isinstance(loaded, Graph)


@pytest.mark.noclient
def test_load_flow_from_json_object():
"""Test loading a flow from a json file and applying tweaks"""
_, projects = zip(*load_starter_projects())
Expand Down
5 changes: 5 additions & 0 deletions src/backend/tests/unit/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
from langflow.logging.logger import SizedLogBuffer


@pytest.fixture
def client():
pass


@pytest.fixture
def sized_log_buffer():
return SizedLogBuffer()
Expand Down
5 changes: 5 additions & 0 deletions src/backend/tests/unit/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
from pydantic import BaseModel


@pytest.fixture
def client():
pass


# Dummy classes for testing purposes
class Parent(BaseModel):
"""Parent Class"""
Expand Down
5 changes: 5 additions & 0 deletions src/backend/tests/unit/test_validate_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
from langflow.utils.validate import create_function, execute_function, extract_function_name, validate_code


@pytest.fixture
def client():
pass


def test_create_function():
code = """
from pathlib import Path
Expand Down