This directory contains the consolidated and enhanced test suite for the CADS Research Visualization System.
tests/
├── conftest.py # Pytest configuration and shared fixtures
├── fixtures/ # Test data and utilities
│ ├── sample_data.json # Sample test data
│ └── test_helpers.py # Test utility functions
├── database/ # Database tests
│ ├── test_connection.py # Database connectivity tests
│ └── test_data_integrity.py # Data integrity and validation tests
├── pipeline/ # ML pipeline tests
│ ├── test_data_processing.py # Data processing tests
│ └── test_full_pipeline.py # End-to-end pipeline tests
├── visualization/ # Frontend visualization tests
│ ├── test_html_structure.py # HTML structure and components
│ ├── test_rendering.py # Data visualization format tests
│ ├── test_interactions.py # UI interaction tests
│ └── test_data_loading.py # Data loading and format tests
├── test_project_structure.py # Project structure validation
├── run_tests.py # Test runner script
└── cleanup_old_tests.py # Cleanup script for migration
# Run fast unit tests (recommended for development)
python3 tests/run_tests.py --unit
# Run all tests
python3 tests/run_tests.py --all
# List available test categories
python3 tests/run_tests.py --listpython3 tests/run_tests.py --database- Database connection and authentication
- Data integrity and consistency
- Query performance
- Referential integrity
python3 tests/run_tests.py --pipeline- Data processing functionality
- ML pipeline execution
- Embedding generation and parsing
- Error handling and validation
python3 tests/run_tests.py --visualization- HTML structure and components
- Data visualization format
- UI interactions and accessibility
- Data loading and performance
python3 tests/run_tests.py --integration- End-to-end pipeline execution
- Full system integration
- Performance testing
# Run specific test file
python3 tests/run_tests.py --test tests/database/test_connection.py
# Run specific test method
python3 tests/run_tests.py --test tests/database/test_connection.py::TestDatabaseConnection::test_database_connection_success- Configuration file:
pytest.ini - Markers for test categorization (database, slow, integration, visualization)
- Minimal output for CI/CD compatibility
Tests automatically handle missing dependencies and database connections:
- Database tests skip if
DATABASE_URLnot configured - ML tests skip if dependencies (umap, hdbscan) not installed
- Visualization tests work with mock data when files not available
- Shared fixtures in
tests/conftest.py - Sample data in
tests/fixtures/sample_data.json - Test utilities in
tests/fixtures/test_helpers.py
- ✅ Database connectivity and integrity
- ✅ ML pipeline functionality
- ✅ Data processing and validation
- ✅ Frontend structure and interactions
- ✅ Error handling and edge cases
- ✅ Performance characteristics
- ✅ Minimal output for CI/CD
- ✅ Proper test isolation
- ✅ Mock data for offline testing
- ✅ Graceful handling of missing dependencies
- ✅ Clear test categorization
- ✅ Comprehensive fixtures and utilities
- ✅ Eliminated duplicate tests
- ✅ Logical grouping by functionality
- ✅ Shared utilities and fixtures
- ✅ Consistent naming conventions
- ✅ Proper pytest configuration
The test suite has been consolidated from fragmented tests across:
cads/tests/(removed duplicates)visuals/tests/(removed duplicates)scripts/test_*.py(preserved unique functionality)
- No Duplication: Eliminated 25+ duplicate test files
- Better Organization: Tests grouped by functionality
- Shared Resources: Common fixtures and utilities
- Multiple Execution Modes: Unit, integration, category-specific
- CI/CD Ready: Minimal output and proper error handling
- Maintainable: Clear structure and documentation
- Choose appropriate directory (
database/,pipeline/,visualization/) - Use existing fixtures from
tests/fixtures/ - Follow naming convention:
test_*.py - Add appropriate pytest markers
- Update this README if adding new categories
- Use descriptive test names
- Include docstrings for test methods
- Handle missing dependencies gracefully
- Use appropriate pytest markers
- Keep tests focused and isolated
- Use shared fixtures when possible
- Database tests failing: Check
DATABASE_URLin.env - ML tests skipped: Install ML dependencies (
pip install umap-learn hdbscan) - Import errors: Ensure project root is in Python path
- Slow tests: Use
--unitflag to skip slow integration tests
# Run with verbose output
python3 -m pytest tests/ -v
# Run with full traceback
python3 -m pytest tests/ --tb=long
# Run specific failing test with debug info
python3 -m pytest tests/path/to/test.py::test_name -v --tb=longThe test suite is designed for CI/CD integration:
- Minimal output by default (
-q --tb=short) - Proper exit codes for success/failure
- Graceful handling of missing dependencies
- Fast unit tests for quick feedback
- Comprehensive integration tests for full validation
- name: Run Unit Tests
run: python3 tests/run_tests.py --unit
- name: Run Database Tests
run: python3 tests/run_tests.py --database
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
- name: Run Full Test Suite
run: python3 tests/run_tests.py --allWhen contributing to the test suite:
- Follow existing patterns and conventions
- Add tests for new functionality
- Update documentation as needed
- Ensure tests pass in isolation
- Use appropriate test markers
- Consider both positive and negative test cases