fix: Gate more tests on package presence

This commit is contained in:
Eric Hare
2026-05-14 17:15:37 -07:00
parent 5fec0a1a42
commit cf488e545c
2 changed files with 30 additions and 19 deletions

View File

@ -2370,13 +2370,6 @@
"line_number": 2970,
"is_secret": false
},
{
"type": "Hex High Entropy String",
"filename": "src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents.json",
"hashed_secret": "d6e6d7b4b115cd3b9d172623199f8c403055fecc",
"is_verified": false,
"line_number": 3789
},
{
"type": "Hex High Entropy String",
"filename": "src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents.json",
@ -2384,9 +2377,24 @@
"is_verified": false,
"line_number": 3206,
"is_secret": false
},
{
"type": "Hex High Entropy String",
"filename": "src/backend/base/langflow/initial_setup/starter_projects/Sequential Tasks Agents.json",
"hashed_secret": "d6e6d7b4b115cd3b9d172623199f8c403055fecc",
"is_verified": false,
"line_number": 3789
}
],
"src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json": [
{
"type": "Hex High Entropy String",
"filename": "src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json",
"hashed_secret": "de5b1f2ea12440f0a19893e82535166ea24c7ce3",
"is_verified": false,
"line_number": 203,
"is_secret": false
},
{
"type": "Hex High Entropy String",
"filename": "src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json",
@ -2401,14 +2409,6 @@
"hashed_secret": "d6e6d7b4b115cd3b9d172623199f8c403055fecc",
"is_verified": false,
"line_number": 650
},
{
"type": "Hex High Entropy String",
"filename": "src/backend/base/langflow/initial_setup/starter_projects/Simple Agent.json",
"hashed_secret": "de5b1f2ea12440f0a19893e82535166ea24c7ce3",
"is_verified": false,
"line_number": 203,
"is_secret": false
}
],
"src/backend/base/langflow/initial_setup/starter_projects/Social Media Agent.json": [
@ -3253,7 +3253,7 @@
"filename": "src/backend/tests/unit/components/files_and_knowledge/test_retrieval.py",
"hashed_secret": "3658a95db0b214e73694335448df084f979c526f",
"is_verified": false,
"line_number": 350,
"line_number": 358,
"is_secret": false
},
{
@ -3261,7 +3261,7 @@
"filename": "src/backend/tests/unit/components/files_and_knowledge/test_retrieval.py",
"hashed_secret": "3d3c09dc9101fcd18909dd4071d6429141ec1bef",
"is_verified": false,
"line_number": 418,
"line_number": 427,
"is_secret": false
},
{
@ -3269,7 +3269,7 @@
"filename": "src/backend/tests/unit/components/files_and_knowledge/test_retrieval.py",
"hashed_secret": "b871b1863882c37735c7754f2cb49d38356e7f1e",
"is_verified": false,
"line_number": 799,
"line_number": 810,
"is_secret": false
}
],
@ -8287,5 +8287,5 @@
}
]
},
"generated_at": "2026-05-07T19:13:33Z"
"generated_at": "2026-05-15T00:15:30Z"
}

View File

@ -1,3 +1,4 @@
import importlib.util
import json
import uuid
from pathlib import Path
@ -9,6 +10,12 @@ from lfx.components.files_and_knowledge.retrieval import KnowledgeBaseComponent
from tests.base import ComponentTestBaseWithClient
# langchain-ibm is gated to python_version<'3.14' in pyproject.toml because
# upstream pins exclude 3.14. Tests that patch langchain_ibm.* directly must
# be skipped when the package is unavailable.
_HAS_LANGCHAIN_IBM = importlib.util.find_spec("langchain_ibm") is not None
_NO_LANGCHAIN_IBM_REASON = "langchain-ibm not available (gated to python_version<'3.14')"
class TestKnowledgeBaseComponent(ComponentTestBaseWithClient):
@pytest.fixture
@ -331,6 +338,7 @@ class TestKnowledgeBaseComponent(ComponentTestBaseWithClient):
)
assert result == mock_embeddings
@pytest.mark.skipif(not _HAS_LANGCHAIN_IBM, reason=_NO_LANGCHAIN_IBM_REASON)
@patch("langchain_ibm.WatsonxEmbeddings")
def test_build_embeddings_watsonx(self, mock_watsonx_embeddings, component_class, default_kwargs):
"""Test building IBM WatsonX embeddings."""
@ -363,6 +371,7 @@ class TestKnowledgeBaseComponent(ComponentTestBaseWithClient):
)
assert result == mock_embeddings
@pytest.mark.skipif(not _HAS_LANGCHAIN_IBM, reason=_NO_LANGCHAIN_IBM_REASON)
def test_build_embeddings_watsonx_no_key(self, component_class, default_kwargs):
"""Test building IBM WatsonX embeddings without API key raises error."""
component = component_class(**default_kwargs)
@ -748,6 +757,7 @@ class TestKnowledgeBaseComponent(ComponentTestBaseWithClient):
mock_ollama_embeddings.assert_called_once_with(model="nomic-embed-text")
assert result == mock_embeddings
@pytest.mark.skipif(not _HAS_LANGCHAIN_IBM, reason=_NO_LANGCHAIN_IBM_REASON)
@patch("langchain_ibm.WatsonxEmbeddings")
def test_build_embeddings_watsonx_api_key_from_provider_vars(
self, mock_watsonx_embeddings, component_class, default_kwargs
@ -781,6 +791,7 @@ class TestKnowledgeBaseComponent(ComponentTestBaseWithClient):
)
assert result == mock_embeddings
@pytest.mark.skipif(not _HAS_LANGCHAIN_IBM, reason=_NO_LANGCHAIN_IBM_REASON)
@patch("langchain_ibm.WatsonxEmbeddings")
def test_build_embeddings_watsonx_partial_vars(self, mock_watsonx_embeddings, component_class, default_kwargs):
"""Test WatsonX with only apikey, no project_id or url."""