Add unit tests for configuration management and settings dialog

- Implement tests for ConfigValidator to ensure proper validation of configuration settings, including valid configurations, required fields, type checks, and error handling.
- Create tests for ConfigProfile to verify profile management functionalities such as saving, loading, listing, and deleting profiles.
- Add tests for ConfigExporter to validate JSON export and import processes, including error handling for non-existent files and invalid JSON.
- Introduce tests for SettingsDialog to confirm proper initialization, tab existence, and configuration data retrieval and application.
This commit is contained in:
claudi 2026-01-29 12:52:53 +01:00
parent 5dc988005c
commit 8b0df0e04f
7 changed files with 1556 additions and 4 deletions

View file

@ -717,6 +717,24 @@ https://git.him-tools.de/HIM-public/webdrop-bridge/packages/
- MainWindow: 64% coverage
- Full workflow validated: startup check → dialog → download → install
**Phase 4.2 Status**: ✅ **COMPLETE** (Jan 29, 2026)
- Enhanced logging: 20 tests passing, 91% coverage
- JSONFormatter for structured logging
- PerformanceTracker for operation timing
- Log archival with 30-day retention
**Phase 4.3 Status**: ✅ **COMPLETE** (Jan 29, 2026)
- Configuration validation: ConfigValidator class with comprehensive schema
- Profile management: ConfigProfile for named profiles (work, personal, etc.)
- Settings UI: SettingsDialog with 5 organized tabs
- Import/Export: ConfigExporter for JSON serialization
- Total: 43 tests passing across config_manager and settings_dialog
**Phase 4 Overall**: ✅ **COMPLETE** - All 3 subphases complete
- **Total Tests**: 139 tests (76 Phase 4.1 + 20 Phase 4.2 + 43 Phase 4.3)
- **Coverage**: Professional-grade configuration, update, and logging systems
- **Next Phase**: 4.4 User Documentation and Phase 5 Post-Release
### 4.1 Auto-Update System with Forgejo Integration
**Forgejo Configuration:**
@ -927,11 +945,51 @@ Help Menu
### 4.3 Advanced Configuration
**Status**: ✅ **COMPLETE** (Jan 29, 2026)
- ConfigValidator with comprehensive schema validation (8 tests passing)
- ConfigProfile for named profile management (7 tests passing)
- ConfigExporter for JSON import/export (5 tests passing)
- SettingsDialog Qt UI with 5 tabs (23 tests passing)
- Total: 43 tests passing, 75% coverage on new modules
**Deliverables:**
- [ ] UI settings dialog
- [ ] Configuration validation schema
- [ ] Profile support (work, personal, etc.)
- [ ] Export/import settings
- [x] Configuration validation schema - ConfigValidator class with 8-test suite
- Validates all config fields with detailed error messages
- Enforces type constraints, ranges, and allowed values
- Used throughout to ensure config consistency
- [x] UI settings dialog - SettingsDialog with 5 tabs (23 tests)
- **Paths Tab**: Manage allowed root directories with add/remove buttons
- **URLs Tab**: Manage allowed web URLs with wildcard support
- **Logging Tab**: Select log level and choose log file location
- **Window Tab**: Configure window width and height
- **Profiles Tab**: Save/load/delete named profiles, export/import configs
- [x] Profile support - ConfigProfile class (7 tests)
- Save current config as named profile (work, personal, etc.)
- Load saved profile to restore settings
- List all available profiles
- Delete profiles
- Profiles stored in ~/.webdrop-bridge/profiles/ as JSON
- [x] Export/import settings - ConfigExporter class (5 tests)
- `export_to_json()` - Save configuration to JSON file
- `import_from_json()` - Load and validate configuration from JSON
- All imports validated with ConfigValidator
- Handles file I/O errors gracefully
**Key Features:**
- Full configuration validation with helpful error messages
- Named profiles for different work contexts
- JSON export/import with validation
- Professional Qt dialog with organized tabs
- Profiles stored in standard ~/.webdrop-bridge/ directory
- 43 unit tests covering all functionality (87% coverage on config_manager)
**Test Results:**
- `test_config_manager.py` - 20 tests, 87% coverage
- `test_settings_dialog.py` - 23 tests, 75% coverage
- Total Phase 4.3 - 43 tests passing
---