Spaces:
Running
on
Zero
A newer version of the Gradio SDK is available:
6.1.0
Warbler CDA Test Suite
Comprehensive test suite for the Warbler CDA (Cognitive Development Architecture) RAG system with GPU-accelerated embeddings and FractalStat hybrid scoring.
Test Organization
Test Files
test_embedding_providers.py - Embedding provider tests
TestEmbeddingProviderFactory- Factory pattern testsTestLocalEmbeddingProvider- Local TF-IDF provider testsTestSentenceTransformerProvider- GPU-accelerated SentenceTransformer provider testsTestEmbeddingProviderInterface- Interface contract validation
test_retrieval_api.py - Retrieval API tests
TestRetrievalAPIContextStore- Document store operationsTestRetrievalQueryExecution- Query execution and filteringTestRetrievalModes- Different retrieval modes (semantic, temporal, composite)TestRetrievalHybridScoring- FractalStat hybrid scoringTestRetrievalMetrics- Metrics and caching
test_fractalstat_integration.py - FractalStat integration tests
TestFractalStatCoordinateComputation- FractalStat coordinate computation from embeddingsTestFractalStatHybridScoring- Hybrid semantic + FractalStat scoringTestFractalStatDocumentEnrichment- Document enrichment with FractalStat dataTestFractalStatQueryAddressing- Multi-dimensional query addressingTestFractalStatDimensions- FractalStat dimensional space properties
test_rag_e2e.py - End-to-end RAG integration
TestEndToEndRAG- Complete RAG pipeline validation- 10 comprehensive end-to-end tests covering the full system
Running Tests
Install Dependencies
pip install -r requirements.txt
pip install pytest pytest-cov
Run All Tests
pytest tests/ -v
Run Specific Test Categories
# Embedding provider tests
pytest tests/test_embedding_providers.py -v
# Retrieval API tests
pytest tests/test_retrieval_api.py -v
# FractalStat integration tests
pytest tests/test_fractalstat_integration.py -v
# End-to-end tests
pytest tests/test_rag_e2e.py -v -s
Run Tests by Marker
# Embedding tests
pytest tests/ -m embedding -v
# Retrieval tests
pytest tests/ -m retrieval -v
# FractalStat tests
pytest tests/ -m fractalstat -v
# End-to-end tests
pytest tests/ -m e2e -v -s
# Exclude slow tests
pytest tests/ -m "not slow" -v
Run with Coverage
pytest tests/ --cov=warbler_cda --cov-report=html -v
Run Specific Test
pytest tests/test_embedding_providers.py::TestSentenceTransformerProvider::test_semantic_search -v
Test Coverage
The test suite covers:
- β Embedding provider creation and configuration
- β Single text and batch embedding generation
- β Embedding similarity and cosine distance calculations
- β Semantic search across embedding collections
- β Document ingestion into context store
- β Semantic similarity retrieval
- β Temporal sequence retrieval
- β Query result filtering by confidence threshold
- β FractalStat coordinate computation from embeddings
- β FractalStat resonance calculation between documents and queries
- β Hybrid semantic + FractalStat scoring
- β Document enrichment with embeddings and FractalStat data
- β Query result caching and metrics tracking
- β End-to-end RAG pipeline execution
Dependencies
- Core: pytest, warbler-cda
- Optional: sentence-transformers (for GPU-accelerated embeddings)
Expected Test Results
With SentenceTransformer Installed
All tests pass, including:
- GPU acceleration tests (falls back to CPU if CUDA unavailable)
- FractalStat coordinate computation tests
- Hybrid scoring tests
Without SentenceTransformer
Tests gracefully skip SentenceTransformer-specific tests and fall back to local TF-IDF provider.
Writing New Tests
When adding new tests, follow this pattern:
import pytest
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from warbler_cda import RetrievalAPI, RetrievalQuery, RetrievalMode
class TestMyFeature:
"""Test description."""
def setup_method(self):
"""Setup for each test."""
self.api = RetrievalAPI()
def test_my_feature(self):
"""Test my feature."""
# Arrange
self.api.add_document("doc_1", "test")
# Act
result = self.api.retrieve_context(query)
# Assert
assert result is not None
CI/CD Integration
The test suite is designed to work with CI/CD pipelines:
# Example GitHub Actions
- name: Run Warbler CDA Tests
run: pytest tests/ --cov=warbler_cda --cov-report=xml
Performance Considerations
- Embedding generation tests are fastest with local TF-IDF provider
- SentenceTransformer tests are slower but more accurate
- First SentenceTransformer test loads the model (cache warmup)
- Subsequent tests benefit from model caching
Troubleshooting
ImportError: No module named 'sentence_transformers'
Install the optional dependency:
pip install sentence-transformers
Tests hang on first SentenceTransformer test
The model is being downloaded. This is normal on first run. Progress can be monitored.
CUDA out of memory errors
The system automatically falls back to CPU. Tests will still pass but run slower.
Test file not found
Ensure you're running pytest from the warbler-cda-package directory:
cd warbler-cda-package
pytest tests/ -v