claude-os/tests
Claude f6a1d6b417
🗂️ ORGANIZE: Reorganize root directory structure
Moved 25 files from root to organized subdirectories while keeping
essential scripts (install.sh, setup.sh, start*.sh, stop*.sh) in root.

## Changes:

### New Directory Structure:
- Created `/scripts/` for utility scripts
- Created `/docs/guides/` for user guides
- Created `/docs/development/` for dev documentation
- Created `/docs/archive/` for historical/legacy docs

### Moved Files:

**To `/scripts/` (7 files):**
- backup_claude_os.sh
- restore_claude_os.sh
- run_tests.sh
- setup_native.sh
- start_mcp_server.sh
- start_redis_workers.sh
- entrypoint.sh

**To `/docs/guides/` (7 files):**
- AUTH_SETUP.md
- BACKUP_RESTORE_GUIDE.md
- HOOK_SETUP_QUICK_START.md
- SHARING_GUIDE.md
- START_SCRIPTS_GUIDE.md
- PORTS_GUIDE.md
- WHAT_IS_CLAUDE_OS.md

**To `/docs/development/` (4 files):**
- COMPREHENSIVE_REVIEW.md
- SECURITY_FIXES.md
- CLAUDE_OS_DEVELOPER_GUIDE.md
- PROJECT_SETUP_AND_COMMANDS.md

**To `/docs/archive/` (10 files):**
- HYBRID_INDEXING_COMPLETE.md
- INITIALIZE_PROJECT_HOOKS_FIX.md
- INSTALL_ENHANCEMENTS.md
- INSTALL_FIXES.md
- PISTN_TEST_RESULTS.md
- SESSION_SUMMARY.md
- TEST_COVERAGE.md
- TEST_RESULTS.md
- TESTING_STATUS.md
- README_TESTING.md

### Updated References:

**Fixed broken documentation links in:**
- docs/QUICK_REFERENCE.md
- docs/PRODUCTION_DEPLOYMENT.md
- docs/SCRIPTS_GUIDE.md
- docs/development/SECURITY_FIXES.md
- docs/guides/BACKUP_RESTORE_GUIDE.md
- docs/development/CLAUDE_OS_DEVELOPER_GUIDE.md
- tests/TESTING_GUIDE.md
- tests/TEST_COVERAGE.md

**Script references updated to:**
- `./scripts/backup_claude_os.sh`
- `./scripts/restore_claude_os.sh`
- `./scripts/run_tests.sh`
- `./scripts/setup_native.sh`
- `./scripts/start_mcp_server.sh`
- `./scripts/start_redis_workers.sh`

### Remaining in Root (9 essential files):
- install.sh
- setup.sh
- start.sh
- start_all_services.sh
- stop_all_services.sh
- restart_services.sh
- README.md
- CLAUDE.md
- requirements.txt (+ GEMINI_DIAGRAM_PROMPT.md)

## Benefits:
✅ Cleaner root directory (9 files vs 34 files)
✅ Organized documentation by purpose
✅ Scripts grouped in dedicated directory
✅ Essential startup commands still in root
✅ All references updated and verified
✅ No broken links

Version: 2.0.2
2025-11-04 21:34:26 +00:00
..
__init__.py Almost got the mosnter finished 2025-10-27 17:41:44 -05:00
conftest.py test(core): Fix test suite and improve core configuration 2025-10-27 21:52:46 -05:00
README.md Project cleanup 2025-10-31 16:54:28 -05:00
test_agent_os.py test(core): Fix test suite and improve core configuration 2025-10-27 21:52:46 -05:00
test_api.py mostly working correctly 2025-10-24 16:17:47 -05:00
test_config.py test(core): Fix test suite and improve core configuration 2025-10-27 21:52:46 -05:00
test_conversation_watcher.py test(core): Fix test suite and improve core configuration 2025-10-27 21:52:46 -05:00
TEST_COVERAGE.md 🗂️ ORGANIZE: Reorganize root directory structure 2025-11-04 21:34:26 +00:00
test_document_processing.py mostly working correctly 2025-10-24 16:17:47 -05:00
test_embeddings.py mostly working correctly 2025-10-24 16:17:47 -05:00
test_file_watcher.py All is working correctly 2025-10-27 21:57:06 -05:00
test_health.py Project cleanup 2025-10-31 16:54:28 -05:00
test_hooks.py All is working correctly 2025-10-27 21:57:06 -05:00
test_ingestion_comprehensive.py All is working correctly 2025-10-27 21:57:06 -05:00
test_kb_metadata.py All is working correctly 2025-10-27 21:57:06 -05:00
test_learning_jobs.py All is working correctly 2025-10-27 21:57:06 -05:00
test_markdown_preprocessor.py All is working correctly 2025-10-27 21:57:06 -05:00
test_rag_engine.py mostly working correctly 2025-10-24 16:17:47 -05:00
test_rag_engine_comprehensive.py All is working correctly 2025-10-27 21:57:06 -05:00
test_redis_config.py All is working correctly 2025-10-27 21:57:06 -05:00
test_sqlite_manager.py All is working correctly 2025-10-27 21:57:06 -05:00
TESTING_GUIDE.md 🗂️ ORGANIZE: Reorganize root directory structure 2025-11-04 21:34:26 +00:00

Claude OS Test Suite

Comprehensive tests for the Claude OS RAG system.

Setup

  1. Install test dependencies:

    pip install -r requirements.txt
    
  2. Set environment variables (optional):

    export TEST_OLLAMA_HOST=http://localhost:11434
    

    Note: 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 configuration
  • test_rag_engine.py - RAG engine functionality
  • test_embeddings.py - Embedding generation
  • test_document_processing.py - Document ingestion and chunking
  • test_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 configuration
  • db_connection - Test database connection (session-scoped)
  • clean_db - Clean database before each test
  • sample_kb - Sample knowledge base
  • sample_embedding - Sample 768-dimensional embedding
  • sample_documents - Sample documents with embeddings
  • mock_ollama_embedding - Mock Ollama embedding model
  • mock_ollama_llm - Mock Ollama LLM
  • sample_text_file - Sample text file
  • sample_pdf_file - Sample PDF file
  • sample_markdown_file - Sample Markdown file
  • api_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