sample_id
stringlengths
21
196
text
stringlengths
105
936k
metadata
dict
category
stringclasses
6 values
langflow-ai/langflow:src/backend/tests/unit/agentic/services/test_flow_types.py
"""Tests for flow execution types and constants. Tests the dataclasses and constants used in flow execution. """ from pathlib import Path from langflow.agentic.services.flow_types import ( FLOWS_BASE_PATH, LANGFLOW_ASSISTANT_FLOW, MAX_VALIDATION_RETRIES, STREAMING_EVENT_TIMEOUT_SECONDS, STREAMING...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/agentic/services/test_flow_types.py", "license": "MIT License", "lines": 155, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/src/lfx/base/flow_controls/loop_utils.py
"""Utility functions for loop component execution.""" from collections import deque from typing import TYPE_CHECKING from lfx.schema.data import Data if TYPE_CHECKING: from lfx.graph.graph.base import Graph from lfx.graph.vertex.base import Vertex def get_loop_body_vertices( vertex: "Vertex", graph...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/src/lfx/base/flow_controls/loop_utils.py", "license": "MIT License", "lines": 227, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/lfx/tests/unit/components/flow_controls/test_loop_events.py
"""Tests for Loop component and loop utilities. These tests verify the loop body detection and component behavior. Event manager propagation is critical for UI updates during loop execution. Subgraph isolation tests are in tests/unit/graph/graph/test_subgraph_isolation.py. """ from contextlib import asynccontextmanag...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/components/flow_controls/test_loop_events.py", "license": "MIT License", "lines": 446, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/components/flow_controls/test_loop_parser_integration.py
"""Integration test for Loop + Parser bug fix. This test reproduces the bug reported where a Parser component inside a Loop was receiving None during the build phase, causing: "Unsupported input type: <class 'NoneType'>. Expected DataFrame or Data." """ import pytest from lfx.components.flow_controls.loop import Loop...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/components/flow_controls/test_loop_parser_integration.py", "license": "MIT License", "lines": 50, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/graph/graph/test_subgraph_isolation.py
"""Tests for subgraph isolation to verify if create_subgraph provides sufficient state isolation. These tests verify whether calling create_subgraph multiple times from the same parent graph produces isolated subgraphs that don't share state from previous executions. """ import pytest from lfx.components.input_output...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/graph/graph/test_subgraph_isolation.py", "license": "MIT License", "lines": 154, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/base/langflow/agentic/api/router.py
"""Langflow Assistant API router. This module provides the HTTP endpoints for the Langflow Assistant. All business logic is delegated to service modules. """ import uuid from dataclasses import dataclass from uuid import UUID from fastapi import APIRouter, HTTPException from fastapi.responses import StreamingRespons...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/agentic/api/router.py", "license": "MIT License", "lines": 249, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/base/langflow/agentic/api/schemas.py
"""Request and response schemas for the Assistant API.""" from typing import Literal from pydantic import BaseModel # All possible step types for SSE progress events StepType = Literal[ "generating", # LLM is generating response "generating_component", # LLM is generating component code "generation_com...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/agentic/api/schemas.py", "license": "MIT License", "lines": 30, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langflow-ai/langflow:src/backend/base/langflow/agentic/helpers/code_extraction.py
"""Python code extraction from markdown responses.""" import re PYTHON_CODE_BLOCK_PATTERN = r"```python\s*([\s\S]*?)```" GENERIC_CODE_BLOCK_PATTERN = r"```\s*([\s\S]*?)```" UNCLOSED_PYTHON_BLOCK_PATTERN = r"```python\s*([\s\S]*)$" UNCLOSED_GENERIC_BLOCK_PATTERN = r"```\s*([\s\S]*)$" def extract_python_code(text: st...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/agentic/helpers/code_extraction.py", "license": "MIT License", "lines": 40, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langflow-ai/langflow:src/backend/base/langflow/agentic/helpers/error_handling.py
"""Error handling and categorization for the Assistant API.""" MAX_ERROR_MESSAGE_LENGTH = 150 MIN_MEANINGFUL_PART_LENGTH = 10 ERROR_PATTERNS: list[tuple[list[str], str]] = [ (["rate_limit", "rate limit", "429"], "Rate limit exceeded. Please wait a moment and try again."), (["authentication", "api_key", "unaut...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/agentic/helpers/error_handling.py", "license": "MIT License", "lines": 33, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/base/langflow/agentic/helpers/sse.py
"""Server-Sent Events (SSE) formatting helpers.""" import json from langflow.agentic.api.schemas import StepType def format_progress_event( step: StepType, attempt: int, max_attempts: int, *, message: str | None = None, error: str | None = None, class_name: str | None = None, compone...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/agentic/helpers/sse.py", "license": "MIT License", "lines": 50, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langflow-ai/langflow:src/backend/base/langflow/agentic/helpers/validation.py
"""Component code validation.""" import re from lfx.custom.validate import create_class, extract_class_name from langflow.agentic.api.schemas import ValidationResult # Regex pattern to extract class name that inherits from Component CLASS_NAME_PATTERN = re.compile(r"class\s+(\w+)\s*\([^)]*Component[^)]*\)") def _...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/agentic/helpers/validation.py", "license": "MIT License", "lines": 44, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langflow-ai/langflow:src/backend/base/langflow/agentic/services/assistant_service.py
"""Assistant service with validation and retry logic.""" import asyncio from collections.abc import AsyncGenerator, Callable, Coroutine from typing import Any from fastapi import HTTPException from lfx.log.logger import logger from langflow.agentic.helpers.code_extraction import extract_component_code from langflow....
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/agentic/services/assistant_service.py", "license": "MIT License", "lines": 317, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/base/langflow/agentic/services/flow_executor.py
"""Flow execution service. Orchestrates flow execution for both Python (.py) and JSON (.json) flows. Supports both synchronous and streaming execution modes. """ import asyncio import json from collections.abc import AsyncGenerator, Callable, Coroutine from typing import TYPE_CHECKING, Any from fastapi import HTTPEx...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/agentic/services/flow_executor.py", "license": "MIT License", "lines": 192, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/base/langflow/agentic/services/flow_preparation.py
"""Flow data preparation and model injection.""" import json from pathlib import Path from lfx.base.models.model_metadata import get_provider_param_mapping from lfx.base.models.unified_models import get_provider_config def inject_model_into_flow( flow_data: dict, provider: str, model_name: str, api_...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/agentic/services/flow_preparation.py", "license": "MIT License", "lines": 67, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langflow-ai/langflow:src/backend/base/langflow/agentic/services/provider_service.py
"""Provider configuration service.""" import os from uuid import UUID from lfx.base.models.unified_models import ( get_model_provider_variable_mapping, get_provider_required_variable_keys, ) from lfx.log.logger import logger from sqlalchemy.ext.asyncio import AsyncSession from langflow.services.deps import g...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/agentic/services/provider_service.py", "license": "MIT License", "lines": 71, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/tests/unit/agentic/api/test_code_extraction.py
"""Tests for code extraction and validation in the agentic module. These tests validate the core functionality of extracting Python code from LLM responses and validating that the code is a valid Langflow component. """ from langflow.agentic.helpers.code_extraction import ( _find_code_blocks, _find_unclosed_c...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/agentic/api/test_code_extraction.py", "license": "MIT License", "lines": 309, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/agentic/api/test_schemas.py
"""Tests for API schemas. Tests the Pydantic models used for request/response validation. """ import pytest from langflow.agentic.api.schemas import AssistantRequest, StepType, ValidationResult from pydantic import ValidationError class TestAssistantRequest: """Tests for AssistantRequest schema.""" def tes...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/agentic/api/test_schemas.py", "license": "MIT License", "lines": 177, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/agentic/api/test_streaming_validation.py
"""Tests for streaming validation flow in the agentic module. These tests validate the retry logic and SSE event emission for component generation. """ import json from unittest.mock import AsyncMock, patch import pytest from langflow.agentic.helpers.code_extraction import extract_python_code from langflow.agentic.h...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/agentic/api/test_streaming_validation.py", "license": "MIT License", "lines": 708, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/agentic/helpers/test_error_handling.py
"""Tests for error handling helpers. Tests the error categorization and user-friendly message generation. """ from langflow.agentic.helpers.error_handling import ( ERROR_PATTERNS, MAX_ERROR_MESSAGE_LENGTH, MIN_MEANINGFUL_PART_LENGTH, _truncate_error_message, extract_friendly_error, ) class TestE...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/agentic/helpers/test_error_handling.py", "license": "MIT License", "lines": 184, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/agentic/helpers/test_sse.py
"""Tests for SSE (Server-Sent Events) formatting helpers. Tests the event formatting functions used for streaming responses. """ import json import pytest from langflow.agentic.helpers.sse import ( format_complete_event, format_error_event, format_progress_event, format_token_event, ) class TestFor...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/agentic/helpers/test_sse.py", "license": "MIT License", "lines": 200, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/agentic/services/test_flow_executor.py
"""Tests for flow executor service. Tests the flow execution, model injection, and streaming functionality. """ import json from pathlib import Path from unittest.mock import AsyncMock, MagicMock, patch import pytest from fastapi import HTTPException from langflow.agentic.services.flow_executor import ( execute_...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/agentic/services/test_flow_executor.py", "license": "MIT License", "lines": 306, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/agentic/services/test_provider_service.py
"""Tests for provider service. Tests the provider configuration and API key checking functionality. """ import os from unittest.mock import AsyncMock, MagicMock, patch from uuid import UUID import pytest from langflow.agentic.services.provider_service import ( DEFAULT_MODELS, PREFERRED_PROVIDERS, check_a...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/agentic/services/test_provider_service.py", "license": "MIT License", "lines": 173, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/base/langflow/alembic/versions/369268b9af8b_add_job_id_to_vertex_build_create_job_.py
"""add job_id to vertex_build, create job status table. Revision ID: 369268b9af8b Revises: 182e5471b900 Create Date: 2026-01-28 13:00:52.967282 Phase: EXPAND """ from collections.abc import Sequence import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. revision: str = "369268b9af8...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/alembic/versions/369268b9af8b_add_job_id_to_vertex_build_create_job_.py", "license": "MIT License", "lines": 65, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, ...
function_simple
langflow-ai/langflow:src/backend/base/langflow/api/v2/workflow_reconstruction.py
"""Workflow response reconstruction from vertex_build table. This module reconstructs WorkflowExecutionResponse from vertex_build table data by job_id, enabling retrieval of past execution results without re-running workflows. """ from __future__ import annotations from typing import TYPE_CHECKING from lfx.graph.gr...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/api/v2/workflow_reconstruction.py", "license": "MIT License", "lines": 62, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/base/langflow/services/database/models/jobs/crud.py
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from collections.abc import Sequence from uuid import UUID from sqlmodel.ext.asyncio.session import AsyncSession from sqlmodel import col, select from langflow.services.database.models.jobs.model import Job, JobStatus...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/services/database/models/jobs/crud.py", "license": "MIT License", "lines": 74, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langflow-ai/langflow:src/backend/base/langflow/services/database/models/jobs/model.py
from datetime import datetime, timezone from enum import Enum from uuid import UUID from sqlalchemy import Column, DateTime from sqlalchemy import Enum as SQLEnum from sqlmodel import Field, SQLModel class JobStatus(str, Enum): QUEUED = "queued" IN_PROGRESS = "in_progress" COMPLETED = "completed" FAI...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/services/database/models/jobs/model.py", "license": "MIT License", "lines": 57, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langflow-ai/langflow:src/backend/base/langflow/services/jobs/factory.py
"""Factory for creating JobService instances.""" from langflow.services.factory import ServiceFactory from langflow.services.jobs.service import JobService class JobServiceFactory(ServiceFactory): """Factory for creating JobService instances.""" def __init__(self): super().__init__(JobService) ...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/services/jobs/factory.py", "license": "MIT License", "lines": 16, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langflow-ai/langflow:src/backend/base/langflow/services/jobs/service.py
"""Job service for managing workflow job status and tracking.""" from __future__ import annotations import asyncio from typing import TYPE_CHECKING if TYPE_CHECKING: from collections.abc import Sequence from datetime import datetime, timezone from uuid import UUID from langflow.services.base import Service from...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/services/jobs/service.py", "license": "MIT License", "lines": 167, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/tests/unit/api/v2/test_workflow_reconstruction.py
"""Unit tests for workflow reconstruction from vertex_build table. Test Coverage: - Successful reconstruction with terminal nodes - Reconstruction with no vertex builds found (error case) - Reconstruction with flow having no data (error case) - Reconstruction filtering to terminal nodes only """ from ...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/api/v2/test_workflow_reconstruction.py", "license": "MIT License", "lines": 125, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/api/v1/test_flow_folder_integrity.py
"""Tests for flow-folder integrity to prevent orphaned flows. These tests verify the fix for the bug where flows could be created without a valid folder_id when all folders were deleted (zero folders scenario), resulting in orphaned flows that were unreachable in the UI. The fix ensures: 1. Flows always have a valid ...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/api/v1/test_flow_folder_integrity.py", "license": "MIT License", "lines": 226, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/components/llm_operations/test_llm_conditional_router.py
from unittest.mock import MagicMock, patch import pytest from lfx.components.llm_operations.llm_conditional_router import SmartRouterComponent from lfx.schema.message import Message from tests.base import ComponentTestBaseWithoutClient class TestSmartRouterComponent(ComponentTestBaseWithoutClient): @pytest.fixt...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/components/llm_operations/test_llm_conditional_router.py", "license": "MIT License", "lines": 106, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/base/io/test_chat.py
from lfx.base.io.chat import _extract_model_name class TestExtractModelName: def test_should_return_string_when_input_is_string(self): assert _extract_model_name("gpt-4o-mini") == "gpt-4o-mini" def test_should_return_name_when_input_is_model_input_list(self): model_input = [{"name": "gpt-4o-m...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/base/io/test_chat.py", "license": "MIT License", "lines": 20, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/performance/check_key_benchmark.py
# src/backend/tests/perf/check_key_benchmark.py import logging import statistics import time import uuid import pytest from langflow.services.auth import utils as auth_utils from langflow.services.database.models.api_key import crud as api_key_crud from langflow.services.database.models.api_key.model import ApiKey fro...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/performance/check_key_benchmark.py", "license": "MIT License", "lines": 91, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/test_get_api_key.py
import asyncio from uuid import uuid4 import langflow.services.database.models.api_key.crud as crud_module import pytest from cryptography.fernet import InvalidToken class DummyResult: def __init__(self, items): self._items = items def all(self): return self._items class MockSession: d...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/test_get_api_key.py", "license": "MIT License", "lines": 56, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/components/prompts/test_validate_prompt_mustache.py
"""Tests for validate_prompt function with mustache templates. These tests ensure that complex mustache syntax is rejected during the "Check & Save" validation phase, not just at runtime. This prevents users from saving templates that are guaranteed to fail at runtime. Regression test for: Complex mustache patterns l...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/components/prompts/test_validate_prompt_mustache.py", "license": "MIT License", "lines": 123, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/components/utilities/test_current_date.py
"""Tests for CurrentDateComponent tool schema optimization.""" import json from lfx.base.tools.component_tool import ComponentToolkit from lfx.components.utilities.current_date import CurrentDateComponent from lfx.io.schema import MAX_OPTIONS_FOR_TOOL_ENUM class TestCurrentDateToolSchema: """Tests to verify too...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/components/utilities/test_current_date.py", "license": "MIT License", "lines": 73, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/inputs/test_model_input_static_options.py
"""Tests for ModelInput static options preservation. This module tests that when a component specifies static options for a ModelInput, those options remain static and are not overridden by global user settings. """ from unittest.mock import MagicMock from lfx.base.models.unified_models import update_model_options_i...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/inputs/test_model_input_static_options.py", "license": "MIT License", "lines": 160, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/base/langflow/services/event_manager.py
"""Event Manager for Webhook Real-Time Updates. This module provides an in-memory event broadcasting system for webhook builds. When a UI is connected via SSE, it receives real-time build events. """ from __future__ import annotations import asyncio import json import time from collections import defaultdict from ty...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/services/event_manager.py", "license": "MIT License", "lines": 194, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/base/langflow/api/v2/converters.py
"""Schema converters for V2 Workflow API. This module provides conversion functions between the new V2 workflow schemas and the existing V1 schemas, enabling reuse of existing execution logic while presenting a new API interface. Key Functions: - parse_flat_inputs: Converts flat input format to tweaks structure ...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/api/v2/converters.py", "license": "MIT License", "lines": 422, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/tests/unit/api/v2/test_converters.py
"""Comprehensive unit tests for V2 Workflow API converters. This test module provides extensive coverage of the converter functions that transform between V2 workflow schemas and V1 schemas. Tests include: Test Coverage: - Input parsing and transformation (parse_flat_inputs) - Nested value extraction from var...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/api/v2/test_converters.py", "license": "MIT License", "lines": 1039, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/services/auth/test_decrypt_api_key.py
"""Test decrypt_api_key function with encrypted, plain text, and wrong key scenarios.""" from types import SimpleNamespace from unittest.mock import patch import pytest from langflow.services.auth.mcp_encryption import is_encrypted from langflow.services.auth.service import AuthService from langflow.services.auth.uti...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/services/auth/test_decrypt_api_key.py", "license": "MIT License", "lines": 148, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:scripts/build_hash_history.py
#!/usr/bin/env python3 import argparse import asyncio import copy from pathlib import Path import orjson from packaging.version import Version STABLE_HISTORY_FILE = "src/lfx/src/lfx/_assets/stable_hash_history.json" NIGHTLY_HISTORY_FILE = "src/lfx/src/lfx/_assets/nightly_hash_history.json" def get_lfx_version(): ...
{ "repo_id": "langflow-ai/langflow", "file_path": "scripts/build_hash_history.py", "license": "MIT License", "lines": 159, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/tests/unit/test_build_hash_history.py
import sys from pathlib import Path from unittest.mock import patch import pytest # Add the scripts directory to the Python path sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent.parent.parent / "scripts")) # Now we can import the script from build_hash_history import _import_components, main, upd...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/test_build_hash_history.py", "license": "MIT License", "lines": 96, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/src/lfx/services/registry.py
"""Service registration decorator for pluggable services. Allows services to self-register with the service manager using a decorator. """ from __future__ import annotations from typing import TYPE_CHECKING, TypeVar from lfx.log.logger import logger if TYPE_CHECKING: from lfx.services.base import Service f...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/src/lfx/services/registry.py", "license": "MIT License", "lines": 37, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langflow-ai/langflow:src/lfx/src/lfx/services/telemetry/base.py
"""Abstract base class for telemetry services.""" from __future__ import annotations from abc import ABC, abstractmethod from typing import TYPE_CHECKING from lfx.services.base import Service if TYPE_CHECKING: from pydantic import BaseModel class BaseTelemetryService(Service, ABC): """Abstract base class ...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/src/lfx/services/telemetry/base.py", "license": "MIT License", "lines": 63, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langflow-ai/langflow:src/lfx/src/lfx/services/telemetry/service.py
"""Lightweight telemetry service for LFX package.""" from __future__ import annotations from typing import TYPE_CHECKING from lfx.log.logger import logger from lfx.services.telemetry.base import BaseTelemetryService if TYPE_CHECKING: from pydantic import BaseModel class TelemetryService(BaseTelemetryService):...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/src/lfx/services/telemetry/service.py", "license": "MIT License", "lines": 74, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langflow-ai/langflow:src/lfx/src/lfx/services/tracing/base.py
"""Abstract base class for tracing services.""" from __future__ import annotations from abc import ABC, abstractmethod from contextlib import asynccontextmanager from typing import TYPE_CHECKING, Any from lfx.services.base import Service if TYPE_CHECKING: from uuid import UUID from langchain.callbacks.base...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/src/lfx/services/tracing/base.py", "license": "MIT License", "lines": 94, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langflow-ai/langflow:src/lfx/src/lfx/services/variable/service.py
"""Minimal variable service for lfx package with in-memory storage and environment fallback.""" import os from lfx.log.logger import logger from lfx.services.base import Service class VariableService(Service): """Minimal variable service with in-memory storage and environment fallback. This is a lightweigh...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/src/lfx/services/variable/service.py", "license": "MIT License", "lines": 63, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langflow-ai/langflow:src/lfx/tests/unit/services/test_decorator_registration.py
"""Tests for decorator-based service registration.""" from unittest.mock import MagicMock import pytest from lfx.services.base import Service from lfx.services.manager import ServiceManager from lfx.services.schema import ServiceType from lfx.services.storage.local import LocalStorageService from lfx.services.telemet...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/services/test_decorator_registration.py", "license": "MIT License", "lines": 118, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/services/test_edge_cases.py
"""Edge case tests for pluggable service system.""" import pytest from lfx.services.base import Service from lfx.services.manager import ServiceManager from lfx.services.schema import ServiceType class MockSessionService(Service): """Mock session service for testing.""" name = "session_service" def __i...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/services/test_edge_cases.py", "license": "MIT License", "lines": 371, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/services/test_integration.py
"""Integration tests for pluggable service system.""" import os import pytest from lfx.services.base import Service from lfx.services.manager import ServiceManager from lfx.services.schema import ServiceType from .conftest import MockSessionService class TestStandaloneLFX: """Test LFX running standalone withou...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/services/test_integration.py", "license": "MIT License", "lines": 383, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/services/test_minimal_services.py
"""Tests for minimal service implementations in LFX.""" import os import pytest from lfx.services.storage.local import LocalStorageService from lfx.services.telemetry.service import TelemetryService from lfx.services.tracing.service import TracingService from lfx.services.variable.service import VariableService cla...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/services/test_minimal_services.py", "license": "MIT License", "lines": 205, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/services/test_service_manager.py
"""Tests for the ServiceManager plugin system.""" from pathlib import Path import pytest from lfx.services.base import Service from lfx.services.manager import NoFactoryRegisteredError, ServiceManager from lfx.services.schema import ServiceType from lfx.services.storage.local import LocalStorageService from lfx.servi...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/services/test_service_manager.py", "license": "MIT License", "lines": 369, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/base/langflow/processing/expand_flow.py
"""Expand compact flow format to full flow format. This module provides functionality to expand a minimal/compact flow format (used by AI agents) into the full flow format expected by Langflow. """ from __future__ import annotations from typing import Any from pydantic import BaseModel, Field class CompactNode(Ba...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/processing/expand_flow.py", "license": "MIT License", "lines": 238, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/tests/unit/test_expand_flow.py
"""Tests for expand_compact_flow functionality.""" import pytest from fastapi import status from httpx import AsyncClient from langflow.processing.expand_flow import ( CompactEdge, CompactNode, _expand_edge, _expand_node, _get_flat_components, expand_compact_flow, ) # Sample component data mim...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/test_expand_flow.py", "license": "MIT License", "lines": 522, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/test_starter_projects_no_hash_history.py
"""Test that starter projects do not contain hash_history in their JSON files. This test ensures that internal component metadata (hash_history) used for tracking component evolution in the component index does not leak into saved flow templates. """ import json from pathlib import Path import pytest def find_hash...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/test_starter_projects_no_hash_history.py", "license": "MIT License", "lines": 60, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/components/processing/test_text_operations_component.py
"""Tests for TextOperations component. Includes regression tests for QA-reported bugs. """ import pytest from lfx.components.processing.text_operations import TextOperations from lfx.schema.data import Data from lfx.schema.dataframe import DataFrame from lfx.schema.message import Message from tests.base import Compo...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/components/processing/test_text_operations_component.py", "license": "MIT License", "lines": 592, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/src/lfx/components/processing/text_operations.py
import contextlib import re from typing import Any import pandas as pd from lfx.custom import Component from lfx.field_typing import RangeSpec from lfx.inputs import ( BoolInput, DropdownInput, IntInput, SortableListInput, StrInput, ) from lfx.inputs.inputs import MultilineInput from lfx.io import...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/src/lfx/components/processing/text_operations.py", "license": "MIT License", "lines": 508, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/lfx/src/lfx/events/observability/lifecycle_events.py
import functools from collections.abc import Awaitable, Callable from typing import Any from ag_ui.encoder.encoder import EventEncoder from lfx.log.logger import logger AsyncMethod = Callable[..., Awaitable[Any]] encoder: EventEncoder = EventEncoder() def observable(observed_method: AsyncMethod) -> AsyncMethod: ...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/src/lfx/events/observability/lifecycle_events.py", "license": "MIT License", "lines": 90, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/lfx/tests/unit/events/observability/test_lifecycle_events.py
import asyncio from typing import Any from unittest.mock import AsyncMock, MagicMock, patch import pytest from ag_ui.core import CustomEvent, StepFinishedEvent, StepStartedEvent # Import the actual decorator we want to test from lfx.events.observability.lifecycle_events import observable # Mock classes for dependen...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/events/observability/test_lifecycle_events.py", "license": "MIT License", "lines": 182, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/base/langflow/api/v2/workflow.py
"""V2 Workflow execution endpoints. This module implements the V2 Workflow API endpoints for executing flows with enhanced error handling, timeout protection, and structured responses. Endpoints: POST /workflow: Execute a workflow (sync, stream, or background modes) GET /workflow: Get workflow job status by j...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/api/v2/workflow.py", "license": "MIT License", "lines": 641, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/tests/unit/api/v2/test_workflow.py
"""Comprehensive unit tests for V2 Workflow API endpoints. This test module provides extensive coverage of the workflow execution endpoints, including authentication, authorization, error handling, and execution modes. Test Coverage: - Developer API protection (enabled/disabled scenarios) - API key authentica...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/api/v2/test_workflow.py", "license": "MIT License", "lines": 1331, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/src/lfx/schema/workflow.py
"""Workflow execution schemas for V2 API.""" from __future__ import annotations from datetime import datetime, timezone from enum import Enum from typing import Annotated, Any, Literal from uuid import UUID from pydantic import BaseModel, BeforeValidator, ConfigDict, Field, model_validator from lfx.schema.validator...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/src/lfx/schema/workflow.py", "license": "MIT License", "lines": 161, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langflow-ai/langflow:src/backend/tests/unit/utils/test_mustache_security.py
"""Tests for mustache security utilities.""" import pytest from langflow.utils.mustache_security import safe_mustache_render, validate_mustache_template class TestMustacheSecurity: """Test mustache security functions.""" def test_validate_accepts_simple_variables(self): """Test that simple variables...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/utils/test_mustache_security.py", "license": "MIT License", "lines": 96, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/src/lfx/utils/mustache_security.py
"""Security utilities for mustache template processing.""" import re from typing import Any # Regex pattern for simple variables only - same as frontend SIMPLE_VARIABLE_PATTERN = re.compile(r"\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}") # Patterns for complex mustache syntax that we want to block DANGEROUS_PATTERNS = [ re...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/src/lfx/utils/mustache_security.py", "license": "MIT License", "lines": 61, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/lfx/tests/unit/components/test_prompt_component.py
"""Tests for PromptComponent with f-string and double brackets syntax.""" from lfx.components.models_and_agents.prompt import PromptComponent class TestPromptComponent: """Test the PromptComponent.""" def test_update_template_single_variable(self): """Test template update with a single variable.""" ...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/components/test_prompt_component.py", "license": "MIT License", "lines": 240, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/schema/test_mustache_template_processing.py
"""Tests for mustache template processing in the Message class. Note: Our mustache implementation only supports simple variable substitution for security reasons. Complex features like conditionals, loops, and sections are not supported. """ import pytest from lfx.schema.message import Message from lfx.utils.mustache...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/schema/test_mustache_template_processing.py", "license": "MIT License", "lines": 131, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/components/models_and_agents/test_ibm_granite_handler.py
"""Tests for IBM Granite handler functions. This module tests the specialized handling for IBM Granite models which have different tool calling behavior compared to other LLMs. """ import contextlib from unittest.mock import Mock, patch import pytest from langchain_core.messages import AIMessage from lfx.components....
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/components/models_and_agents/test_ibm_granite_handler.py", "license": "MIT License", "lines": 686, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/graph/test_cache_restoration.py
"""Tests for cache restoration behavior in build_vertex. This module tests the fix for the issue where cache restoration failure would leave vertex.built = True, causing subsequent build() calls to return early without setting vertex.result. Bug scenario (before fix): 1. Frozen vertex, cache hit -> vertex.built = Tru...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/graph/test_cache_restoration.py", "license": "MIT License", "lines": 357, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/cli/test_lazy_imports.py
"""Tests for CLI lazy import mechanisms. These tests verify that the lazy import patterns in CLI modules work correctly and help reduce cold start time. """ import json import pytest class TestCLIModuleLazyImports: """Test lazy imports in CLI __init__ module.""" def test_serve_command_accessible_via_getat...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/cli/test_lazy_imports.py", "license": "MIT License", "lines": 149, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/field_typing/test_lazy_imports.py
"""Tests for field_typing lazy import mechanism. These tests verify that the __getattr__ lazy import pattern in field_typing/__init__.py works correctly and returns the expected types. """ import pytest class TestFieldTypingLazyImports: """Test that field_typing exports are accessible via lazy imports.""" ...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/field_typing/test_lazy_imports.py", "license": "MIT License", "lines": 132, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/test_auth_jwt_algorithms.py
"""Comprehensive tests for JWT algorithm support (HS256, RS256, RS512). Tests cover: - AuthSettings configuration for each algorithm - RSA key generation and persistence - Token creation and verification - Error cases and edge cases - Authentication failure scenarios """ import tempfile from datetime import timedelta...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/test_auth_jwt_algorithms.py", "license": "MIT License", "lines": 795, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/base/langflow/services/transaction/factory.py
"""Transaction service factory for langflow.""" from __future__ import annotations from typing import TYPE_CHECKING from langflow.services.factory import ServiceFactory from langflow.services.transaction.service import TransactionService if TYPE_CHECKING: from langflow.services.settings.service import SettingsS...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/services/transaction/factory.py", "license": "MIT License", "lines": 19, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
documentation
langflow-ai/langflow:src/backend/base/langflow/services/transaction/service.py
"""Transaction service implementation for langflow.""" from __future__ import annotations from typing import TYPE_CHECKING, Any from uuid import UUID from lfx.log.logger import logger from lfx.services.deps import session_scope from lfx.services.interfaces import TransactionServiceProtocol from langflow.services.ba...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/services/transaction/service.py", "license": "MIT License", "lines": 67, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/tests/unit/api/v1/test_transactions.py
"""Tests for transactions API endpoints and models.""" from datetime import datetime, timezone from uuid import uuid4 import pytest from fastapi import status from httpx import AsyncClient from langflow.services.database.models.transactions.crud import ( transform_transaction_table, transform_transaction_tabl...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/api/v1/test_transactions.py", "license": "MIT License", "lines": 455, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/services/transaction/test_deps.py
"""Tests for transaction service dependency injection.""" from unittest.mock import MagicMock, patch from lfx.services.deps import get_transaction_service from lfx.services.interfaces import TransactionServiceProtocol from lfx.services.transaction.service import NoopTransactionService class TestGetTransactionServic...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/services/transaction/test_deps.py", "license": "MIT License", "lines": 32, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/services/transaction/test_factory.py
"""Tests for TransactionServiceFactory.""" from unittest.mock import MagicMock import pytest from langflow.services.factory import ServiceFactory from langflow.services.schema import ServiceType from langflow.services.transaction.factory import TransactionServiceFactory from langflow.services.transaction.service impo...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/services/transaction/test_factory.py", "license": "MIT License", "lines": 55, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/services/transaction/test_noop_transaction_service.py
"""Tests for NoopTransactionService.""" import pytest from lfx.services.interfaces import TransactionServiceProtocol from lfx.services.transaction.service import NoopTransactionService class TestNoopTransactionService: """Test suite for NoopTransactionService.""" @pytest.fixture def service(self) -> Noo...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/services/transaction/test_noop_transaction_service.py", "license": "MIT License", "lines": 70, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/services/transaction/test_service.py
"""Tests for TransactionService.""" from unittest.mock import AsyncMock, MagicMock, patch from uuid import UUID import pytest from langflow.services.transaction.service import TransactionService from lfx.services.interfaces import TransactionServiceProtocol class TestTransactionService: """Test suite for Transa...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/services/transaction/test_service.py", "license": "MIT License", "lines": 157, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/src/lfx/services/transaction/service.py
"""Transaction service implementations for lfx.""" from __future__ import annotations from typing import Any from lfx.services.interfaces import TransactionServiceProtocol class NoopTransactionService(TransactionServiceProtocol): """No-operation transaction service for standalone lfx mode. This service is...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/src/lfx/services/transaction/service.py", "license": "MIT License", "lines": 26, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langflow-ai/langflow:src/backend/tests/unit/components/embeddings/test_ollama_embeddings_component.py
"""Tests for OllamaEmbeddingsComponent. This test module validates the OllamaEmbeddingsComponent functionality: - Building embeddings with various configurations - URL handling (localhost transformation, /v1 suffix stripping) - Model fetching with capability filtering - URL validation - Build config updates - Headers ...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/components/embeddings/test_ollama_embeddings_component.py", "license": "MIT License", "lines": 737, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/test_database_path_resolution.py
"""Tests for database path resolution in settings. These tests verify that the database path is correctly resolved based on the save_db_in_config_dir setting and langflow package availability. """ import os from pathlib import Path from unittest.mock import patch class TestDatabasePathResolution: """Test databa...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/test_database_path_resolution.py", "license": "MIT License", "lines": 78, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/integration/cli/test_simple_agent_integration.py
"""Integration tests for lfx CLI with Simple Agent flow. These tests verify that the lfx CLI can properly load and execute the Simple Agent starter project, addressing the bug where lfx serve/run commands fail with module resolution errors. Requirements: - OPENAI_API_KEY environment variable must be set for execution...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/integration/cli/test_simple_agent_integration.py", "license": "MIT License", "lines": 358, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/inputs/test_model_input_fixes.py
"""Tests for ModelInput fixes. This module tests the following bug fixes: 1. Input port visibility: ModelInput should always show connection handle based on model_type. 2. Model defaults (cb6208f0ab): The first 5 models from each provider should be marked as default. """ from lfx.base.models.unified_models import get...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/inputs/test_model_input_fixes.py", "license": "MIT License", "lines": 185, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/src/lfx/base/data/cloud_storage_utils.py
"""Shared utilities for cloud storage operations (AWS S3 and Google Drive). This module provides common functionality used by both read and write file components to avoid code duplication. """ from __future__ import annotations import json from typing import Any def validate_aws_credentials(component: Any) -> None...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/src/lfx/base/data/cloud_storage_utils.py", "license": "MIT License", "lines": 121, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/tests/unit/test_strip_dynamic_fields.py
"""Tests for the _strip_dynamic_fields function in build_component_index.py.""" import sys from pathlib import Path import pytest @pytest.fixture(scope="session") def strip_dynamic_fields_func(): """Fixture to import and provide the _strip_dynamic_fields function.""" script_path = Path(__file__).parent.pare...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/test_strip_dynamic_fields.py", "license": "MIT License", "lines": 147, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/src/lfx/run/base.py
"""Core run functionality for executing Langflow graphs.""" import json import re import sys import time from io import StringIO from pathlib import Path from typing import TYPE_CHECKING from lfx.cli.script_loader import ( extract_structured_result, extract_text_from_result, find_graph_variable, load_...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/src/lfx/run/base.py", "license": "MIT License", "lines": 421, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/lfx/tests/unit/run/test_base.py
"""Unit tests for the run.base module. This module demonstrates different testing approaches: 1. UNIT TESTS (with mocks): Test individual functions in isolation 2. INTEGRATION TESTS (with real components): Test with actual graphs and components 3. ENVIRONMENT-BASED TESTS: Test with real environment variable injection...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/run/test_base.py", "license": "MIT License", "lines": 740, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/lfx/tests/unit/run/test_base_integration.py
"""Integration tests for run.base module with minimal mocking. This file demonstrates how to test run_flow with real components and graphs, reducing the need for extensive mocking while still maintaining test isolation. """ from pathlib import Path import pytest from lfx.run.base import RunError, run_flow class Te...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/lfx/tests/unit/run/test_base_integration.py", "license": "MIT License", "lines": 183, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/api/v1/test_flows_path_validation.py
"""Unit tests for flow filesystem path validation security.""" from unittest.mock import MagicMock from uuid import uuid4 import anyio import pytest from fastapi import HTTPException from langflow.api.v1.flows import _get_safe_flow_path from langflow.services.storage.service import StorageService @pytest.fixture de...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/api/v1/test_flows_path_validation.py", "license": "MIT License", "lines": 151, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/base/langflow/utils/mcp_cleanup.py
"""MCP subprocess cleanup utilities for graceful shutdown. This module provides functions to properly terminate MCP server subprocesses spawned by stdio_client during Langflow shutdown. Works on macOS and Linux only. """ from __future__ import annotations import contextlib import sys from typing import TYPE_CHECKIN...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/utils/mcp_cleanup.py", "license": "MIT License", "lines": 88, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/tests/unit/utils/test_mcp_cleanup.py
"""Tests for MCP cleanup utilities.""" import sys from unittest.mock import AsyncMock, MagicMock, patch import pytest from langflow.utils.mcp_cleanup import ( _kill_mcp_processes, _terminate_child_mcp_processes, _terminate_orphaned_mcp_processes, _try_terminate_mcp_process, cleanup_mcp_sessions, )...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/utils/test_mcp_cleanup.py", "license": "MIT License", "lines": 421, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/base/langflow/tests/api/v1/test_openai_responses_error.py
"""Test OpenAI Responses Error Handling.""" import json from unittest.mock import MagicMock, patch import pytest from fastapi.testclient import TestClient from langflow.main import create_app @pytest.fixture def client(): app = create_app() return TestClient(app) @pytest.mark.asyncio async def test_openai...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/tests/api/v1/test_openai_responses_error.py", "license": "MIT License", "lines": 76, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/test_starter_projects.py
"""Test suite for starter project JSON files. Verifies that starter project JSON files are properly structured and that: - noteNode types have width/height at the root level - Other node types have width/height removed from root level """ import json from pathlib import Path import pytest STARTER_PROJECTS_DIR = Pat...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/test_starter_projects.py", "license": "MIT License", "lines": 65, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/components/models_and_agents/test_mcp_component_output.py
"""Tests for MCP component output processing.""" from unittest.mock import AsyncMock, MagicMock import pytest from lfx.components.models_and_agents.mcp_component import MCPToolsComponent from lfx.schema.dataframe import DataFrame class TestMCPComponentOutputProcessing: """Test MCP component output processing, p...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/components/models_and_agents/test_mcp_component_output.py", "license": "MIT License", "lines": 102, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/base/langflow/api/v1/model_options.py
from fastapi import APIRouter from lfx.base.models.unified_models import get_embedding_model_options, get_language_model_options from langflow.api.utils import CurrentActiveUser router = APIRouter(prefix="/model_options", tags=["Model Options"], include_in_schema=False) @router.get("/language", status_code=200) asy...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/api/v1/model_options.py", "license": "MIT License", "lines": 16, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_simple
langflow-ai/langflow:src/backend/base/langflow/api/v1/models.py
from __future__ import annotations import json from typing import Annotated from fastapi import APIRouter, Depends, HTTPException, Query from lfx.base.models.model_utils import replace_with_live_models from lfx.base.models.unified_models import ( get_model_provider_metadata, get_model_provider_variable_mappin...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/base/langflow/api/v1/models.py", "license": "MIT License", "lines": 736, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
function_complex
langflow-ai/langflow:src/backend/tests/unit/api/v1/test_models_enabled_providers.py
"""Tests for model provider enabled_providers endpoint and credential redaction.""" from unittest import mock import pytest from fastapi import status from httpx import AsyncClient from langflow.services.variable.constants import CREDENTIAL_TYPE from lfx.base.models.unified_models import get_model_provider_variable_m...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/api/v1/test_models_enabled_providers.py", "license": "MIT License", "lines": 462, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/test_models_api.py
import pytest from httpx import AsyncClient def _flatten_models(result_json): for provider_dict in result_json: yield from provider_dict["models"] @pytest.mark.asyncio async def test_models_endpoint_default(client: AsyncClient, logged_in_headers): response = await client.get("api/v1/models", headers...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/test_models_api.py", "license": "MIT License", "lines": 32, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test
langflow-ai/langflow:src/backend/tests/unit/test_unified_models.py
from langflow.base.models.unified_models import get_unified_models_detailed def _flatten_models(result): """Helper to flatten result to list of model dicts.""" for provider_dict in result: yield from provider_dict["models"] def test_default_providers_present(): result = get_unified_models_detail...
{ "repo_id": "langflow-ai/langflow", "file_path": "src/backend/tests/unit/test_unified_models.py", "license": "MIT License", "lines": 59, "canary_id": -1, "canary_value": "", "pii_type": "", "provider": "", "regex_pattern": "", "repetition": -1, "template": "" }
test