mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-08 23:58:34 +00:00
- Implement ElasticsearchClient with full sync/async operations - Add ElasticsearchConfig with connection and embedding options - Create factory pattern following ChromaDB/Qdrant conventions - Add comprehensive test suite with 26 passing tests (100% coverage) - Support both sync and async Elasticsearch operations - Include proper error handling and edge case coverage - Update type system and factory to support Elasticsearch provider - Follow existing RAG patterns for consistency Resolves #3404 Co-Authored-By: João <joao@crewai.com>
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""Tests for optional imports."""
|
|
|
|
import pytest
|
|
|
|
from crewai.rag.config.optional_imports.base import _MissingProvider
|
|
from crewai.rag.config.optional_imports.providers import (
|
|
MissingChromaDBConfig,
|
|
MissingElasticsearchConfig,
|
|
)
|
|
|
|
|
|
def test_missing_provider_raises_runtime_error():
|
|
"""Test that _MissingProvider raises RuntimeError on instantiation."""
|
|
with pytest.raises(
|
|
RuntimeError, match="provider '__missing__' requested but not installed"
|
|
):
|
|
_MissingProvider()
|
|
|
|
|
|
def test_missing_chromadb_config_raises_runtime_error():
|
|
"""Test that MissingChromaDBConfig raises RuntimeError on instantiation."""
|
|
with pytest.raises(
|
|
RuntimeError, match="provider 'chromadb' requested but not installed"
|
|
):
|
|
MissingChromaDBConfig()
|
|
|
|
|
|
def test_missing_elasticsearch_config_raises_runtime_error():
|
|
"""Test that MissingElasticsearchConfig raises RuntimeError on instantiation."""
|
|
with pytest.raises(
|
|
RuntimeError, match="provider 'elasticsearch' requested but not installed"
|
|
):
|
|
MissingElasticsearchConfig()
|