| .. | ||
| __init__.py | ||
| conftest.py | ||
| README.md | ||
| test_agent_os.py | ||
| test_api.py | ||
| test_config.py | ||
| test_conversation_watcher.py | ||
| TEST_COVERAGE.md | ||
| test_document_processing.py | ||
| test_embeddings.py | ||
| test_file_watcher.py | ||
| test_health.py | ||
| test_hooks.py | ||
| test_ingestion_comprehensive.py | ||
| test_kb_metadata.py | ||
| test_learning_jobs.py | ||
| test_markdown_preprocessor.py | ||
| test_rag_engine.py | ||
| test_rag_engine_comprehensive.py | ||
| test_redis_config.py | ||
| test_spec_tracking.py | ||
| test_sqlite_manager.py | ||
| TESTING_GUIDE.md | ||
Claude OS Test Suite
Comprehensive tests for the Claude OS RAG system.
Setup
-
Install test dependencies:
pip install -r requirements.txt -
Set environment variables (optional):
export TEST_OLLAMA_HOST=http://localhost:11434Note: Tests use SQLite database which is automatically created in the test environment.
Running Tests
Run all tests:
pytest
Run specific test categories:
# Unit tests only (fast, no external dependencies)
pytest -m unit
# Integration tests (require database, Ollama)
pytest -m integration
# Vector operation tests
pytest -m vector
# RAG engine tests
pytest -m rag
# API endpoint tests
pytest -m api
Run specific test files:
pytest tests/test_pg_vector.py
pytest tests/test_rag_engine.py
pytest tests/test_api.py
Run with coverage:
pytest --cov=app --cov-report=html
# Open htmlcov/index.html to view coverage report
Run with verbose output:
pytest -v
Run and stop on first failure:
pytest -x
Test Structure
conftest.py- Shared fixtures and configurationtest_rag_engine.py- RAG engine functionalitytest_embeddings.py- Embedding generationtest_document_processing.py- Document ingestion and chunkingtest_api.py- FastAPI endpoints
Test Markers
Tests are categorized with markers:
@pytest.mark.unit- Fast unit tests, no external dependencies@pytest.mark.integration- Integration tests requiring database/Ollama@pytest.mark.slow- Tests that may take several seconds@pytest.mark.embeddings- Tests involving embedding generation@pytest.mark.vector- Tests involving vector operations@pytest.mark.rag- Tests involving RAG engine@pytest.mark.api- Tests involving API endpoints
Fixtures
Common fixtures available in all tests:
test_db_config- Database configurationdb_connection- Test database connection (session-scoped)clean_db- Clean database before each testsample_kb- Sample knowledge basesample_embedding- Sample 768-dimensional embeddingsample_documents- Sample documents with embeddingsmock_ollama_embedding- Mock Ollama embedding modelmock_ollama_llm- Mock Ollama LLMsample_text_file- Sample text filesample_pdf_file- Sample PDF filesample_markdown_file- Sample Markdown fileapi_client- FastAPI test client
CI/CD Integration
Tests can be run in CI/CD pipelines:
# Example GitHub Actions workflow
- name: Run tests
run: |
pytest --cov=app --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v3
Troubleshooting
Ollama connection errors:
- Ensure Ollama is running:
curl http://localhost:11434/api/tags - Check TEST_OLLAMA_HOST environment variable
Import errors:
- Ensure you're in the project root directory
- Install all dependencies:
pip install -r requirements.txt