HeurAMS Test Suite
This directory contains comprehensive unit tests and examples for the Heuristic Assisted Memory Scheduler (HeurAMS) system.
Test Structure
Unit Tests
-
test_particles.py- Tests for core particle modules:Atom- Data container managementElectron- Memory algorithm metadata and SM-2 implementationNucleon- Content data managementOrbital- Learning strategy configurationProbe- File detection and cloze deletion scanningLoader- Data loading and saving
-
test_algorithms.py- Tests for algorithm modules:BaseAlgorithm- Abstract algorithm base classSM2Algorithm- SuperMemo-2 interval repetition algorithm
-
test_puzzles.py- Tests for puzzle generation modules:BasePuzzle- Abstract puzzle base classClozePuzzle- Cloze deletion puzzle generatorMCQPuzzle- Multiple choice question generator
-
test_reactor.py- Tests for reactor system modules:Phaser- Global scheduling state managementProcession- Memory process queue managementFission- Single atom scheduling and puzzle generationStates- State enumeration definitions
-
test_services.py- Tests for service modules:Config- Configuration managementHasher- Hash computation utilitiesTimer- Time services with override capabilityVersion- Version information managementAudioService- Audio feedback serviceTTSService- Text-to-speech service
Examples
examples.py- Comprehensive usage examples demonstrating:- Basic atom creation and management
- Algorithm usage and review processing
- Puzzle generation for different content types
- Reactor system workflows
- Service integration patterns
- File operations and data persistence
Test Utilities
-
conftest.py- Pytest configuration and fixtures:temp_config_file- Temporary configuration filesample_atom_data- Sample atom data for testingsample_markdown_content- Sample markdown with cloze deletions
-
run_tests.py- Test runner with flexible options
Running Tests
Run All Tests
python tests/run_tests.py
# or
python -m pytest tests/
Run Specific Tests
# Run specific test file
python tests/run_tests.py --file test_particles.py
# Run specific test class
python tests/run_tests.py --file test_particles.py --class TestAtom
# Run specific test method
python tests/run_tests.py --file test_particles.py --class TestAtom --method test_atom_creation
Run Examples
python tests/run_tests.py --examples
Using Pytest Directly
# Run all tests with coverage
pytest tests/ --cov=src.heurams --cov-report=html
# Run tests with specific markers
pytest tests/ -m "not slow"
# Run tests with verbose output
pytest tests/ -v
Test Coverage
The test suite provides comprehensive coverage for:
- Core Data Structures: Atom, Electron, Nucleon, Orbital
- Algorithms: SM-2 interval repetition implementation
- Puzzle Generation: Cloze deletions and multiple choice questions
- State Management: Reactor system state transitions
- Configuration: Settings management and validation
- Utilities: Hashing, timing, and file operations
Key Test Scenarios
Algorithm Testing
- SM-2 interval calculation in learning phase
- Ease factor adjustments based on review quality
- Repetition counting and reset logic
- Boundary conditions and edge cases
Puzzle Generation
- Cloze deletion detection and processing
- Multiple choice question generation with distractors
- Content type detection and appropriate puzzle selection
Reactor System
- State transitions (IDLE → LEARNING → REVIEW → FINISHED)
- Procession queue management
- Fission workflow for single atom processing
Service Integration
- Configuration loading and validation
- Time service with override capability
- Hash consistency and file operations
Fixtures and Test Data
The test suite includes reusable fixtures for:
- Temporary configuration files
- Sample atom data structures
- Test markdown content with cloze deletions
- Mock time values for testing scheduling
Example Usage Patterns
The examples.py file demonstrates common usage patterns:
- Basic Atom Creation - Creating simple question-answer pairs
- Cloze Content - Working with cloze deletion content
- Algorithm Integration - Processing reviews with SM-2
- Puzzle Generation - Creating different puzzle types
- Workflow Management - Using the reactor system
- Configuration - Customizing learning parameters
- Data Persistence - Saving and loading atom collections
Test Dependencies
pytest- Test frameworkpytest-cov- Coverage reporting (optional)- Standard Python libraries only
Adding New Tests
When adding new tests:
- Follow the existing naming conventions
- Use the provided fixtures when appropriate
- Include both positive and negative test cases
- Test boundary conditions and edge cases
- Ensure tests are independent and repeatable
Continuous Integration
The test suite is designed to run in CI environments and provides:
- Fast execution (most tests complete in seconds)
- No external dependencies
- Clear failure reporting
- Comprehensive coverage of core functionality