ref: Auto-fix ruff rules in tests (#4154)
This commit is contained in:
parent
51b3909d60
commit
45c8f98692
80 changed files with 359 additions and 456 deletions
|
|
@ -1,18 +1,14 @@
|
|||
import os
|
||||
|
||||
from astrapy.db import AstraDB
|
||||
import pytest
|
||||
|
||||
from astrapy.db import AstraDB
|
||||
from langchain_core.documents import Document
|
||||
from langflow.components.embeddings import OpenAIEmbeddingsComponent
|
||||
from langflow.components.vectorstores import AstraVectorStoreComponent
|
||||
from tests.api_keys import get_astradb_application_token, get_astradb_api_endpoint, get_openai_api_key
|
||||
from tests.integration.components.mock_components import TextToData
|
||||
from tests.integration.utils import ComponentInputHandle
|
||||
from langchain_core.documents import Document
|
||||
|
||||
|
||||
from langflow.schema.data import Data
|
||||
from tests.integration.utils import run_single_component
|
||||
from tests.api_keys import get_astradb_api_endpoint, get_astradb_application_token, get_openai_api_key
|
||||
from tests.integration.components.mock_components import TextToData
|
||||
from tests.integration.utils import ComponentInputHandle, run_single_component
|
||||
|
||||
BASIC_COLLECTION = "test_basic"
|
||||
SEARCH_COLLECTION = "test_search"
|
||||
|
|
@ -30,7 +26,7 @@ ALL_COLLECTIONS = [
|
|||
]
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@pytest.fixture
|
||||
def astradb_client(request):
|
||||
client = AstraDB(api_endpoint=get_astradb_api_endpoint(), token=get_astradb_application_token())
|
||||
yield client
|
||||
|
|
@ -139,7 +135,7 @@ def test_astra_vectorize():
|
|||
|
||||
@pytest.mark.api_key_required
|
||||
def test_astra_vectorize_with_provider_api_key():
|
||||
"""tests vectorize using an openai api key"""
|
||||
"""Tests vectorize using an openai api key."""
|
||||
from langchain_astradb import AstraDBVectorStore, CollectionVectorServiceOptions
|
||||
|
||||
application_token = get_astradb_application_token()
|
||||
|
|
@ -196,7 +192,7 @@ def test_astra_vectorize_with_provider_api_key():
|
|||
|
||||
@pytest.mark.api_key_required
|
||||
def test_astra_vectorize_passes_authentication():
|
||||
"""tests vectorize using the authentication parameter"""
|
||||
"""Tests vectorize using the authentication parameter."""
|
||||
from langchain_astradb import AstraDBVectorStore, CollectionVectorServiceOptions
|
||||
|
||||
store = None
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import pytest
|
||||
|
||||
from langflow.components.helpers.ParseJSONData import ParseJSONDataComponent
|
||||
from langflow.components.inputs import ChatInput
|
||||
from langflow.schema import Data
|
||||
from tests.integration.components.mock_components import TextToData
|
||||
from tests.integration.utils import run_single_component, ComponentInputHandle
|
||||
from tests.integration.utils import ComponentInputHandle, run_single_component
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import pytest
|
||||
from langflow.components.inputs import ChatInput
|
||||
from langflow.memory import get_messages
|
||||
from langflow.schema.message import Message
|
||||
from tests.integration.utils import run_single_component
|
||||
|
||||
from langflow.components.inputs import ChatInput
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_default():
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
import pytest
|
||||
from langflow.components.inputs import TextInputComponent
|
||||
from langflow.schema.message import Message
|
||||
from tests.integration.utils import run_single_component
|
||||
|
||||
from langflow.components.inputs import TextInputComponent
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_text_input():
|
||||
outputs = await run_single_component(TextInputComponent, run_input="sample text", input_type="text")
|
||||
print(outputs)
|
||||
assert isinstance(outputs["text"], Message)
|
||||
assert outputs["text"].text == "sample text"
|
||||
assert outputs["text"].sender is None
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import json
|
||||
from typing import List
|
||||
|
||||
from langflow.custom import Component
|
||||
from langflow.inputs import StrInput, BoolInput
|
||||
from langflow.inputs import BoolInput, StrInput
|
||||
from langflow.schema import Data
|
||||
from langflow.template import Output
|
||||
|
||||
|
|
@ -21,5 +20,5 @@ class TextToData(Component):
|
|||
return Data(data=json.loads(text))
|
||||
return Data(text=text)
|
||||
|
||||
def create_data(self) -> List[Data]:
|
||||
def create_data(self) -> list[Data]:
|
||||
return [self._to_data(t) for t in self.text_data]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import os
|
||||
import pytest
|
||||
|
||||
import pytest
|
||||
from langflow.components.models.OpenAIModel import OpenAIModelComponent
|
||||
from langflow.components.output_parsers.OutputParser import OutputParserComponent
|
||||
from langflow.components.prompts.Prompt import PromptComponent
|
||||
|
|
@ -23,7 +23,7 @@ async def test_csv_output_parser_openai():
|
|||
prompt_handler = ComponentInputHandle(
|
||||
clazz=PromptComponent,
|
||||
inputs={
|
||||
"template": "List the first five positive integers.\n\n{format_instructions}",
|
||||
"template": "List the first five positive integers.\n\n{format_instructions}", # noqa: RUF027
|
||||
"format_instructions": format_instructions,
|
||||
},
|
||||
output_name="prompt",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import pytest
|
||||
from langflow.components.outputs import ChatOutput
|
||||
from langflow.memory import get_messages
|
||||
from langflow.schema.message import Message
|
||||
from tests.integration.utils import run_single_component
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_string():
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import pytest
|
||||
from langflow.components.outputs import TextOutputComponent
|
||||
from langflow.schema.message import Message
|
||||
from tests.integration.utils import run_single_component
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test():
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
import pytest
|
||||
from langflow.components.prompts import PromptComponent
|
||||
from langflow.schema.message import Message
|
||||
from tests.integration.utils import run_single_component
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test():
|
||||
outputs = await run_single_component(PromptComponent, inputs={"template": "test {var1}", "var1": "from the var"})
|
||||
print(outputs)
|
||||
assert isinstance(outputs["prompt"], Message)
|
||||
assert outputs["prompt"].text == "test from the var"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue