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

test: add test for CohereComponent component #6622

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
33 changes: 33 additions & 0 deletions src/backend/tests/unit/components/models/test_cohere_component.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import pytest
from langflow.components.models import CohereComponent

from tests.base import ComponentTestBaseWithClient


@pytest.mark.usefixtures("client")
class TestCohereComponent(ComponentTestBaseWithClient):
@pytest.fixture
def component_class(self):
return CohereComponent

@pytest.fixture
def default_kwargs(self):
return {"cohere_api_key": "test_api_key", "temperature": 0.75, "_session_id": "123"}

@pytest.fixture
def file_names_mapping(self):
return [
{"version": "1.0.0", "module": "cohere", "file_name": "Cohere"},
{"version": "1.1.0", "module": "cohere", "file_name": "cohere"},
]

async def test_build_model(self, component_class, default_kwargs):
component = component_class(**default_kwargs)
model = component.build_model()
assert model is not None
assert model.temperature == default_kwargs["temperature"]
assert model.cohere_api_key == default_kwargs["cohere_api_key"]

def test_component_latest_version(self, component_class, default_kwargs):
result = component_class(**default_kwargs)()
assert result is not None
Loading