Files
crewAI/tests/rag/config/test_factory.py
Greyson LaLonde 7ac482c7c9
Some checks failed
Notify Downstream / notify-downstream (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
feat: rag configuration with optional dependency support (#3394)
### RAG Config System

* Added ChromaDB client creation via config with sensible defaults
* Introduced optional imports and shared RAG config utilities/schema
* Enabled embedding function support with ChromaDB provider integration
* Refactored configs for immutability and stronger type safety
* Removed unused code and expanded test coverage
2025-08-26 00:00:22 -04:00

35 lines
1.0 KiB
Python

"""Tests for RAG config factory."""
from unittest.mock import Mock, patch
from crewai.rag.config.factory import create_client
def test_create_client_chromadb():
"""Test ChromaDB client creation."""
mock_config = Mock()
mock_config.provider = "chromadb"
with patch("crewai.rag.config.factory.require") as mock_require:
mock_module = Mock()
mock_client = Mock()
mock_module.create_client.return_value = mock_client
mock_require.return_value = mock_module
result = create_client(mock_config)
assert result == mock_client
mock_require.assert_called_once_with(
"crewai.rag.chromadb.factory", purpose="The 'chromadb' provider"
)
mock_module.create_client.assert_called_once_with(mock_config)
def test_create_client_unsupported_provider():
"""Test unsupported provider returns None for now."""
mock_config = Mock()
mock_config.provider = "unsupported"
result = create_client(mock_config)
assert result is None