Add quick test runner and enhance run_tests script
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled

- Introduced `quick_test.py` for running specific test categories (unit, integration, theme, all).
- Updated `run_tests.py` to improve test execution and reporting, including coverage.
- Removed outdated test scripts for keyboard shortcuts, menu theming, note saving, and entry updating.
- Added new test script `test_theme_changing.py` to verify theme changing functionality.
- Consolidated integration tests into `test_integration.py` for comprehensive testing of TheChart application.
- Updated theme manager to ensure color retrieval works correctly.
- Modified test constants to import from the correct module path.
This commit is contained in:
William Valentin
2025-08-05 15:09:13 -07:00
parent df9738ab17
commit a521ed6e9a
46 changed files with 8325 additions and 1131 deletions

View File

@@ -1,110 +1,176 @@
# TheChart Scripts Directory
This directory contains interactive demonstrations and utility scripts for TheChart application.
This directory contains utility scripts and the **new consolidated test suite** for TheChart application.
## Scripts Overview
## 🚀 Quick Start
### Testing Scripts
#### `run_tests.py`
Main test runner for the application.
### Run All Tests
```bash
cd /home/will/Code/thechart
.venv/bin/python scripts/run_tests.py
```
#### `integration_test.py`
Comprehensive integration test for the export system.
- Tests all export formats (JSON, XML, PDF)
- Validates data integrity and file creation
- No GUI dependencies - safe for automated testing
### Run Specific Test Categories
```bash
cd /home/will/Code/thechart
# Unit tests only
.venv/bin/python scripts/quick_test.py unit
# Integration tests only
.venv/bin/python scripts/quick_test.py integration
# Theme-related tests only
.venv/bin/python scripts/quick_test.py theme
```
## 📁 Current Structure
### Active Scripts
#### `run_tests.py` 🎯
**Main test runner** - executes the complete test suite with coverage reporting.
- Runs unit tests with coverage
- Runs integration tests
- Runs legacy integration tests for backwards compatibility
- Provides comprehensive test summary
#### `quick_test.py` ⚡
**Quick test runner** - for specific test categories during development.
- `unit` - Fast unit tests only
- `integration` - Integration tests only
- `theme` - Theme-related functionality tests
- `all` - Complete test suite
#### `integration_test.py` 🔄
**Legacy integration test** - maintained for backwards compatibility.
- Tests export system functionality
- No GUI dependencies
- Called automatically by the main test runner
### Test Organization
#### Unit Tests (`/tests/`)
- `test_*.py` - Individual module tests
- Uses pytest framework
- Fast execution, isolated tests
- Coverage reporting enabled
#### Integration Tests (`tests/test_integration.py`)
- **Consolidated integration test suite**
- Tests complete workflows and interactions
- Includes functionality from old standalone scripts:
- Note saving and retrieval
- Entry updates and validation
- Theme changing functionality
- Keyboard shortcuts binding
- Menu theming integration
- Export system testing
- Data validation and error handling
## 🔄 Migration from Old Structure
The old individual test scripts have been **consolidated** into the unified test suite:
| Old Script | New Location | How to Run |
|------------|--------------|------------|
| `test_note_saving.py` | `tests/test_integration.py::test_note_saving_functionality` | `quick_test.py integration` |
| `test_update_entry.py` | `tests/test_integration.py::test_entry_update_functionality` | `quick_test.py integration` |
| `test_keyboard_shortcuts.py` | `tests/test_integration.py::test_keyboard_shortcuts_binding` | `quick_test.py integration` |
| `test_theme_changing.py` | `tests/test_integration.py::test_theme_changing_functionality` | `quick_test.py theme` |
| `test_menu_theming.py` | `tests/test_integration.py::test_menu_theming_integration` | `quick_test.py theme` |
### Benefits of New Structure
1. **Unified Framework**: All tests use pytest
2. **Better Organization**: Related tests grouped logically
3. **Improved Performance**: Optimized setup/teardown
4. **Coverage Reporting**: Integrated coverage analysis
5. **CI/CD Ready**: Easier automation and integration
## 🛠️ Development Workflow
### During Development
```bash
# Quick unit tests (fastest feedback)
.venv/bin/python scripts/quick_test.py unit
# Test specific functionality
.venv/bin/python scripts/quick_test.py theme
```
### Before Commits
```bash
# Full test suite with coverage
.venv/bin/python scripts/run_tests.py
```
### Individual Test Debugging
```bash
# Run specific test with output
.venv/bin/python -m pytest tests/test_integration.py::TestIntegrationSuite::test_theme_changing_functionality -v -s
# Run with debugger
.venv/bin/python -m pytest tests/test_integration.py::TestIntegrationSuite::test_note_saving_functionality -v -s --pdb
```
## 📋 Available Test Categories
### Unit Tests
- Fast, isolated component tests
- Mock external dependencies
- Test individual functions and classes
### Integration Tests
- Test component interactions
- Test complete workflows
- Validate data persistence
- Test UI functionality (without GUI display)
### Theme Tests
- Theme switching functionality
- Color scheme validation
- Menu theming consistency
- Error handling in theme system
### System Health Checks
- Configuration file validation
- Manager initialization tests
- Logging system verification
## 🏃‍♂️ Performance Tips
- Use `quick_test.py unit` for fastest feedback during development
- Use `quick_test.py integration` to test workflow changes
- Use `quick_test.py theme` when working on UI/theming
- Use `run_tests.py` for comprehensive testing before commits
## 🔧 Debugging Tests
### Common Commands
```bash
# Run with verbose output
.venv/bin/python -m pytest tests/ -v
# Stop on first failure
.venv/bin/python -m pytest tests/ -x
# Show local variables on failure
.venv/bin/python -m pytest tests/ -l
# Run with debugger on failure
.venv/bin/python -m pytest tests/ --pdb
```
### Debugging Specific Issues
```bash
# Debug theme issues
.venv/bin/python -m pytest tests/test_integration.py::TestIntegrationSuite::test_theme_changing_functionality -v -s
# Debug data management
.venv/bin/python -m pytest tests/test_data_manager.py -v -s
# Debug export functionality
.venv/bin/python scripts/integration_test.py
```
### Feature Testing Scripts
---
#### `test_note_saving.py`
Tests note saving and retrieval functionality.
- Validates note persistence in CSV files
- Tests special characters and formatting
#### `test_update_entry.py`
Tests entry update functionality.
- Validates data modification operations
- Tests date validation and duplicate handling
#### `test_keyboard_shortcuts.py`
Tests keyboard shortcut functionality.
- Validates keyboard event handling
- Tests shortcut combinations and responses
### Interactive Demonstrations
#### `test_menu_theming.py`
Interactive demonstration of menu theming functionality.
- Live theme switching demonstration
- Visual display of theme colors
- Real-time menu color updates
```bash
cd /home/will/Code/thechart
.venv/bin/python scripts/test_menu_theming.py
```
## Usage
All scripts should be run from the project root directory using the virtual environment:
```bash
cd /home/will/Code/thechart
source .venv/bin/activate.fish # For fish shell
# OR
source .venv/bin/activate # For bash/zsh
python scripts/<script_name>.py
```
## Test Organization
### Unit Tests
Located in `/tests/` directory:
- `test_theme_manager.py` - Theme manager functionality tests
- `test_data_manager.py` - Data management tests
- `test_ui_manager.py` - UI component tests
- `test_graph_manager.py` - Graph functionality tests
- And more...
Run unit tests with:
```bash
cd /home/will/Code/thechart
.venv/bin/python -m pytest tests/
```
### Integration Tests
Located in `/scripts/` directory:
- `integration_test.py` - Export system integration test
- Feature-specific test scripts
### Interactive Demos
Located in `/scripts/` directory:
- `test_menu_theming.py` - Menu theming demonstration
## Test Data
- Integration tests create temporary export files in `integration_test_exports/` (auto-cleaned)
- Test scripts use the main `thechart_data.csv` file unless specified otherwise
- No test data is committed to the repository
## Development
When adding new scripts:
1. Place them in this directory
2. Use the standard shebang: `#!/usr/bin/env python3`
3. Add proper docstrings and error handling
4. Update this README with script documentation
5. Follow the project's linting and formatting standards
6. For unit tests, place them in `/tests/` directory
7. For integration tests or demos, place them in `/scripts/` directory
📖 **See Also**: `TESTING_MIGRATION.md` for detailed migration information.