Files
flares/tests
Hermes 4887379896 fix: Testing validation - fix bugs discovered by pytest
Testing validation revealed 4 real implementation bugs:

1. security_utils.py sanitize_filename(): Missing shell metacharacters ($(){}[]) in regex
2. security_utils.py validate_path_within_root(): Error message casing mismatch 'Symlinks' vs 'symlinks'
3. security_utils.py safe_join_path(): Over-sanitizing __init__.py (underscore collapse)
4. security_utils.py validate_download_url(): URL validation too aggressive with false positives
5. logging_config.py LOG_LEVEL_ENV_MAP: Case mismatch - dict keys lowercase but env var uppercased

Added comprehensive test coverage:
- test_auth_utils.py: 12 tests for AuthManager, token loading, header generation
- test_logging_config.py: 17 tests for logger creation, SecureFormatter, log levels

Test results: 57 passing (all new tests + existing security_utils tests)
2026-11-07 16:27:25 -07:00
..

Test Suite

This directory contains automated tests for the FLARES project.

Directory Structure

tests/
├── unit/          # Unit tests for individual modules
│   ├── test_updater.py      # Security-critical updater module tests
│   └── ... (more tests TBD)
├── integration/   # Integration tests for multi-component workflows
└── fixtures/      # Test data and mock resources

Running Tests

# Install development dependencies
pip install -r requirements-dev.txt

# Run all unit tests
pytest tests/unit/ -v

# Run specific test file
pytest tests/unit/test_updater.py -v

# Run with coverage
pytest --cov=src tests/ -v

Test Coverage Goals

  • updater.py: 100% (security-critical)
  • Core modules: >80%
  • Overall project: >60% (initial target)

Writing Tests

See existing tests in tests/unit/test_updater.py for examples of:

  • Testing utility functions like version_compare()
  • Mocking external dependencies (QThread, HTTP requests)
  • Security-focused test cases