ref: Remove useless pytest.mark.asyncio (#4364)

This commit is contained in:
Christophe Bornet 2024-11-02 14:46:07 +01:00 committed by GitHub
commit df22924b0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 0 additions and 53 deletions

View file

@ -5,7 +5,6 @@ from tests.api_keys import get_openai_api_key
from tests.integration.utils import download_flow_from_github, run_json_flow
@pytest.mark.asyncio
@pytest.mark.api_key_required
async def test_1_0_15_basic_prompting():
api_key = get_openai_api_key()

View file

@ -15,7 +15,6 @@ async def test_list_assistants():
@pytest.mark.api_key_required
@pytest.mark.asyncio
async def test_create_assistants():
from langflow.components.astra_assistants import AssistantsCreateAssistant

View file

@ -36,7 +36,6 @@ def astradb_client():
@pytest.mark.api_key_required
@pytest.mark.asyncio
async def test_base(astradb_client: AstraDB):
from langflow.components.embeddings import OpenAIEmbeddingsComponent
@ -65,7 +64,6 @@ async def test_base(astradb_client: AstraDB):
@pytest.mark.api_key_required
@pytest.mark.asyncio
async def test_astra_embeds_and_search():
application_token = get_astradb_application_token()
api_endpoint = get_astradb_api_endpoint()

View file

@ -1,4 +1,3 @@
import pytest
from langflow.components.helpers import ParseJSONDataComponent
from langflow.components.inputs import ChatInput
from langflow.schema import Data
@ -7,7 +6,6 @@ from tests.integration.components.mock_components import TextToData
from tests.integration.utils import ComponentInputHandle, run_single_component
@pytest.mark.asyncio
async def test_from_data():
outputs = await run_single_component(
ParseJSONDataComponent,
@ -34,7 +32,6 @@ async def test_from_data():
assert outputs["filtered_data"] == [Data(text="2")]
@pytest.mark.asyncio
async def test_from_message():
outputs = await run_single_component(
ParseJSONDataComponent,

View file

@ -1,4 +1,3 @@
import pytest
from langflow.components.inputs import ChatInput
from langflow.memory import get_messages
from langflow.schema.message import Message
@ -6,7 +5,6 @@ from langflow.schema.message import Message
from tests.integration.utils import run_single_component
@pytest.mark.asyncio
async def test_default():
outputs = await run_single_component(ChatInput, run_input="hello")
assert isinstance(outputs["message"], Message)
@ -21,7 +19,6 @@ async def test_default():
assert outputs["message"].sender_name == "User"
@pytest.mark.asyncio
async def test_sender():
outputs = await run_single_component(
ChatInput, inputs={"sender": "Machine", "sender_name": "AI"}, run_input="hello"
@ -32,7 +29,6 @@ async def test_sender():
assert outputs["message"].sender_name == "AI"
@pytest.mark.asyncio
async def test_do_not_store_messages():
session_id = "test-session-id"
outputs = await run_single_component(

View file

@ -1,11 +1,9 @@
import pytest
from langflow.components.inputs import TextInputComponent
from langflow.schema.message import Message
from tests.integration.utils import run_single_component
@pytest.mark.asyncio
async def test_text_input():
outputs = await run_single_component(TextInputComponent, run_input="sample text", input_type="text")
assert isinstance(outputs["text"], Message)

View file

@ -8,7 +8,6 @@ from langflow.components.prompts import PromptComponent
from tests.integration.utils import ComponentInputHandle, run_single_component
@pytest.mark.asyncio
@pytest.mark.api_key_required
async def test_csv_output_parser_openai():
format_instructions = ComponentInputHandle(

View file

@ -1,4 +1,3 @@
import pytest
from langflow.components.outputs import ChatOutput
from langflow.memory import get_messages
from langflow.schema.message import Message
@ -6,7 +5,6 @@ from langflow.schema.message import Message
from tests.integration.utils import run_single_component
@pytest.mark.asyncio
async def test_string():
outputs = await run_single_component(ChatOutput, inputs={"input_value": "hello"})
assert isinstance(outputs["message"], Message)
@ -15,7 +13,6 @@ async def test_string():
assert outputs["message"].sender_name == "AI"
@pytest.mark.asyncio
async def test_message():
outputs = await run_single_component(ChatOutput, inputs={"input_value": Message(text="hello")})
assert isinstance(outputs["message"], Message)
@ -24,7 +21,6 @@ async def test_message():
assert outputs["message"].sender_name == "AI"
@pytest.mark.asyncio
async def test_do_not_store_message():
session_id = "test-session-id"
outputs = await run_single_component(

View file

@ -1,11 +1,9 @@
import pytest
from langflow.components.outputs import TextOutputComponent
from langflow.schema.message import Message
from tests.integration.utils import run_single_component
@pytest.mark.asyncio
async def test():
outputs = await run_single_component(TextOutputComponent, inputs={"input_value": "hello"})
assert isinstance(outputs["text"], Message)
@ -14,7 +12,6 @@ async def test():
assert outputs["text"].sender_name is None
@pytest.mark.asyncio
async def test_message():
outputs = await run_single_component(TextOutputComponent, inputs={"input_value": Message(text="hello")})
assert isinstance(outputs["text"], Message)

View file

@ -1,11 +1,9 @@
import pytest
from langflow.components.prompts import PromptComponent
from langflow.schema.message import Message
from tests.integration.utils import run_single_component
@pytest.mark.asyncio
async def test():
outputs = await run_single_component(PromptComponent, inputs={"template": "test {var1}", "var1": "from the var"})
assert isinstance(outputs["prompt"], Message)

View file

@ -1,4 +1,3 @@
import pytest
from langflow.components.inputs import ChatInput
from langflow.components.outputs import ChatOutput
from langflow.components.prompts import PromptComponent
@ -8,7 +7,6 @@ from langflow.schema.message import Message
from tests.integration.utils import run_flow
@pytest.mark.asyncio
async def test_simple_no_llm():
graph = Graph()
flow_input = graph.add_component(ChatInput())

View file

@ -6,7 +6,6 @@ from langflow.components.tools.calculator import CalculatorToolComponent
@pytest.mark.api_key_required
@pytest.mark.asyncio
async def test_agent_component_with_calculator():
# Mock inputs
tools = [CalculatorToolComponent().build_tool()] # Use the Calculator component as a tool

View file

@ -7,7 +7,6 @@ from langflow.components.tools.calculator import CalculatorToolComponent
@pytest.mark.api_key_required
@pytest.mark.asyncio
async def test_tool_calling_agent_component():
tools = [CalculatorToolComponent().build_tool()] # Use the Calculator component as a tool
input_value = "What is 2 + 2?"

View file

@ -54,7 +54,6 @@ def test_update_build_config_exceed_limit(create_data_component):
create_data_component.update_build_config(build_config, 16, "number_of_fields")
@pytest.mark.asyncio
async def test_build_data(create_data_component):
create_data_component._attributes = {
"field_1_key": {"key1": "value1"},

View file

@ -54,7 +54,6 @@ def test_update_build_config_exceed_limit(update_data_component):
update_data_component.update_build_config(build_config, 16, "number_of_fields")
@pytest.mark.asyncio
async def test_build_data(update_data_component):
update_data_component._attributes = {
"field_1_key": {"key1": "new_value1"},

View file

@ -37,7 +37,6 @@ class TestEventManager:
assert manager.events["on_test_event"].func == manager.send_event
# Sending an event with valid event_type and data using pytest-asyncio plugin
@pytest.mark.asyncio
async def test_sending_event_with_valid_type_and_data_asyncio_plugin(self):
async def mock_queue_put_nowait(item):
await queue.put(item)
@ -96,7 +95,6 @@ class TestEventManager:
manager.register_event("invalid_name", "test_type", mock_callback)
# Sending an event with complex data and verifying successful event transmission
@pytest.mark.asyncio
async def test_sending_event_with_complex_data(self):
queue = asyncio.Queue()
manager = EventManager(queue)
@ -149,7 +147,6 @@ class TestEventManager:
# Verifying the uniqueness of event IDs for each event triggered using await with asyncio decorator
import pytest
@pytest.mark.asyncio
async def test_event_id_uniqueness_with_await(self):
queue = asyncio.Queue()
manager = EventManager(queue)
@ -165,7 +162,6 @@ class TestEventManager:
assert event_id_1 != event_id_2
# Ensuring the queue receives the correct event data format
@pytest.mark.asyncio
async def test_queue_receives_correct_event_data_format(self):
async def mock_queue_put_nowait(data):
pass

View file

@ -10,7 +10,6 @@ from langflow.graph import Graph
from langflow.graph.graph.constants import Finish
@pytest.mark.asyncio
async def test_graph_not_prepared():
chat_input = ChatInput()
chat_output = ChatOutput()
@ -21,7 +20,6 @@ async def test_graph_not_prepared():
await graph.astep()
@pytest.mark.asyncio
async def test_graph(caplog: pytest.LogCaptureFixture):
chat_input = ChatInput()
chat_output = ChatOutput()
@ -34,7 +32,6 @@ async def test_graph(caplog: pytest.LogCaptureFixture):
assert "Graph has vertices but no edges" in caplog.text
@pytest.mark.asyncio
async def test_graph_with_edge():
chat_input = ChatInput()
chat_output = ChatOutput()
@ -55,7 +52,6 @@ async def test_graph_with_edge():
assert graph.edges[0].target_id == output_id
@pytest.mark.asyncio
async def test_graph_functional():
chat_input = ChatInput(_id="chat_input")
chat_output = ChatOutput(input_value="test", _id="chat_output")
@ -71,7 +67,6 @@ async def test_graph_functional():
assert graph.edges[0].target_id == "chat_output"
@pytest.mark.asyncio
async def test_graph_functional_async_start():
chat_input = ChatInput(_id="chat_input")
chat_output = ChatOutput(input_value="test", _id="chat_output")

View file

@ -1,9 +1,7 @@
import pytest
from langchain_core.prompts.chat import ChatPromptTemplate
from langflow.schema.message import Message
@pytest.mark.asyncio
async def test_message_async_prompt_serialization():
template = "Hello, {name}!"
message = await Message.from_template_and_variables(template, name="Langflow")

View file

@ -15,7 +15,6 @@ def api_request():
return data.APIRequestComponent()
@pytest.mark.asyncio
@respx.mock
async def test_successful_get_request(api_request):
# Mocking a successful GET request
@ -53,7 +52,6 @@ def test_parse_curl(api_request):
assert new_build_config["body"]["value"] == {"key": "value"}
@pytest.mark.asyncio
@respx.mock
async def test_failed_request(api_request):
# Mocking a failed GET request
@ -68,7 +66,6 @@ async def test_failed_request(api_request):
assert result.data["status_code"] == 404
@pytest.mark.asyncio
@respx.mock
async def test_timeout(api_request):
# Mocking a timeout
@ -84,7 +81,6 @@ async def test_timeout(api_request):
assert result.data["error"] == "Request timed out"
@pytest.mark.asyncio
@respx.mock
async def test_build_with_multiple_urls(api_request):
# This test depends on having a working internet connection and accessible URLs

View file

@ -276,7 +276,6 @@ async def test_delete_flows(client: AsyncClient, logged_in_headers):
assert response.json().get("deleted") == number_of_flows
@pytest.mark.asyncio
@pytest.mark.usefixtures("active_user")
async def test_delete_flows_with_transaction_and_build(client: AsyncClient, logged_in_headers):
# Create ten flows
@ -335,7 +334,6 @@ async def test_delete_flows_with_transaction_and_build(client: AsyncClient, logg
assert response.json() == {"vertex_builds": {}}
@pytest.mark.asyncio
@pytest.mark.usefixtures("active_user")
async def test_delete_folder_with_flows_with_transaction_and_build(client: AsyncClient, logged_in_headers):
# Create a new folder

View file

@ -47,7 +47,6 @@ def test_get_project_data():
assert isinstance(project_icon_bg_color, str) or project_icon_bg_color is None
@pytest.mark.asyncio
@pytest.mark.usefixtures("client")
async def test_create_or_update_starter_projects():
with session_scope() as session:
@ -65,7 +64,6 @@ async def test_create_or_update_starter_projects():
# Some starter projects require integration
# @pytest.mark.asyncio
# async def test_starter_projects_can_run_successfully(client):
# with session_scope() as session:
# # Run the function to create or update projects
@ -128,7 +126,6 @@ def add_edge(source, target, from_output, to_input):
}
@pytest.mark.asyncio
async def test_refresh_starter_projects():
data_path = str(Path(__file__).parent.parent.parent.absolute() / "base" / "langflow" / "components")
components = build_custom_component_list_from_path(data_path)

View file

@ -1,4 +1,3 @@
import pytest
from langflow.processing.process import process_tweaks
from langflow.services.deps import get_session_service
@ -262,7 +261,6 @@ def test_tweak_not_in_template():
assert result == graph_data
@pytest.mark.asyncio
async def test_load_langchain_object_with_cached_session(basic_graph_data):
# Provide a non-existent session_id
session_service = get_session_service()
@ -276,7 +274,6 @@ async def test_load_langchain_object_with_cached_session(basic_graph_data):
# TODO: Update basic graph data
# @pytest.mark.asyncio
# async def test_load_langchain_object_with_no_cached_session(client, basic_graph_data):
# # Provide a non-existent session_id
# session_service = get_session_service()
@ -296,7 +293,6 @@ async def test_load_langchain_object_with_cached_session(basic_graph_data):
# assert id(graph1) != id(graph2)
# @pytest.mark.asyncio
# async def test_load_langchain_object_without_session_id(client, basic_graph_data):
# # Provide a non-existent session_id
# session_service = get_session_service()