ref: Remove autouse from pytest client fixture (#4158)
Remove autouse from pytest client fixture
This commit is contained in:
parent
2be7c56939
commit
047077cee4
41 changed files with 17 additions and 190 deletions
|
|
@ -273,7 +273,7 @@ def json_memory_chatbot_no_llm():
|
|||
return pytest.MEMORY_CHATBOT_NO_LLM.read_text()
|
||||
|
||||
|
||||
@pytest.fixture(name="client", autouse=True)
|
||||
@pytest.fixture(name="client")
|
||||
async def client_fixture(session: Session, monkeypatch, request, load_flows_dir):
|
||||
# Set the database url to a test database
|
||||
if "noclient" in request.keywords:
|
||||
|
|
|
|||
6
src/backend/tests/integration/conftest.py
Normal file
6
src/backend/tests/integration/conftest.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _start_app(client):
|
||||
pass
|
||||
|
|
@ -12,11 +12,6 @@ from langflow.schema.message import Message
|
|||
from langflow.services.settings.feature_flags import FEATURE_FLAGS
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def add_toolkit_output():
|
||||
FEATURE_FLAGS.add_toolkit_output = True
|
||||
|
|
@ -87,7 +82,7 @@ def test_component_tool():
|
|||
|
||||
|
||||
@pytest.mark.api_key_required
|
||||
@pytest.mark.usefixtures("add_toolkit_output")
|
||||
@pytest.mark.usefixtures("add_toolkit_output", "client")
|
||||
def test_component_tool_with_api_key():
|
||||
chat_output = ChatOutput()
|
||||
openai_llm = OpenAIModelComponent()
|
||||
|
|
|
|||
|
|
@ -7,11 +7,6 @@ from langchain_community.chat_models.ollama import ChatOllama
|
|||
from langflow.components.models.OllamaModel import ChatOllamaComponent
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def component():
|
||||
return ChatOllamaComponent()
|
||||
|
|
|
|||
|
|
@ -1,13 +1,6 @@
|
|||
import pytest
|
||||
|
||||
from langflow.components.prompts.Prompt import PromptComponent # type: ignore
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
class TestPromptComponent:
|
||||
def test_post_code_processing(self):
|
||||
component = PromptComponent(template="Hello {name}!", name="John")
|
||||
|
|
|
|||
|
|
@ -1,15 +1,8 @@
|
|||
import pytest
|
||||
|
||||
from langflow.components.tools.PythonREPLTool import PythonREPLToolComponent
|
||||
from langflow.custom.custom_component.component import Component
|
||||
from langflow.custom.utils import build_custom_component_template
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
def test_python_repl_tool_template():
|
||||
python_repl_tool = PythonREPLToolComponent()
|
||||
component = Component(_code=python_repl_tool._code)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,8 @@
|
|||
import pytest
|
||||
|
||||
from langflow.components.tools.YfinanceTool import YfinanceToolComponent
|
||||
from langflow.custom.custom_component.component import Component
|
||||
from langflow.custom.utils import build_custom_component_template
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
def test_yfinance_tool_template():
|
||||
yf_tool = YfinanceToolComponent()
|
||||
component = Component(_code=yf_tool._code)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,9 @@
|
|||
from collections.abc import Callable
|
||||
|
||||
import pytest
|
||||
|
||||
from langflow.components.inputs.ChatInput import ChatInput
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
def test_component_to_toolkit():
|
||||
chat_input = ChatInput()
|
||||
tools = chat_input.to_toolkit()
|
||||
|
|
|
|||
|
|
@ -9,11 +9,6 @@ from langflow.components.outputs import ChatOutput
|
|||
from langflow.template.field.base import Output
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
def test_set_invalid_output():
|
||||
chatinput = ChatInput()
|
||||
chatoutput = ChatOutput()
|
||||
|
|
|
|||
|
|
@ -9,11 +9,6 @@ from langflow.events.event_manager import EventManager
|
|||
from langflow.schema.log import LoggableType
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
class TestEventManager:
|
||||
# Registering an event with a valid name and callback using a mock callback function
|
||||
def test_register_event_with_valid_name_and_callback_with_mock_callback(self):
|
||||
|
|
|
|||
|
|
@ -7,11 +7,7 @@ from langflow.components.prompts.Prompt import PromptComponent
|
|||
from langflow.graph.graph.base import Graph
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("client")
|
||||
def test_edge_raises_error_on_invalid_target_handle():
|
||||
template = """Answer the user as if you were a pirate.
|
||||
|
||||
|
|
|
|||
|
|
@ -9,11 +9,6 @@ from langflow.graph.state.model import create_state_model
|
|||
from langflow.template.field.base import UNDEFINED
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def chat_input_component():
|
||||
return ChatInput()
|
||||
|
|
|
|||
|
|
@ -13,11 +13,6 @@ from langflow.graph.graph.base import Graph
|
|||
from langflow.graph.graph.constants import Finish
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_graph_not_prepared():
|
||||
chat_input = ChatInput()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from langflow.components.outputs.ChatOutput import ChatOutput
|
||||
from langflow.custom.custom_component.component import Component
|
||||
|
|
@ -11,11 +10,6 @@ from langflow.schema.message import Message
|
|||
from langflow.template.field.base import Output
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
class LogComponent(Component):
|
||||
name = "LogComponent"
|
||||
inputs = [IntInput(name="times", value=1)]
|
||||
|
|
|
|||
|
|
@ -15,11 +15,6 @@ from langflow.io import MessageTextInput, Output
|
|||
from langflow.schema.message import Message
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
class Concatenate(Component):
|
||||
display_name = "Concatenate"
|
||||
description = "Concatenates two strings"
|
||||
|
|
|
|||
|
|
@ -11,11 +11,6 @@ from langflow.graph.graph.constants import Finish
|
|||
from langflow.graph.graph.state_model import create_state_model_from_graph
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
def test_graph_state_model():
|
||||
session_id = "test_session_id"
|
||||
template = """{context}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,6 @@ import pytest
|
|||
from langflow.graph.graph.runnable_vertices_manager import RunnableVerticesManager
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def data():
|
||||
run_map: defaultdict(list) = {"A": ["B", "C"], "B": ["D"], "C": ["D"], "D": []}
|
||||
|
|
|
|||
|
|
@ -5,11 +5,6 @@ import pytest
|
|||
from langflow.graph.graph import utils
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def graph():
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -22,11 +22,6 @@ from langflow.initial_setup.setup import load_starter_projects
|
|||
# BASIC_EXAMPLE_PATH, COMPLEX_EXAMPLE_PATH, OPENAPI_EXAMPLE_PATH
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_template():
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -17,11 +17,6 @@ from langflow.graph.graph.constants import Finish
|
|||
from langflow.schema.data import Data
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ingestion_graph():
|
||||
# Ingestion Graph
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@ from langflow.inputs.utils import instantiate_input
|
|||
from langflow.schema.message import Message
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
def test_table_input_valid():
|
||||
data = TableInput(name="valid_table", value=[{"key": "value"}, {"key2": "value2"}])
|
||||
assert data.value == [{"key": "value"}, {"key2": "value2"}]
|
||||
|
|
|
|||
|
|
@ -6,11 +6,6 @@ from pydantic.fields import FieldInfo
|
|||
from langflow.components.inputs.ChatInput import ChatInput
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
def test_create_input_schema():
|
||||
from langflow.io.schema import create_input_schema
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,6 @@ import pytest
|
|||
from langflow.schema.table import Column, FormatterType
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
class TestColumn:
|
||||
# Creating a Column instance without display_name sets it to the name
|
||||
def test_create_column_without_display_name(self):
|
||||
|
|
|
|||
|
|
@ -4,11 +4,6 @@ from langchain_core.prompts.chat import ChatPromptTemplate
|
|||
from langflow.schema.message import Message
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_message_async_prompt_serialization():
|
||||
template = "Hello, {name}!"
|
||||
|
|
|
|||
|
|
@ -11,11 +11,6 @@ from langflow.services.variable.constants import CREDENTIAL_TYPE, GENERIC_TYPE
|
|||
from langflow.services.variable.service import DatabaseVariableService
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def service():
|
||||
settings_service = get_settings_service()
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ def default_settings():
|
|||
]
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("client")
|
||||
def test_components_path(runner, default_settings, tmp_path):
|
||||
# create a "components" folder
|
||||
temp_dir = tmp_path / "components"
|
||||
|
|
|
|||
|
|
@ -12,11 +12,6 @@ from langflow.custom.custom_component.base_component import BaseComponent, Compo
|
|||
from langflow.custom.utils import build_custom_component_template
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def code_component_with_multiple_outputs():
|
||||
code = Path("src/backend/tests/data/component_multiple_outputs.py").read_text()
|
||||
|
|
|
|||
|
|
@ -4,11 +4,6 @@ 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!"
|
||||
|
|
|
|||
|
|
@ -10,11 +10,6 @@ from httpx import Response
|
|||
from langflow.components import data
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def api_request():
|
||||
# This fixture provides an instance of APIRequest for each test case
|
||||
|
|
|
|||
|
|
@ -1,10 +1,4 @@
|
|||
from langflow.components import prototypes
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
def test_python_function_component():
|
||||
|
|
|
|||
|
|
@ -5,11 +5,6 @@ from langflow.template.frontend_node.base import FrontendNode
|
|||
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")
|
||||
|
|
|
|||
|
|
@ -4,12 +4,6 @@ from langflow.components import helpers
|
|||
from langflow.custom.utils import build_custom_component_template
|
||||
from langflow.schema import Data
|
||||
from langflow.schema.message import Message
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
# def test_update_data_component():
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ def test_get_project_data():
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.usefixtures("client")
|
||||
async def test_create_or_update_starter_projects():
|
||||
with session_scope() as session:
|
||||
# Get the number of projects returned by load_starter_projects
|
||||
|
|
|
|||
|
|
@ -1,15 +1,8 @@
|
|||
import pytest
|
||||
|
||||
from langflow.graph import Graph
|
||||
from langflow.initial_setup.setup import load_starter_projects
|
||||
from langflow.load import load_flow_from_json
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
# TODO: UPDATE BASIC EXAMPLE
|
||||
# def test_load_flow_from_json():
|
||||
# """Test loading a flow from a json file"""
|
||||
|
|
|
|||
|
|
@ -5,11 +5,6 @@ from unittest.mock import patch
|
|||
from langflow.logging.logger import SizedLogBuffer
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sized_log_buffer():
|
||||
return SizedLogBuffer()
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ def created_messages(session):
|
|||
return messages_read
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("client")
|
||||
def test_get_messages():
|
||||
add_messages(
|
||||
[
|
||||
|
|
@ -49,6 +50,7 @@ def test_get_messages():
|
|||
assert messages[1].text == "Test message 2"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("client")
|
||||
def test_add_messages():
|
||||
message = Message(text="New Test message", sender="User", sender_name="User", session_id="new_session_id")
|
||||
messages = add_messages(message)
|
||||
|
|
@ -56,6 +58,7 @@ def test_add_messages():
|
|||
assert messages[0].text == "New Test message"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("client")
|
||||
def test_add_messagetables(session):
|
||||
messages = [MessageTable(text="New Test message", sender="User", sender_name="User", session_id="new_session_id")]
|
||||
added_messages = add_messagetables(messages, session)
|
||||
|
|
@ -63,6 +66,7 @@ def test_add_messagetables(session):
|
|||
assert added_messages[0].text == "New Test message"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("client")
|
||||
def test_delete_messages(session):
|
||||
session_id = "session_id2"
|
||||
delete_messages(session_id)
|
||||
|
|
@ -70,6 +74,7 @@ def test_delete_messages(session):
|
|||
assert len(messages) == 0
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("client")
|
||||
def test_store_message():
|
||||
message = Message(text="Stored message", sender="User", sender_name="User", session_id="stored_session_id")
|
||||
stored_messages = store_message(message)
|
||||
|
|
|
|||
|
|
@ -11,11 +11,6 @@ from langflow.type_extraction.type_extraction import post_process_type
|
|||
from collections.abc import Sequence as SequenceABC
|
||||
|
||||
|
||||
@pytest.fixture(name="client", autouse=True)
|
||||
def client_fixture():
|
||||
pass
|
||||
|
||||
|
||||
class TestInput:
|
||||
def test_field_type_str(self):
|
||||
input_obj = Input(field_type="str")
|
||||
|
|
|
|||
|
|
@ -5,11 +5,6 @@ from langflow.utils.util import build_template_from_function, get_base_classes,
|
|||
from pydantic import BaseModel
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
# Dummy classes for testing purposes
|
||||
class Parent(BaseModel):
|
||||
"""Parent Class"""
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ async def super_user_headers(client: AsyncClient, super_user):
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def deactivated_user():
|
||||
def deactivated_user(client):
|
||||
with session_getter(get_db_service()) as session:
|
||||
user = User(
|
||||
username="deactivateduser",
|
||||
|
|
|
|||
|
|
@ -7,11 +7,6 @@ from requests.exceptions import MissingSchema
|
|||
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
|
||||
|
|
|
|||
|
|
@ -2,11 +2,6 @@ import pytest
|
|||
from langflow.utils.connection_string_parser import transform_connection_string
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"connection_string, expected",
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue